StyleCop Task Problem - Could not load file or assembly 'Microsoft.StyleCop, Version=4.3.3.0

Jan 28, 2010 at 2:16 PM
Edited Jan 28, 2010 at 2:30 PM

I have Microsoft StyleCop 4.3.3.0 installed and it is the only version of the software I have installed on my build machine.  I am trying to use the StyleCop task from this most current version of the MBuild Extension Pack.  When I first installed 3.5.5.0, I was getting the same error, but it was saying "Version=4.3.2.1".  I found your additional download dll for those using Extension Pack 3.5.5.0 along with StyleCop 4.3.3.0.  I downloaded that and put the new files over top the ones from the 3.5.5.0 install.  I figured I would be all set, but I am getting the same error, but with "Version=4.3.3.0" as you can see below:

C:\_BuildMachine\Build Scripts\Shared\Broadway.Scripts.proj(90, 5): FileNotFoundException: Could not load file or assembly 'Microsoft.StyleCop, Version=4.3.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Please help...  I have spent the past 2 days trying to get this task to work in my build environment.  I have the most current release of StyleCop and ExtensionPack.  I tried everything that I know how to do, along with everything I could find on the Internet.

Here is my task from MSBuild, just in case you need that too.  Since it is getting to the point of looking for the Stylecop dll, I figure the problem is not in the task.

 

    <ItemGroup>
      <Sc Include="$(dirFileTest)\Added.txt" />
    </ItemGroup>
    <ReadLinesFromFile File="@(Sc)">
      <Output TaskParameter="Lines" ItemName="ItemsFromSc" />
    </ReadLinesFromFile>
    <Message Text="%(ItemsFromSc.Identity)" />
    <StyleCop TaskAction="Scan"
              SourceFiles="%(ItemsFromSc.Identity)"
              ShowOutput="true"
              ForceFullAnalysis="true"
              CacheResults="false"
              LogFile="$(dirFileTest)\StyleCop.txt"
              SettingsFile="C:\Program Files\MSBuild\Microsoft\StyleCop\v4.3\Settings.StyleCop" />

 

    <ItemGroup>

      <Sc Include="$(dirFileTest)\Added.txt" />

    </ItemGroup>

    <ReadLinesFromFile File="@(Sc)">

      <Output TaskParameter="Lines" ItemName="ItemsFromSc" />

    </ReadLinesFromFile>

 

    <Message Text="%(ItemsFromSc.Identity)" />

 

    <StyleCop TaskAction="Scan"

              SourceFiles="%(ItemsFromSc.Identity)"

              ShowOutput="true"

              ForceFullAnalysis="true"

              CacheResults="false"

              LogFile="$(dirFileTest)\StyleCop.txt"

              SettingsFile="C:\Program Files\MSBuild\Microsoft\StyleCop\v4.3\Settings.StyleCop" />

 

 

I just tried the task that someone else listed in one of the postings here and I got the same error.  Here is a link to the other task I tried (from the first response).

http://msbuildextensionpack.codeplex.com/Thread/View.aspx?ThreadId=37382

Coordinator
Jan 28, 2010 at 2:35 PM

you need to copy the extensionpack.stylecop assembly to C:\Program Files\MSBuild\Microsoft\StyleCop\v4.3

Jan 28, 2010 at 2:43 PM

Awesome!  Copying the file into that folder, then changing the path to the task dll to the same location worked!  Thank you!

Did I miss something in the documentation or on the site somewhere?  It would be nice if it was stated that you have to move the dll into your MSBuild\StyleCop\v4.3 folder and you need to link the ' using TaskName="StyleCop" ' line that dll, in that location.  I figured that I needed to overwrite the files in my ExtensionPack installation location.

Coordinator
Jan 28, 2010 at 2:55 PM

No sorry, I'll update the docs. I thought i had it in there. Teh copy is all you should need to do, then use the standard import

<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.tasks"/>

Feb 26, 2010 at 8:48 AM

I'm putting this task into TeamCity and it isn't great to have to install Stylecop on all the build servers, is there any way to not require fixed path references to the stylecop dlls?

 

Coordinator
Feb 26, 2010 at 11:25 AM

You could try GAC the stylecop assemblies. What is your concern with installing stylecop on the build servers?