I am trying to get the text (2018.09.06
) of the Version attribute of my Asp.Net Core 2 MVC project, which is captured in the project's options dialog:
The value is contained in the ReleaseVersion
element in project's .csproj
file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RootNamespace>Project Foo</RootNamespace>
<ReleaseVersion>2018.09.06</ReleaseVersion>
<UserSecretsId>[GUID here]</UserSecretsId>
</PropertyGroup>
...
</Project>
I've tried this:
var version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version;
But it returns 1.0.0.0
.
I'm using .Net Core 2.0 Framework.
Note: the answers to Display project version in ASP.NET MVC Core application (RC2) don't work.