- #Change version of .net in visual studio osx code
- #Change version of .net in visual studio osx windows
Using (FileStream file = new FileStream(Assembly.GetEntryAssembly().Location, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) We then apply a local timezone adjustment to adjust for UTC. Unfortunately, this is a slightly messy calculation, as we have to count the number of seconds from the 1st Jan 1970. While getting a version number is great, seeing a last modified date provides a lot more context and is easier for a human to comprehend and confirm the deployment was successful. In this example, this will return the version number for the project this is run in: string appVersion = Assembly.GetEntryAssembly().GetCustomAttribute().Version Extracting our application assembly build timeįinally, as a bonus, we are getting the entry assembly last modification date – this is when the assembly was built. Our application assembly version is a little simpler. FrameworkName Extracting our application assembly version Net 3.0 preview that is floating around too. In our case, this displays “.NETCoreApp,Version=v2.2”.
#Change version of .net in visual studio osx code
Note that you need a “using System.Reflection” on the top of the code file you are using this for, as prefixing it to the Assembly name does not work. Net Core version our application is targeting, we use the System.Reflection namespace again to get the entry assembly information.
Note that this namespace is also useful if you need to branch your code for specific operating systems, for example: if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
#Change version of .net in visual studio osx windows
We run our application in Azure on a Windows web server, so it displays “Microsoft Windows 3”, but this will display other operating systems too. To get the operating system our application is running on, we just need to call the System.Runtime namespace for the “OSDescription”. To start today, we are going to extract some key version information with C# to display in our application, before diving into the details of customizing that version. This all helps with troubleshooting and to ensure we are running the version we expect, without loading the Azure Portal or our code. Net version, underlying operating system, and our assembly information. As we have a lot of projects to balance, easily viewing the. One of the best practices we’ve found over the years is to include versioning information right on our website.