Build/Test Issues

NCrunch cannot build VS 'Analyzer with Code Fix' project in VS 2015 Update 3

Started by iangriffiths on 4,233 views

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:

NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/documentation/troubleshooting_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:

  <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.)
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'">

Post a reply

Log in to reply.