Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
"workloadVersion": "11.0.100-rc.2.26509.2",
"rollForward": "disable",
"allowPrerelease": false
},
"msbuild-sdks": {
"Azure.Functions.Sdk": "1.0.1"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit annoying that we have to include this in the global.json file, for a single sample project, but there doesn't seem to be a way around that.

<Project Sdk="Azure.Functions.Sdk"> creates an extension project as an intermediate artefact of the build process, which has no version... Without this in global.json NuGet fails with MSB4236. Because it's done via an SDK reference, there's no way to do this as a build property :-(

msbuild-sdks in global.json is where the resolver looks when a project gives no version, so pinning it here covers both the sample project and the intermediate extension project.

There's a suggestion to fix this upstream:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, but fair.
I've added a comment, maybe we just mention this on the code as well.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Covered by the comment now at the top of the sample project (db0e2b9), which is where someone copying the sample will look. global.json itself stays comment-free.

🤖 Addressed by Claude Code

}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Azure.Functions.Sdk">

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation for reviewers

Microsoft.NET.Sdk.Web is Microsoft.NET.Sdk plus ASP.NET defaults. Azure.Functions.Sdk works the same way. Its Sdk.props and Sdk.targets start by importing Microsoft.NET.Sdk.Worker, which builds on Microsoft.NET.Sdk:

Azure.Functions.Sdk → Microsoft.NET.Sdk.Worker → Microsoft.NET.Sdk

l
So everything we had before is still here, with a Functions layer on top:

  • OutputType and AzureFunctionsVersion are defaults now, set by the Worker SDK and the Functions SDK. That's why these have been deleted from the project.
  • It adds the Functions build steps: generating function metadata, writing worker.config.json and extensions.json, wiring dotnet run to start the Functions host, and publishing to Azure.

Package reference vs SDK

The old setup did roughly the same work, but delivered it as an ordinary package, Microsoft.Azure.Functions.Worker.Sdk:

PackageReference (old) Sdk attribute (new)
When its logic loads After restore. NuGet generates obj/*.nuget.g.props/.targets, and the next evaluation imports the package's build/ files from there Before anything else, when MSBuild first evaluates the project
Can it change restore itself? No. Restore has already happened by the time it loads Yes. It hooks Restore to generate and restore azure_functions.g.csproj
Can it supply defaults you override? Not cleanly. Its .props come in through NuGet's import, so you had to set properties yourself Yes. Sdk.props runs before your body, the same way Microsoft.NET.Sdk does
Versioning Ordinary NuGet resolution Attribute or global.json, and never pulled in transitively

Comment thread
jamescrosswell marked this conversation as resolved.
<!-- This repository pins the Azure.Functions.Sdk version under "msbuild-sdks" in its root global.json.
If you copy this project, add that entry to your own global.json, or the build fails with MSB4236. -->
<PropertyGroup>
<!-- Stays on net10.0: the Azure Functions Worker SDK does not support .NET 11 yet -
both 2.0.7 and the current 2.1.0 fail with "Invalid combination of TargetFramework
and AzureFunctionsVersion is set." Bump this once Functions supports .NET 11. -->
<TargetFramework>net10.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<TargetFramework>net11.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.51.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.52.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.3.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.7" />
<PackageReference Include="OpenTelemetry" Version="1.18.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.18.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.18.0" />
Expand Down
Loading