I have an Azure Functions v3 (dotnet isolated) C# project that references Microsoft.Azure.Functions.Worker.Sdk version 1.0.4. When NCrunch tries to build this project it fails with the message: ..\..\..\..\..\..\program files (x86)\microsoft visual studio\2019\professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets (1150, 7): The target "NCrunchPrepareForBuild" does not exist in the project. If I remove the package reference the build succeeds.
Conditionally disabling the reference with <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.0.4" OutputItemType="Analyzer" Condition="'$(NCrunch)' != '1'" /> doesn't work. Oddly, if I change that to Condition="'$(NCrunch)' == '1'" it does work, which suggests that the $(NCrunch) property has not been set at this point in the build process.
The line referenced by the error message looks like this:
<Target
Name="PrepareForBuild"
DependsOnTargets="$(PrepareForBuildDependsOn)">
As suggested by arkiaconsulting and Clement:
Paths triggered only for the NCrunch build
To disable the targets loading, you can set the
ExcludeRestorePackageImportsproperty to true in your project referencing the Azure Function package like this:That way, the targets are not triggered, the files are not moved into the bin folders and NCrunch works fine.
You can refer to Azure function:build issue
If the above suggestions don't work then you can ask the same on NCrunch forum and also open an issue on GitHub: azure-functions-vs-build-sdk