Skip to content

Conversation

@jviau
Copy link
Contributor

@jviau jviau commented Nov 4, 2025

Issue describing the changes in this PR

Part of #3133

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)

Additional 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.json after restore has finished, scanning all referenced runtime assemblies, and checking for the ExtensionInformationAttribute.

KNOWN GAP: there is a known gap with this approach with the current SDK: we cannot pickup ExtensionInformationAttribute from 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.

Copilot AI review requested due to automatic review settings November 4, 2025 23:35
Copy link

Copilot AI left a 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 ResolveExtensionPackages MSBuild 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.

@jviau jviau force-pushed the jviau/msbuild-sdk/collect-packages branch from 11ae921 to 2964c16 Compare November 5, 2025 17:34
@jviau jviau changed the title [MSBUILD SDK] Add target to resolve extension pacjages [MSBUILD SDK] Add target to resolve extension packages Nov 11, 2025
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
@jviau jviau force-pushed the jviau/msbuild-sdk/collect-packages branch from 3513e0e to a49001e Compare November 11, 2025 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants