Welcome to MSDN Blogs Sign in | Join | Help

Fixing invalid version number problems with the AssemblyInfoTask

The arrival of 2007 bought a flurry of e-mails to the MSBuild team from people having trouble with the AssemblyInfoTask. The symptom is simple to describe - the builds start to fail with the following error:

Error emitting 'System.Reflection.AssemblyVersionAttribute' attribute -- 'The version specified '1.0.70102.1' is invalid

The fix to get builds going again is to change the date format used to generate the build number to something other than the default "yyMMdd". The date formats are in Microsoft.VersionNumber.target, located in %program files%\MSBuild\Microsoft\AssemblyInfoTask, and there are two of them (one for file version and one for assembly version). You can use any format you want. Within Visual Studio we're now using 01MMdd.

Note that you may have to go in and hand-edit your assemblyinfo.* files to change their version number back to a default starting point of 1.0.0.0 to get your builds going again.

Questions or problems after doing the above? Contact us using the e-mail link at the top of this page.

[ Author: Neil Enns ]

Published Wednesday, January 03, 2007 6:33 PM by msbuild

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

Wednesday, January 03, 2007 1:47 PM by MSBuild Team Blog

# Why are build numbers limited to 65535?

In my previous post I explained how to fix the issue with the default date format provided in the AssemblyVersionTask.

Wednesday, January 03, 2007 4:10 PM by MSBuild Team Blog

# How To: Update Assembly Version Numbers with MSBuild

UPDATE: For information on the "Y7K" or "2007" issue, see our new blog entry . One of our most frequently

Saturday, January 06, 2007 8:44 PM by Buck Hodges

# How to deal with the Y2K7 problem -- file versions and AssemblyInfoTask

If you use the AssemblyInfoTask to stamp the version numbers for your assemblies that you build with

Thursday, January 11, 2007 11:59 PM by Jonathan Reyes

# re: Fixing invalid version number problems with the AssemblyInfoTask

Great fix.

I do have a suggestion. I think its better to use MMddyy than 01MMdd.

But still thanks for the great fix.

Friday, January 12, 2007 2:16 PM by Greg

# re: Fixing invalid version number problems with the AssemblyInfoTask

Are none of you old enough to remember the old days, where storage was expensive enough that cutting one byte out of each record in a file could be a huge savings?

I changed my version to use yyddd, where the first two digits are the year, and the last three digits are the day of the year, 1-365(366).  You can guess at the number -- 32 is February 1st, July 1st is just over 180, etc. -- or you can figure it out easily enough if you need to know what day of the year 246 is.

And yes, some people have pointed out that I've just replaced the Y2K7 problem with the Y2K66 problem, but I hope I'll be retired by then.

Wednesday, January 17, 2007 4:28 PM by Steve

# re: Fixing invalid version number problems with the AssemblyInfoTask

Greg - your julian dateformat string doesn't work.  When I use yyddd it throws and exception trying to parse it, most likely because ddd means "short name of day" as in "Mon".  Is this solution actually working for you?  If so, what other mods did you make to get it going?

Thanks.

Friday, February 23, 2007 6:02 AM by VIO

# re: Fixing invalid version number problems with the AssemblyInfoTask

What if, we use the following format - "YYWKDY" where WK represents the week of year (max 2 digits) and DY represents the day of week (max 1 digit).

E.g. for 02/23/2007 will have 07086 which is year 2007, week 08 and day 6 of week.

Wednesday, March 28, 2007 8:50 PM by JZ

# re: Fixing invalid version number problems with the AssemblyInfoTask

I followed VIO response of using YYWDDY using ISO date formats.  I get the error: "Input string was not in a correct format. Failed to increment Build Number!"  So, for example my value is 07133 which when converted to a long is 7133 for my build number.  Anyone know how to fix the error?

Thursday, March 29, 2007 4:14 PM by RJS

# re: Fixing invalid version number problems with the AssemblyInfoTask

seems to me that the best way around this one is allowing a value to exceed UInt16 - maybe a 32 would have been more appropriate.

The person that decided to use the date for their buildnumber is going "doh!" about now....

Of course the one that decided the version numbers should be limited to an UInt16 never dreamed of a date value being used.

granted, the yyddd idea isn't bad- but the year is still the clincher-

so- put the day first... 36599 - would keep you below 65535 (until you tried to squeeze a 4 digit year in).

Wednesday, September 19, 2007 8:28 PM by Chris Eldredge

# re: Fixing invalid version number problems with the AssemblyInfoTask

I guess I'm the only person that actually injects a serial build number from an integration server into my assembly versions.  Good thing my projects are only a year old and the build number is in the 4,000s.

Monday, December 10, 2007 10:22 PM by Steve

# re: Fixing invalid version number problems with the AssemblyInfoTask

What am I missing? I am still getting the error: Error 11 Error emitting 'System.Reflection.AssemblyVersionAttribute' attribute -- 'The version specified '1.0.71210.8' is invalid' AssemblyInfo\Debug\AssemblyInfo.cs

I made the following mod:

 <PropertyGroup>

   <AssemblyMajorVersion>1</AssemblyMajorVersion>

   <AssemblyMinorVersion>0</AssemblyMinorVersion>

   <AssemblyBuildNumber></AssemblyBuildNumber>

   <AssemblyRevision></AssemblyRevision>

   <AssemblyBuildNumberType>DateString</AssemblyBuildNumberType>

   <AssemblyBuildNumberFormat>MMddyy</AssemblyBuildNumberFormat>

   <AssemblyRevisionType>AutoIncrement</AssemblyRevisionType>

   <AssemblyRevisionFormat>00</AssemblyRevisionFormat>

 </PropertyGroup>

 <!-- Properties for controlling the Assembly File Version -->

 <PropertyGroup>

   <AssemblyFileMajorVersion>1</AssemblyFileMajorVersion>

   <AssemblyFileMinorVersion>0</AssemblyFileMinorVersion>

   <AssemblyFileBuildNumber></AssemblyFileBuildNumber>

   <AssemblyFileRevision></AssemblyFileRevision>

   <AssemblyFileBuildNumberType>DateString</AssemblyFileBuildNumberType>

   <AssemblyFileBuildNumberFormat>MMddyy</AssemblyFileBuildNumberFormat>

   <AssemblyFileRevisionType>AutoIncrement</AssemblyFileRevisionType>

   <AssemblyFileRevisionFormat>00</AssemblyFileRevisionFormat>

 </PropertyGroup>

Tuesday, January 29, 2008 5:42 AM by อภิรมย์ กริ่มใจ

# re: Fixing invalid version number problems with the AssemblyInfoTask

99/28 ม.อยู่สบาย ข.สะพานสูง ถ.กรุงเทพกรีฑา กรุงเทพๆ

# re: Fixing invalid version number problems with the AssemblyInfoTask

99/28 ม.บ้านอยู่สบาย ถ.กรุงเทพกรีฑา ข.สะพานสูง

กรุงเทพๆ 10400

Monday, March 17, 2008 6:56 PM by Denis

# re: Fixing invalid version number problems with the AssemblyInfoTask

I have found another workaround-Versioning that could work in my eyes: Use the year as Build-Number and Month/Day as Revision.

If you really publish something you won't likely have more than one release each day, right?

Thursday, March 20, 2008 9:17 AM by Jason

# re: Fixing invalid version number problems with the AssemblyInfoTask

@Denis

If you have an automated build process and you check in each change into source control and go on to add a new change, a build would be generated after each check in. So yes, you could likely have more than one "release" in a day.

Friday, April 11, 2008 3:33 PM by Randar Puust

# re: Fixing invalid version number problems with the AssemblyInfoTask

Since everyone seems to have a solution, we are going to try the following:

Major.Minor.YYMM.DDBuildNumber

So you would have:

-5.0.0801.220 is Version 5, built on Jan 22nd, 2008.  

-5.0.0801.2211 is Version 5, built on Jan 22nd, 2008, 11th build of the day.  

-5.1.200801.010 is Version 5.1, built on Jan 1st, 2008.

It's a bit cryptic, but at least it fits within the bounds unless you have an insane number of builds.

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker