Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

NCrunch does not recursively copy msbuild target imports
alexpeck
#1 Posted : Friday, July 13, 2012 2:53:47 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/13/2012(UTC)
Posts: 1
Location: Denmark

In my test project, I import an msbuild targets file which defines stylecop rules. This style cop rule targets file imports the standard stylecop targets file, which is checked in to our source code repo (so everyone always has the same stylecop version). I use absolute paths to reference files, where the paths are rooted at the environment variable %inetroot%. I open VS with this environment variable set.

I have warnings as errors set to true in each project, which through the target files I use enables stylecop warnings as errors as well. This works in Visual Studio and with MSBuild at the command line. However, NCrunch builds fail with stylecop errors. The errors I am getting are for things like including documentation on private fields, which are not part of the stylecop rule set I am using.

So, in my test project, I have this (much of it omitted for brevity):

Code:

<Project …>
   …
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    …
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>
  …
   <Import Project="$(inetroot)\build\msbuild\StyleCop.Targets" />
   …
</Project>


And in the file StyleCop.Targets I have this:

Code:

<Project …>
   …
  <!-- If the project has the TreatWarningsAsErrors flag set, then treat StyleCop violations as errors as well. -->
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <SourceAnalysisTreatErrorsAsWarnings Condition="'$(TreatWarningsAsErrors)' == 'true'">false</SourceAnalysisTreatErrorsAsWarnings>
  </PropertyGroup>

  <Import Project="$(INETROOT)\build\tools\StyleCop\v4.5\StyleCop.Targets" />
   …
</Project>


I used the Advanced menu -> Browse to workspace last built for selected project. I can see that NCrunch has replicated the directory structure of my project and the target files it references, so that I have these files:

NCrunch\31804\19\build\msbuild\StyleCop.Targets
NCrunch\31804\19\test\AssemblyName\AssemblyName.csproj

But there is no NCrunch\31804\19\build\tools\StyleCop\v4.5\StyleCop.Targets file in the workspace. So it seems like NCrunch only copied the msbuild imports 1 level deep. Is this a known limitation, or is there another reason that this file would not be copied to the NCrunch workspace?

If I use msbuild at the command line to build the project in the NCrunch workspace (with %inetroot% set the same as it is when I run VS), it fails with all the stylecop errors, just like it does from within NCrunch. So, it seems like the problem stems from the workspace.

I can workaround this by putting a condition on the treat warnings as errors tag so that it is not set when NCrunch = 1, but I would prefer not to have to do this for all of the project files because there are many of them.

I am using VS 2010 and NCrunch 1.40.0.24b.

Remco
#2 Posted : Saturday, July 14, 2012 9:52:02 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi, thanks for posting!

Right now NCrunch has a known issue with stylecop settings files that are placed adjacent to a solution (.sln) file. If you're making use of solution-wide stylecop settings, this may be something to watch out for as NCrunch likely won't have copied this settings file to the workspace. The workaround for this issue is to ensure the solution-level stylecop settings file is included in your NCrunch solution-level 'Additional files to include' configuration setting.

Because you're using absolute paths to reference your tools (via the environment variable), the workspacing itself shouldn't in any way impact the referencing of these files as they'll be loaded from the same place as normal anyway. I think that most likely the issue is related to stylecop being unable to properly find your settings as opposed to finding the stylecop build tasks (as it seems these are actually running inside the NCrunch build).

I hope that this helps!

Cheers,

Remco
Remco
#3 Posted : Monday, August 13, 2012 3:55:45 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
For anyone interested, NCrunch 1.41b has just been released including a fix for the above described issue (unable to find stylecop settings files at solution level).
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.037 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download