Azure / azure-functions-dotnet-worker

Azure Functions out-of-process .NET language worker
MIT License
412 stars 176 forks source link

Regression in `Microsoft.Azure.Functions.Worker.Sdk` version `1.17.4`/`1.17.3` of solution builds using no-incremental #2601

Open skystedt opened 1 month ago

skystedt commented 1 month ago

Description

Microsoft.Azure.Functions.Worker.Sdk version 1.17.4/1.17.3 breaks solution builds using no-incremental.

This is a regression of: https://github.com/Azure/azure-functions-dotnet-worker/issues/2284

Description

Building a solution with flag --no-incremental while having a test project referencing a functions project will result in the build failing with MSB3030: Could not copy the file "obj\Debug\net8.0\extensions.json" because it was not found.

Steps to reproduce

  1. Create a solution with a new functions project
    • Functions worker: .NET 8.0 Isolated
    • Function: Empty
  2. Add a xunit test project
  3. Add a project reference in the test project targeting the functions project
  4. Use Microsoft.Azure.Functions.Worker.Sdk 1.17.0
  5. build with: dotnet build --no-incremental solution.sln
jviau commented 1 month ago

It appears that --no-incremental (which invokes a rebuild) is asking for the function projects output files from the test project before it is fully built. This only happens when invoking dotnet build --no-incremental on the solution file, and not on the test csproj nor function csproj.

This leads me to believe this is a msbuild or dotnet SDK issue. I'll reach out to those teams and see if they know if any issue like this.

pregress commented 1 month ago

The issue also occurs when you do a clean publish, eg: our build server always starts from a clean checkout and we are able to reproduce it 100% of the time.

Can this be solved? And please with some test cases so it's never introduced again. This blocks our dependency upgrades.

trimmed down version of our build process:

  1. git clone
  2. dotnet publish -c Release

/usr/share/dotnet/sdk/8.0.101/Microsoft.Common.CurrentVersion.targets(5198,5): error MSB3030: Could not copy the file "/data/jenkins/workspace/REDACTED/obj/Release/net8.0/linux-x64/extensions.json" because it was not found. [/data/jenkins/workspace/REDACTED/src/REDACTED/REDACTED.csproj]

jviau commented 1 month ago

@pregress what is the target of your dotnet publish command? Is it a solution file, dirs.proj, csproj?

jviau commented 1 month ago

The issue appears to be with MSBuild parallelization. We are still investigating, but a potential workaround is to provide max cpu count of 1: dotnet build --no-incremental -m:1

pregress commented 1 month ago

@pregress what is the target of your dotnet publish command? Is it a solution file, dirs.proj, csproj?

Its a *.sln file

ChristopherL-STCU commented 1 month ago

Hitting this when running GitHub CodeQL on our solutions after upgrading to 1.17.3 or 1.17.4, since the CodeQL autobuild uses --no-incremental

pregress commented 4 weeks ago

Is there any real solution in the making ?

skotl commented 1 week ago

Same issue here, confirming that it is only on a clean/re build. This will cause problems in our CICD pipeline... :(