Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
| Item | Value |
|---|---|
| Rule ID | AZFW0108 |
| Category | Sdk |
| Severity | Warning |
Cause
This SDK warning occurs when a project using Azure.Functions.Sdk is built without the extension bundle post-restore hook being invoked. The post-restore hook is run when the function project is directly restored. Restoring a solution file or a traversal project will not invoke the post-restore hook.
When the post-restore hook is not successfully run, the functions SDK will try to run the hook before build. However, since the post-restore hook performs another nuget restore itself, running as part of build (and not restore) may cause issues depending on the build environment. It is strongly recommended to follow the steps here to ensure the post-restore hook runs as part of dotnet restore.
Rule Description
The extension bundle is a payload that is deployed alongside a function application, which contains the extensions needed by the functions runtime to enable the function app's triggers and bindings.
How to Fix
Option 1: Restore function csproj directly
The post-restore hook will be run when the functions project is restored directly.
dotnet restore MyFunctionApp.csproj
Option 2: Add post-restore hook for restore target.
The Restore target only runs on the exact project that dotnet restore is targeted against — it does not propagate to referenced projects. This means the function app's post-restore hook (which generates the extension project) is never invoked when restoring a solution or traversal project.
To fix this, add the following target so that it is included in the project being restored. This target recursively walks ProjectReference items, eventually reaching the function app where GenerateFunctionsExtensionProject is defined.
<Target Name="_RecursiveGenerateFunctionsExtensionProject" AfterTargets="Restore">
<MSBuild Projects="@(ProjectReference)" Targets="_RecursiveGenerateFunctionsExtensionProject"
SkipNonexistentProjects="true" SkipNonexistentTargets="true" />
<MSBuild Projects="@(ProjectReference)" Targets="GenerateFunctionsExtensionProject"
SkipNonexistentProjects="true" SkipNonexistentTargets="true" />
</Target>
Where to place this target depends on how you restore:
- Solution files (
dotnet restore MySolution.sln): Add the target to aDirectory.Solution.targetsfile next to your solution file. - Single traversal project (
dotnet restore dirs.proj): Add the target toDirectory.Build.targets, assumingdirs.projimports it (the default). If you have a chain of traversal projects (e.g.,dirs.proj→src/dirs.proj→MyFunctionApp.csproj), everydirs.projin the chain must have this target — either directly or through its ownDirectory.Build.targets.
When to Suppress Warnings
Suppression is not recommended. Follow the steps here to fix the warning.