-
Notifications
You must be signed in to change notification settings - Fork 201
[MSBUILD SDK] Add target to resolve extension packages #3224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/msbuild-sdk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces extension package resolution functionality for the Azure Functions SDK. It adds the ability to scan project dependencies and automatically identify Azure Functions extension packages based on assembly attributes.
Key changes:
- New
ResolveExtensionPackagesMSBuild task that scans project assets to find extension packages - Assembly scanning infrastructure using Mono.Cecil to read extension metadata from assemblies
- Helper classes for working with lock files, task items, and MSBuild integration
- New MSBuild targets and properties files to integrate extension resolution into the build pipeline
Reviewed Changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Azure.Functions.Sdk/Tasks/Extensions/ResolveExtensionPackages.cs | New MSBuild task for resolving extension packages from project lock file |
| src/Azure.Functions.Sdk/ExtensionReference.cs | Utility to extract extension information from assemblies via custom attributes |
| src/Azure.Functions.Sdk/WebJobsReference.cs | Model representing WebJobs extension references |
| src/Azure.Functions.Sdk/FunctionsAssemblyScanner.cs | Scanner for analyzing assemblies and extracting extension metadata |
| src/Azure.Functions.Sdk/FunctionsAssemblyResolver.cs | Custom assembly resolver for Mono.Cecil with TPA support |
| src/Azure.Functions.Sdk/MonoExtensions.cs | Extension methods for Mono.Cecil type operations |
| src/Azure.Functions.Sdk/MSBuildNugetLogger.cs | Adapter to bridge NuGet logging to MSBuild logging |
| src/Azure.Functions.Sdk/LockFileExtensions.cs | Helper for working with NuGet lock files |
| src/Azure.Functions.Sdk/TaskItemExtensions.cs | Extension methods for MSBuild ITaskItem metadata |
| src/Azure.Functions.Sdk/ExceptionExtensions.cs | Helper to identify fatal exceptions |
| src/Azure.Functions.Sdk/Constants.cs | Constants for extension output folder |
| src/Azure.Functions.Sdk/Throw.cs | Removed namespace declaration (now defined via global using or file-scoped) |
| src/Azure.Functions.Sdk/Targets/Extensions/Azure.Functions.Sdk.Extensions.targets | MSBuild targets for extension package collection |
| src/Azure.Functions.Sdk/Targets/Extensions/Azure.Functions.Sdk.Extensions.props | MSBuild properties for extension package metadata |
| src/Azure.Functions.Sdk/Targets/Azure.Functions.Sdk.targets | Import of extension targets |
| src/Azure.Functions.Sdk/Targets/Azure.Functions.Sdk.props | Import of extension props |
| src/Azure.Functions.Sdk/Strings.resx | Added error message for missing project assets file |
| src/Azure.Functions.Sdk/Azure.Functions.Sdk.csproj | Added Mono.Cecil and System.IO.Abstractions package references |
| test/Azure.Functions.Sdk.Tests/TempDirectory.cs | Test utility for managing temporary directories |
| test/Azure.Functions.Sdk.Tests/TargetOutputs.cs | Helper for working with MSBuild target results |
| test/Azure.Functions.Sdk.Tests/MSBuildExtensions.cs | Extension methods for ProjectCreator with new helpers |
| test/Azure.Functions.Sdk.Tests/Tasks/Extensions/ResolveExtensionPackagesTests.cs | Unit tests for ResolveExtensionPackages task |
| test/Azure.Functions.Sdk.Tests/Integration/SdkEndToEndTests.Targets.CollectExtensionPackages.cs | Integration tests for CollectExtensionPackages target |
| test/Azure.Functions.Sdk.Tests/Integration/MSBuildSdkTestBase.cs | Refactored to use TempDirectory helper |
| test/Azure.Functions.Sdk.Tests/Assertions/TaskItemAssertions.cs | Assertion helpers for ITaskItem instances |
| test/Azure.Functions.Sdk.Tests/Assertions/BuildOutputAssertions.cs | Added null checks in assertion methods |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Azure.Functions.Sdk/Tasks/Extensions/ResolveExtensionPackages.cs
Outdated
Show resolved
Hide resolved
src/Azure.Functions.Sdk/Tasks/Extensions/ResolveExtensionPackages.cs
Outdated
Show resolved
Hide resolved
src/Azure.Functions.Sdk/Tasks/Extensions/ResolveExtensionPackages.cs
Outdated
Show resolved
Hide resolved
11ae921 to
2964c16
Compare
Add integration and unit tests Use ProjectAssetsFile property Fix public API exposing msbuild types Handle edge case for ResolveExtensionPackages update assertions package Update src/Azure.Functions.Sdk/ExtensionReference.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update src/Azure.Functions.Sdk/Tasks/Extensions/ResolveExtensionPackages.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update src/Azure.Functions.Sdk/Tasks/Extensions/ResolveExtensionPackages.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Address copilot review Remove unneeded suppressions
3513e0e to
a49001e
Compare
Issue describing the changes in this PR
Part of #3133
Pull request checklist
release_notes.mdAdditional information
This PR adds a target and task which scan for and collect all WebJobs extension references from the currently referenced nuget packages. This is done by directly loading the
project.assets.jsonafter restore has finished, scanning all referenced runtime assemblies, and checking for theExtensionInformationAttribute.KNOWN GAP: there is a known gap with this approach with the current SDK: we cannot pickup
ExtensionInformationAttributefrom p2p references, as we are hooking into restore. Any p2p reference will not be built yet, and thus we cannot discover attributes from them. The only potential solution to this is to support a way to supply extension references via MSBuild. Which we are unsure about at this time.