After updating Nuget packages in an Azure Function v.4 project, dotnet 6, NCrunch suddenly started reporting build failures:
..\..\..\..\..\program files\microsoft visual studio\2022\professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets (1154, 7): The target "NCrunchPrepareForBuild" does not exist in the project.
Seems to be the same issue as in topic https://forum.ncrunch.net/yaf_postst2767_Azure-Function---build-issue.aspx before, and the suggested workaround still works:
I will give it a try, and get back to you, but I'm not confident I will be able to reproduce the error. In the meanwhile, is there any information from the current project, configuration, target-file, whatnot that I could provide that would be of use for you in investigating the issue further?
I mean, everything used to be OK, and then suddenly one day, it just wasn't any more.
Careidas77 wrote:I will give it a try, and get back to you, but I'm not confident I will be able to reproduce the error. In the meanwhile, is there any information from the current project, configuration, target-file, whatnot that I could provide that would be of use for you in investigating the issue further?
Something that may be helpful is if you can submit a bug report via the NCrunch menu after the failure appears.
Though I don't think the bug report will give us enough info to reproduce the issue, I will take a look through it to see if anything stands out.
Sorry for the delay in response. I've now realized that the error is reproducable:
[list=1]
Create a blank solution (Visual Studio 2022).
Create a default Azure Function project from the VS template. Make sure that it's:
[list=a]
Dotnet 6
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" (in local.settings.json).
Enable NCrunch - note that NCrunch can build just fine.
Update Nuget packages to latest version. At the time of writing, it's:
[list=a]
Microsoft.Azure.Functions.Worker -> 1.10.0
Microsoft.Azure.Functions.Worker.Extentions.Timer -> 4.1.0 (if you chose a time-trigger function from the template when creating the AF project)
Microsoft.Azure.Functions.Worker.Sdk -> 1.7.0
Note that NCrunch upon the next build attempt fails with the error in question:
[...]\program files\microsoft visual studio\2022\professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets (1154, 7): The target "NCrunchPrepareForBuild" does not exist in the project.
I can send you a project copy if you like, but it should be easy enough for you to try it yourself, I guess? I also filed a bug report through the NCrunch interface as you suggested, after the error occurs, containing the same information as above.
Please let me know if I can do anything more to help.
I've tried to follow your instructions but ended up with something very different. There are a range of options available under the VS Azure Function template and I'm not sure which ones you're using.
My problem is gone, so I conclude it's "mission accomplished" :) The test project I sent you, as well as the original project in which I first encountered the issue in question: NCrunch now runs fine in both projects again, and I no longer need the "old fix" in place to make it so. Thank you!