11

As you can see in the following picture when you create a project of type Analyzer with Code Fix (.NET Standard) using VS 2017, in the properties tab of the project there is package version, assembly version and assembly file version.

enter image description here

Are those 3 versions related together or not? Also, as I make changes in the project how am I supposed to change the versions number? For instance, if I fix a bug, if I add a new rule, etc.

Mo Sadeghipour
  • 489
  • 8
  • 25
  • http://www.lionhack.com/2014/03/09/software-versioning-strategies/ Broad subject though... version control, build systems, lifecycle strategy, deploy/rollout strategy, bug management, etc. Short answer: you will need to decide! – Alexandru Clonțea Mar 03 '18 at 13:05
  • Also see: https://stackoverflow.com/questions/356543/can-i-automatically-increment-the-file-build-version-when-using-visual-studio – Alexandru Clonțea Mar 03 '18 at 13:09
  • Package version is the NuGet the package version number you are assigning – Ken Tucker Mar 03 '18 at 13:44
  • Package version is a string, it could be, say, "1.0.0-beta1". You are expected to use semantic versioning, major.minor.patch, where major is incremented for a breaking change, minor for a change that is backwards compatible and patch for bug fixes. It is prominently visible on the Nuget home page. Assembly version bangs a different drum, that is what the CLR actually checks. Not incrementing it for a patch or minor change is okay and keeps the assembly compatible. No reason otherwise to make the numbers drastically different. – Hans Passant Mar 03 '18 at 13:58
  • Versioning is much more complex, so before knowing more about your project it is impossible to give a concrete answer. You might refer to famous packages such as JSON.NET, http://james.newtonking.com/archive/2012/04/04/json-net-strong-naming-and-assembly-version-numbers – Lex Li Mar 03 '18 at 16:15

1 Answers1

12

Are those 3 versions related together or not? Also, as I make changes in the project how am I supposed to change the versions number? For instance, if I fix a bug, if I add a new rule, etc.

Before answering this question, we need to know some info about the AssemblyVersionand AssemblyFileVersion.

Assembly Version: This is the version that .Net looks at during run-time for loading packages and finding types.

Assembly File Version: This defines the version reported by the OS to other applications like Windows Explorer.

You can see the Rémy van Duijkeren`s answer for some more details.

However, NuGet doesn’t use either of these. It uses a third versioning attribute: AssemblyInformationalVersion - the Product version of the assembly.

It uses this attribute because nothing else seems to care about it. The informational version isn’t used by the OS or by .Net, which means it’s available for NuGet to claim. But this versioning attribute was removed in the AssemblyInfo.cs file, because they don’t apply to semantic versioning.

When you are in the project of type Analyzer with Code Fix (.NET Standard) using VS 2017, those attributes settings has moved into the .csproj file. By default they don't show up but you can discover them from Visual Studio 2017 in the project properties Package tab:

enter image description here

Once saved those values can be found in MyProject.csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
    <Version>1.2.3.4</Version>
    <Authors>Author 1</Authors>
    <Company>Company XYZ</Company>
    <Product>Product 2</Product>
    <PackageId>MyApp</PackageId>
    <AssemblyVersion>2.0.0.0</AssemblyVersion>
    <FileVersion>3.0.0.0</FileVersion>
    <NeutralLanguage>en</NeutralLanguage>
    <Description>Description here</Description>
    <Copyright>Copyright</Copyright>
    <PackageLicenseUrl>License URL</PackageLicenseUrl>
    <PackageProjectUrl>Project URL</PackageProjectUrl>
    <PackageIconUrl>Icon URL</PackageIconUrl>
    <RepositoryUrl>Repo URL</RepositoryUrl>
    <RepositoryType>Repo type</RepositoryType>
    <PackageTags>Tags</PackageTags>
    <PackageReleaseNotes>Release</PackageReleaseNotes>
  </PropertyGroup>

In the file explorer properties information tab, Version is shown as "Product version", which is used by NuGet. Just like the versioning attribute: AssemblyInformationalVersion.

So, if you fix a bug or add a new rule, you can change the package version for shipping new package.

major is incremented for a breaking change, minor for a change that is backwards compatible and patch for bug fixes.

As to whether it needs to be modified the versions number for Assembly Versions, you can refer to this document for some more details.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135