MSBuild not targeting right assembly?
We're setting up a new build server with CruiseControl.Net and MSBuild. After quite a bit of work, it's mostly working, except for one issue with one project (out of seven) that refuses to build under MSBuild. Here's the error:
error CS1061: 'System.Web.UI.HtmlControls.HtmlForm' does not contain a definition for 'Action' and no extension method 'Action' accepting a first argument of type 'System.Web.UI.HtmlControls.HtmlForm' could be found (are you missing a using directive or an assembly reference?)
All the code is still compiling fine on the old build server, and the new build server, while not an exact match, is configured similarly to the old.
The only cause that I can come up with for this error is that the System.Web.dll that's being used for compilation is v1.1, not v2.0, since the Action method was not in the v1.1 framework.
I'm not sure why this error, which we never saw on the old build server, is coming up on the new server. I'm not even sure exactly how to drill down to find the possible cause. I have tried running MSBuild with the /toolsversion:3.5 parameter set. I've run with the verbosity level set to the highest level, then compared the output to the old build server, but there wasn't anything that pointed to a cause (at least, nothing that was obvious to me).
There are several projects that are built before this one, and none of them are failing, even though they all are using more recent versions of the framework (3.5). This is the only project referencing System.Web.HtmlControls.
Has anyone had any similar issues? Ca开发者_C百科n anyone offer any help/hints on how best to try and get to the bottom of MSBuild issues?
Update The .sln and .csproj files are the same between the two servers. One thing I noticed in the .csproj file was the System.Web reference had no framework requirements:
<Reference Include="System.Web" />
I'm going to try adding a <RequiredTargetFramework>
to this reference to see if that makes a difference.
Update 2
Updating the reference in the csproj file to the following:
<Reference Include="System.Web">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
Did not seem to work. Next step, download the SDK so I can use ILDASM on System.Web to see if maybe something is wrong with my framework install (specifically, does the system.web.dll in my v2.0 framework have that method).
Update 3 The problem seems to be with the system.web.dll in the v2.0.5072 framework folder. It does not have the Action method on the HtmlForm class. I have no idea how something like that can happen, but I'm going to have to straighten out the frameworks on this server.
It's not MSBuild ... it's the 2.0 framework on the newer machine. The system.web.dll is just slightly different on the two machines:
Current machine: System.Web.dll version = 2.0.50727.3618 New machine: System.Web.dll version = 2.0.50727.1433
I think maybe someone here missed a SP on the newer machine. I'm surprised that there would be any kind of significant difference in the classes between these build numbers, though.
Under your project's references, check that the reference to System.Web
is to v2 version of the DLL, rather than v1.1.
精彩评论