Ncrunch is unable to build an Azure Function (net 8 isolated) when it references Microsoft.Azure.Functions.Worker.Sdk with version 1.17.3 or 1.17.4. Here is the error:
C:\Program Files\dotnet\sdk\8.0.400-preview.0.24324.5\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets: Assets file 'D:\NCrunchWorkspace\26516\20\xxx\src\AzureFunction\obj\project.assets.json' doesn't have a target for 'net6.0'. Ensure that restore has run and that you have included 'net6.0' in the TargetFrameworks for your project.
It works fine when downgrading the package Microsoft.Azure.Functions.Worker.Sdk to 1.17.2
Thanks for sharing this. Do you have a sample project you can share with me that can produce this issue? You can submit this to me in ZIP form through the NCrunch support contact form.
Thanks for sending through the sample project. I've reproduced this problem in the way you've described it.
The issue is caused by a nested build that happens inside the build of this project. Normally, we shut this off as it isn't required for NCrunch and just gives us trouble. Unfortunately, there is no clearly designed 'off' switch for the build steps involved, so we need to reach into the internals of the build system and shut down the targets specifically.
In v1.17.2, MS changed the build system significantly and the targets we are shutting down have changed, so to fix this I'll need to get you a new build. I'll let you know as soon as we have one available.
As I side note, I also tested this NCrunch version with the version 1.17.0 of the Microsoft.Azure.Functions.Worker.Sdk package, and I got the following build error:
..\..\..\..\program files\microsoft visual studio\2022\preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets (5321, 5): Could not copy the file "D:\NCrunchWorkspace\46204\7\FunctionApp1\obj\Debug\net8.0\functions.metadata" because it was not found.
..\..\..\..\program files\microsoft visual studio\2022\preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets (5321, 5): Could not copy the file "D:\NCrunchWorkspace\46204\7\FunctionApp1\obj\Debug\net8.0\worker.config.json" because it was not found.
..\..\..\..\program files\microsoft visual studio\2022\preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets (5321, 5): Could not copy the file "D:\NCrunchWorkspace\46204\7\FunctionApp1\obj\Debug\net8.0\extensions.json" because it was not found.
That could be an issue for those of us who cannot easily upgrade their packages.
As I side note, I also tested this NCrunch version with the version 1.17.0 of the Microsoft.Azure.Functions.Worker.Sdk package, and I got the following build error:
..\..\..\..\program files\microsoft visual studio\2022\preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets (5321, 5): Could not copy the file "D:\NCrunchWorkspace\46204\7\FunctionApp1\obj\Debug\net8.0\functions.metadata" because it was not found.
..\..\..\..\program files\microsoft visual studio\2022\preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets (5321, 5): Could not copy the file "D:\NCrunchWorkspace\46204\7\FunctionApp1\obj\Debug\net8.0\worker.config.json" because it was not found.
..\..\..\..\program files\microsoft visual studio\2022\preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets (5321, 5): Could not copy the file "D:\NCrunchWorkspace\46204\7\FunctionApp1\obj\Debug\net8.0\extensions.json" because it was not found.
That could be an issue for those of us who cannot easily upgrade their packages.
Good catch. I'll look into this. Thanks for letting me know.