Wednesday 10 September 2008

CS1504 & MSBuild

I have just spent half a day trying to reason why VS2008 is happy to build a solution in a particular configuration, but MSBuild 2008 is not prepared to build exactly the same solution in the same configuration!

First a bit of background, we use a AssemblyInfoCommon.cs file to contain all of the common bits of the assembly information, such as copyright, dates, build numbers etc. This is included into each of our C# projects as a link. It then appears in the VS Solution Explorer and all is well.

When I was getting this strange error code of CS1504 and complaining of not being able to find the common file in the project folder, I was a little bemused because the file doesn't live there, but in the parent folder. After much faffing, I discovered that the project file had been hand edited (always a warning sign) and the link to ..\AssemblyInfoCommon.cs was actually ../AssemblyInfoCommon.cs. The incorrect /, rather than \, was the culprit, looks like MSBuild cannot handle it and bails, where as VS2008 just ignores it, so in this case it didn't appear in the solution explorer!


No comments: