Question

We have our AssemblyVersion and AssemblyFileVersion attributes in a separate properties file. This is because they are "linked" between all the projects and are updated by the build server. We don't want to have to manually update versions after every build or release.

AssemblyInfo.cs:

[assembly: AssemblyTitle("MyProductTitle")]
[assembly: AssemblyCulture("")]
[assembly: Guid("579eb194-08f1-44fc-9422-21aaf6cb2963")]

AssemblyVersionInfo.cs:

[assembly: AssemblyFileVersion("0.0.14056.19")]
[assembly: AssemblyVersion("0.0.0.0")]

The problem is that our build server complains with the following warning for each project:

CA1016 : Microsoft.Design : Add an AssemblyVersion attribute to 'MyProduct.dll'.

When building the projects locally, the actually DLL files in bin have all the version numbers applied (file property dialog):

File properties

When looking at the project properties in Visual Studio, the version info is not detected in Assembly Info:

VS Project properties

My guess is that this is due to AssemblyVersion and AssemblyFileVersion not residing in AssemblyInfo.cs.

Is there any way to "include" the custom AssemblyVersionInfo.cs file?

Was it helpful?

Solution

More than one thing going wrong here:

  • The dialog is pretty empty because it strictly looks at the AssemblyInfo.cs file for attributes. And will write them to that file if you enter a version number. Using a separate file is not a great idea.

  • The Windows "Details" property sheet is agnostic of .NET, it only displays the content of the unmanaged version resource in the file. Which is only indirectly related to the attributes in your C# source code, the C# compiler auto-generates the unmanaged version resource from the attributes. Sadly, the super-important [AssemblyVersion] number is not displayed in this dialog, XP was the last Windows version that could still display it.

  • You probably got CA1016 because you left the version number at 0.

Windows not displaying the [AssemblyVersion] is not a good reason to skip the attribute. If it is important to you to see it in the property sheet then simply make the [AssemblyFileVersion] the same as the [AssemblyVersion]. Do keep in mind what it used for, if you change the [AssemblyVersion] then all of the projects that have a reference to the assembly need to be recompiled.

There's bad history between the Windows and DevDiv groups at Microsoft, I don't want to get into the details of it. Let's just say that Windows does very little to accommodate .NET. It is up to us to work around this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top