0
votes

I have an old MVC2 project, which I am trying to move from an old cruise control CI server to our current TeamCity CI Server.

I'm getting screeds of build errors of the form:

Models\State\ControllerStates.cs(3, 18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

I get a lot of warnings of the form:

[14:57:16]ResolveAssemblyReference [14:57:16]C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360, 9): warning MSB3257: The primary reference "System.Runtime.Serialization" could not be resolved because it has a higher version "4.0.0.0" than exists in the current target framework. The version found in the current target framework is "3.0.0.0".

The TeamCity build step is using the Visual Studio (.sln) runner vs2012 Here's part of the csc command logged by team city.

/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Configuration.dll et al.

I found a VS2012 installation it works correctly, and the similar parameter looks like this:

/reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll et. al.

So it's using the wrong version of some assemblies, and I'm not sure why.

1
How are your build steps set up? Also try building it locally using the same version of msbuild that your TeamCity setup to use in the build step and that might at least help you replicate the build errors locally and test fixes without having to go to the TeamCity server. - Nanhydrin
@Nanhydrin I've added the build step info into the question, now to try your next suggestion. :-) - Myster
It very much looks like TeamCity is overriding whatever version of .NET it should be using (3.5 presumably) with 4.0. If you go into TeamCity, edit the build configuration, and look at the build step that's running the compile, there are two fields that are relevant, MSBuild version and MSBuild ToolsVersion. What are they set to? My suspicion is that your ToolsVersion is set to 4.0 but should be 3.5 or 2.0. - Nanhydrin
@Nanhydrin, I have no idea what was wrong, but I've set up a new bulid agent and that works correctly, so I don't think TC or my project are to blame, but rather something fishy with the setup on the build agent. - Myster
@Nanhydrin thanks for your help, it got me looking in the right place. - Myster

1 Answers

0
votes

I have no idea what was wrong, but I've set up a new build agent and that works correctly, so I don't think TC or my project are to blame, but rather something fishy with the setup on the build agent.

This is not a great answer, but if you have a similar problem you may want to cut to the chase and re-build or add a new build agent.