A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://dotnet.github.io/Nerdbank.GitVersioning/docs/ecosystems/dotnet.html below:

.NET | Nerdbank.GitVersioning

.NET

Nerdbank.GitVersioning offers first class version stamping support for .NET assemblies and NuGet packages.

Hello, World! for versioning

The following commands demonstrate Nerdbank.GitVersioning on a new project:

mkdir NbgvExample
cd NbgvExample
git init
dotnet new classlib --framework=netstandard2.0
git add *.cs *.csproj
git commit -m "Plain vanilla project"
dotnet tool install -g nbgv
nbgv install
git commit -m "Add version stamping"
dotnet pack
dir .\bin\Release\*.nupkg

This will build a package versioned 1.0.1-beta.

Then make a small change, commit the change, and pack again to see the version change:

touch README.md
git add README.md
git commit -m "Add README"
dotnet pack
dir .\bin\Release\*.nupkg

Now we have another package, the new one versioned 1.0.2-beta.

Assembly version generation

During the build Nerdbank.GitVersioning adds source code such as this to your compilation:

[assembly: System.Reflection.AssemblyVersion("1.0")]
[assembly: System.Reflection.AssemblyFileVersion("1.0.24.15136")]
[assembly: System.Reflection.AssemblyInformationalVersion("1.0.24-alpha+g9a7eb6c819")]

This class is also injected into your project at build time:

internal sealed partial class ThisAssembly {
    internal const string AssemblyVersion = "1.0";
    internal const string AssemblyFileVersion = "1.0.24.15136";
    internal const string AssemblyInformationalVersion = "1.0.24-alpha+g9a7eb6c819";
    internal const string AssemblyName = "Microsoft.VisualStudio.Validation";
    internal const string PublicKey = @"0024000004800000940000...reallylongkey..2342394234982734928";
    internal const string PublicKeyToken = "b03f5f7f11d50a3a";
    internal const string AssemblyTitle = "Microsoft.VisualStudio.Validation";
    internal const string AssemblyConfiguration = "Debug";
    internal const string RootNamespace = "Microsoft";
}

This allows you to actually write source code that can refer to the exact build number your assembly will be assigned.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4