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

Notification

Icon
Error

NCrunch cannot build VS 'Analyzer with Code Fix' project in VS 2015 Update 3
iangriffiths
#1 Posted : Wednesday, July 6, 2016 5:52:15 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/6/2016(UTC)
Posts: 4
Location: United Kingdom

Thanks: 1 times
I've recently installed Update 3 of Visual Studio 2015 and also the .NET Compiler Platform SDK v1.3.0.60420 from https://visualstudiogallery.msdn.microsoft.com/2ddb7240-5249-4c8c-969e-5d05823bcb89 (which seems to be required to get the Analyzer and Code Fix templates).

If I create a brand new "Analyzer with Code Fix (NuGet+ VISX)" project, NCrunch is unable to build the analyzer project (which in turn stops the test project that the template also creates from building). The project's status in the NCrunch Tests window is 'Build failure' and it reports this error:

Quote:
NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/d...ng_project-build-issues
The system cannot find the path specified.
The command ""C:\Users\Ian\AppData\Local\NCrunch\14232\1\packages\NuGet.CommandLine.2.8.5\tools\NuGet.exe" pack Diagnostic.nuspec -NoPackageAnalysis -Version 1.0.6031.11810 -OutputDirectory ." exited with code 3.


I've seen this on both of the two machines I've tried it on. I'm running NCrunch 2.23.0.2

I was able to work around this by adding packages\NuGet.CommandLine\2.8.5\**.* in the solution's Additional Files To Include, but I'm not sure this should be necessary - the relevant file seems to be used from an AfterBuild target:

Code:
  <Target Name="AfterBuild">
    <GetAssemblyIdentity AssemblyFiles="$(OutDir)\$(AssemblyName).dll">
      <Output TaskParameter="Assemblies" ItemName="AnalyzerAssemblyInfo" />
    </GetAssemblyIdentity>
    <Exec Command="&quot;$(SolutionDir)packages\NuGet.CommandLine.2.8.5\tools\NuGet.exe&quot; pack Diagnostic.nuspec -NoPackageAnalysis -Version %(AnalyzerAssemblyInfo.Version) -OutputDirectory ."
          WorkingDirectory="$(OutDir)" LogStandardErrorAsError="true" ConsoleToMSBuild="true">
      <Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" />
    </Exec>
  </Target>


In my NCrunch configuration for the project, Run post-build events is disabled. So why is it even attempting to run this step? I'm fairly sure this isn't something I'd actually want as part of NCrunch's build. (I think it's there to ensure that any NuGet packaging problems get reported as a build error, which you want when building the project normally, but I think it's just going to slow things down unnecessarily for NCrunch.)
Remco
#2 Posted : Wednesday, July 6, 2016 6:13:48 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

NCrunch automatically disables pre and post build events that are declared using the PreBuildEvent and PostBuildEvent MSBuild properties. Note that this is distinctly different from BeforeBuild and AfterBuild targets (which are custom coded MSBuild hooks in the build system).

In this case, the dependency auto detection will have failed because the files are being referenced using a string inside an Exec block (so it's basically an indirect/implicit dependency). NCrunch has no way to reliably identify MSBuild dependencies that are derived at run time.

There are two ways to resolve this problem. The first way is to add the dependencies to your additional files to include (as you have done). This will allow the Exec command to work inside NCrunch's build as normal.

If you wish to avoid running this code entirely, I suggest adding a build condition to the AfterBuild target, for example:

<Target Name="AfterBuild" Condition="'$(NCrunch)' != '1'">
1 user thanked Remco for this useful post.
iangriffiths on 7/6/2016(UTC)
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.032 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download