Scott
Scott

Reputation: 13921

Assembly versioning in .NET Core 1.1 (SDK Preview 3)

There are plenty of resources online for bumping and reading version numbers using project.json. Given its deprecation and the re-introduction of .csproj, how do I go about setting the version number for a web project?

I've been able to read it with:

Microsoft.Extensions.PlatformAbstractions
    .PlatformServices.Default.Application.ApplicationVersion

However, it always outputs 1.0.0.0, and I haven't been able to find where that version number is set.

Upvotes: 2

Views: 92

Answers (1)

Shaun Luttin
Shaun Luttin

Reputation: 141462

Use the <VersionPrefix>5.4.3.2</VersionPrefix> property.

temp.csproj

 ...

  <PropertyGroup>
    <VersionPrefix>5.4.3.2</VersionPrefix>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <AssemblyName>temp</AssemblyName>
    <OutputType>Exe</OutputType>
  </PropertyGroup>

...    

Program.cs

public class Program
{
    public static void Main()
    {
        var version = Microsoft
            .Extensions
            .PlatformAbstractions
            .PlatformServices
            .Default
            .Application
            .ApplicationVersion;

        System.Console.WriteLine(version); // 5.4.3.2
    }
}

Upvotes: 2

Related Questions