3
votes

I'm using VS2010 RC while targeting .NET 3.5. I can run code analysis via Visual Studio without a problem. However, when I try to run code analysis on our CI server it isn't getting executed. When I attempt to build using msbuild 4.0 I get the following exception:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(129,9): error MSB4018: The "CodeAnalysis" task failed unexpectedly.

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(129,9): error MSB4018: System.TypeLoadException: Could not load type 'System.Runtime.Versioning.TargetFrameworkAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Like I said, it works fine when I run it through VS.

1
As it turns out the build machine is still running .net 4 beta 2 instead of rc (which is what the dlls were built with). I'm going to try and upgrade and see if that fixes it.devlife
I spent a bunch of time on this today and there are several things that need to happen. The first is that you have to pass in /p:FxCopDir="path to FxCop directory". This directory contains all FxCop files including the exe and required dlls used during code analysis. When VS is installed everything works fine due to the installation creating registry entries. To get around this you have to modify C:\Program Files(x86)\MSBuild\Microsoft\VisualStudio\v10\CodeAnalysis\Microsoft.CodeAnalysis.Targets and remove the dependencies on the registry.devlife

1 Answers

0
votes

You will have tough times to set this up...

I would install VS2010 on the build server. Problem solved.

Note:
The Build server should be a replication of your developer environment (not production environment)