Azure / azure-functions-dotnet-worker

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

Unable to `publish` a NET8 Functions App with ReadyToRun on the command line #2212

Closed MatthewSteeples closed 9 months ago

MatthewSteeples commented 9 months ago

Please see https://github.com/MatthewSteeples/ReadyToRun8/actions/runs/7508999929/job/20445457605 for repro

From what I can work out, the SDK generates a csproj file to do something with the Extensions that are referenced. This csproj (generated in ExtensionsCsprojGenerator) is a NET6 project. If you set ReadyToRun as a command line parameter it's not able to build this project, presumably because everything else that it's building is NET8.

There's a workaround to set the ReadyToRun as part of the csproj rather than pass it in as command line, but I don't know what consequences that has (because it means that whatever the Extensions csproj output is used for won't have R2R enabled on it).

MatthewSteeples commented 9 months ago

Related Developer Community Feedback

jviau commented 9 months ago

@MatthewSteeples what property are you setting in your csproj exactly? Is it ReadyToRun or PublishReadyToRun? The issue when using the command line param is it is a global property which propagates to the inner build. This PR included changes to suppress these known problematic global props from the inner build. Wondering if this is already solved or if a new prop will need to be added.

MatthewSteeples commented 9 months ago

@jviau Thanks for the reply. At this point my repro only sets it via the command line. Did you mean to link to a PR?

The reason that I've raised this is because the first two things that I tried both resulted in failed builds:

  1. Setting via command line - build fails
  2. Setting via environment variable in the build - build fails
  3. Setting via a property in the csproj - build succeeds

My concern with using option 3 is that while my projects are compiled as ReadyToRun, this extensions project is (presumably) not compiled with that setting. I don't know whether that's an issue or not though (as I'm not sure what this project does).

jviau commented 9 months ago

@MatthewSteeples yeah I understand the 3 scenarios: 1 & 2 are 'global properties' which propagate to the inner build. The functions SDK needs to suppress these from propagating. I just want to know the exact property you are setting in your csproj to verify what I need to suppress.

MatthewSteeples commented 9 months ago

The property as it appears in the csproj file is PublishReadyToRun

jviau commented 9 months ago

@MatthewSteeples great thank you. This is addressed by #1946 and will be in the next SDK release (aiming for Monday 1/19).

Specifically, PublishReadyToRun is part of _FunctionsExtensionRemoveProps, which are the props we will suppress on the inner build. Passing this in via env var or cmdline will no longer propagate and fail that build.

jviau commented 9 months ago

Fix released: https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk/1.17.0-preview1