MSBuild 4 fails to build VS2008 csproj due to 1 compiler warning
We have a VS2008 CS DLL project targeting .NET 3.5. It builds successfully on our CI server when using MSBuild 3.5.
When CI is upgraded to use MSBuild 4.0, the same project fails to build, due to 1 warning message:
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.t开发者_如何学运维argets(1418,9): warning MSB3283: Cannot find wrapper assembly for type library "ADODB".
The warning does not occur with MSBuild 3.5, and I'm surprised that it results in Build FAILED. We do not have the project set to treat warnings as errors.
All our other projects build successfully with either version of MSBuild.
The error message was not telling the whole story. The ADODB assembly on our dev machines is loaded in the GAC. That was not the case on the CI build machine.
The reference to ADODB was only placed into our C# project by a TLBIMP pre-build task, within the C# project (along with references to MSXML and VBA dlls). The latter DLLs are included in our source code repository, and thus found during the CI build process. ADODB is not. However, we also discovered that we could safely remove from the C# project all the added references, including the one to ADODB.DLL.
This fixed the problem. (Thanks for your suggestions -- they kept me thinking till we got there.)
Try either removing any hardwired toolsversion in your msbuild (and csproj) files, or setting them to ToolsVersion="4.0".
Read: http://msdn.microsoft.com/en-us/library/bb383796.aspx for a better understanding of the significance of the attribute. Since you want to target 3.5, make sure you have the target framework version set up correctly by checking that the TargetFrameworkVersion in your csproj.
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
If you set the ToolsVersion to 4.0, any machine that wants to build the project, will have a dependency on the 4.0 framework (which has the 4.0 msbuild), even though you're targetting 3.5.
If you're targetting 3.5, and your projects are VS2008, there's no need to use msbuild 4.0 over msbuild 3.5 (they can exist peacefully side by side). Just using the 3.5 msbuild would be the simpler solution.
This is a ClickOnce issue. Remove that dependency from the list.
BTW, this bug is present in VS2008 too, but seems to not have triggered for you.
精彩评论