Late yesterday afternoon, I updated my project source and was met with the following error when attempting to build the solution:

The target “RunCodeAnalysis” does not exist in the project.   

If you have encountered this error, you know the Error List provides little help as the error description isn’t accompanied by a filename, line number or additional help.  If you search the solution for “RunCodeAnalysis” you will get no results.  If you review the offending project’s properties via the IDE, you won’t find a reference either…unless, of course, you’re running Visual Studio Team System. In this case, a big ol’ Code Analysis tab will be staring you in the face.

image

Here’s the deal.  Developer Out-To-Get-Me runs Visual Studio Team System and takes advantage of the built-in code analysis tools such as FxCop.  Yours truly is running the mere professional edition and has been diligently running FxCop outside of Visual Studio.  Great. Developer-Out-To-Get-Me’s tool is better than my tool.  The problem is the Code Analysis project settings are stored in the .csproj file and are committed to version control.  I pull down the latest .csproj, compile and my version of Visual Studio barfs. 

<CodeAnalysisIgnoreGeneratedCode>true</CodeAnalysisIgnoreGeneratedCode>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Design...</CodeAnalysisRules>

I’m not sure there’s a good work around for this other than Developer Out-To-Get-Me refraining from committing their version of the project file.  It would be nice if varying versions of Visual Studio handled this more gracefully though. [Note, it seems to be handled okay for VS 2008 RTM but not VS 2008 SP1 but that's another story, I think.]

For now, I’ve manually purged the project file of the above XML block and the coding gods are smiling down on my again.  Next steps? Upgrade my own tools already.

5 Comments to “RunCodeAnalysis Does Not Exist”

  1. Chen says:

    Thanks a lot !!!

  2. Ryan says:

    Thanks this helped me out.

  3. Ben Griswold says:

    Chen and Ryan, I’m happy to help.

  4. Samuel De Rycke says:

    Thank you, solved me problem :)

  5. Steven Weiß says:

    Here’s the workaround:
    just rename the directory c:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\CodeAnalysis

    Then it should work ;-)

Leave a Reply

You can wrap your code with [ruby][/ruby] or [python][/python] blocks for syntax highlighting and you can use these traditional tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>