0

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?

RoboJ1M
  • 1,590
  • 2
  • 27
  • 34
  • I'm just taking a stab in the dark here, but I would make sure that the AssemblyInfo.cs file is physically in the project and not linked in from another project. – BryanJ Jan 03 '13 at 12:48
  • Well stabbed, there were two AssemblyInfo.cs files in the folder, one in the root and one in Properties. Only one, the one in properties, is IN the project. However, if I delete the one in root (holdover from VS2003) the error changes to AssemblyInfo.cs not found. And the file I just deleted had no AssemblyFileVersion in it. – RoboJ1M Jan 03 '13 at 12:53
  • And a quick restart of VS2008 and now it works. – RoboJ1M Jan 03 '13 at 12:58

1 Answers1

1

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

BryanJ
  • 8,485
  • 1
  • 42
  • 61
  • Also I would add: Make sure you don't have multiple AssemblyInfo.cs files hanging around in your project folder. It was having two that stuffed me, one in the "new" location and one in the "old" location (VS2003/2005 change) – RoboJ1M Jan 03 '13 at 12:59
  • Oh and it caches the location, so restart VS as well. – RoboJ1M Jan 03 '13 at 13:00