Build/Test Issues

The target "NCrunchPrepareForBuild" does not exist in the project (again)

Started by Careidas77 on 2,666 views

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:

<PropertyGroup Condition="'$(NCrunch)' == '1'">
<ExcludeRestorePackageImports>true</ExcludeRestorePackageImports>
</PropertyGroup>

However, this was not a problem until recently with this project in question. I did update (and pay for yet another license) NCrunch, but to no avail.

Any insights?

Edited

Hi, thanks for sharing this issue.

We do now have properly considered support for Azure function projects, which we didn't have back when this was posted 3 years ago.

As such, this is supposed to work without needing to have the workaround in place.

Are you able to build us a sample project that can produce this issue? You can submit small code packages to us through the support contact form.
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.

Thank you beforehand!

Edited

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.

Edited

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.

    Edited

    Thanks for these extra details.

    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.

    Could you upload a ZIP of the failing project?
    OK, uploaded the requested zip just now.
    Thanks for sharing the test project. I've now managed to reproduce this problem and I've implemented a fix.

    Would you be interested in trying the build below?

    NCrunch_Console_4.15.0.2.msi
    NCrunch_Console_4.15.0.2.zip
    NCrunch_GridNodeServer_4.15.0.2.msi
    NCrunch_GridNodeServer_4.15.0.2.zip
    NCrunch_LicenseServer_4.15.0.2.zip
    NCrunch_VS2010_4.15.0.2.msi
    NCrunch_VS2010_4.15.0.2.zip
    NCrunch_VS2012_4.15.0.2.msi
    NCrunch_VS2012_4.15.0.2.zip
    NCrunch_VS2013_4.15.0.2.msi
    NCrunch_VS2013_4.15.0.2.zip
    NCrunch_VS2015_4.15.0.2.msi
    NCrunch_VS2015_4.15.0.2.msi.7z
    NCrunch_VS2015_4.15.0.2.zip
    NCrunch_VS2017_4.15.0.2.msi
    NCrunch_VS2017_4.15.0.2.msi.7z
    NCrunch_VS2017_4.15.0.2.zip
    NCrunch_VS2019_4.15.0.2.msi
    NCrunch_VS2019_4.15.0.2.msi.7z
    NCrunch_VS2019_4.15.0.2.zip
    NCrunch_VS2022_4.15.0.2.msi
    NCrunch_VS2022_4.15.0.2.msi.7z
    NCrunch_VS2022_4.15.0.2.zip

    I'll take it for a spin and report back :)
    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!

    Post a reply

    Log in to reply.