Using MSBuild Extension Pack and AssemblyInfo to automate the version number, why does it fail when added to an existing project?

StackOverflow https://stackoverflow.com/questions/14139154

Question

I have a large project that consists of several solutions which all contain a mix of unique and shared projects.

I'm trying to make them all have the same auto-incremented version number when I run my batch build of all of the solutions.

The first two digits need to be fixed, second two auto increment.

This appears to be the default behaviour of the AssemblyInfo class in the MSBuild Extension Pack

So I've followed the guide here: http://www.msbuildextensionpack.com/help/3.5.12.0/html/d6c3b5e8-00d4-c826-1a73-3cfe637f3827.htm

And I'm mostly getting nowhere.

If I add the following line to a simple, brand new test project:

<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.VersionNumber.targets"/>

It works fine. Every time a build the project in VS it updates the version number.

However, if I add the exact same line to the first project in my existing solution, I get the following error:

Unable to update the AssemblyFileVersion for AssemblyInfo.cs: No stub entry for AssemblyFileVersion was found in the AssemblyInfo file.

The contents of AssemblyInfo.cs are:

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("02ecd067-a91c-44bc-a486-a7b097157757")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Almost entirely identical to the working test version:

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("AutoVersionTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("AutoVersionTest")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("33c1d540-f9c4-4cc5-86ed-9d8695bf7b4d")]
[assembly: AssemblyVersion("1.0.0103.01")]
[assembly: AssemblyFileVersion("1.0.0103.01")]

So why does it work in one but not the other?

Was it helpful?

Solution

I would make sure that the AssemblyInfo.cs file is physically in the project and not linked in from another project.

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