dotnet restore on Azure Functions projects ignores local NuGet.config
Azure Functions project cannot be properly restored if there is no machine-level package source defined.
Steps to reproduce:
- edit
%appdata%\NuGet\NuGet.Configand remove all package sources - if there are other global config files defined, remove the package sources from them
- create a new azure functions project and add a nuget config file, in the solution or project folder, with the correct package sources. You can use the default one that references nuget.org
- run
dotnet restore(it has to bedotnet restoresincenuget restoreworks)
Actual behavior
The following errors are returned:
error NU1100: Unable to resolve 'Microsoft.NETCore.Targets (>= 3.0.0)' for 'net6.0'.
error NU1100: Unable to resolve 'Microsoft.NET.Sdk.Functions (>= 4.0.1)' for 'net6.0'.
Expected behavior
dotnet restore should consider the local nuget configuration file and use it.
Additional notes
As far as I can tell, the problem only appears when referencing:
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" OutputItemType="Analyzer" />
Workaround
Ensure that %appdata%\NuGet\NuGet.Config has a valid package source defined.
Thanks for reporting will check and update.
@fabiocav pls comment and validate.
Come on this has been almost 7 mos we need a solution to this. This breaks it so upgrading this on the CI is difficult -- please prioritize a fix for this issue.
We have also encountered this issue. Azure Functions generates a project called WorkerExtensions.csproj in a temp folder. When WorkerExtensions.csproj is built, packages are restored using global NuGet settings instead of project NuGet settings. WorkerExtensions.csproj should be built using the same NuGet settings as the Azure Functions project.
This is still causing us issues, randomly. Sometimes the build work, sometimes they don't :(
Appears to have started becoming a problem since we moved from .net 6 to .net 8
NET6 is end of life is in 6 days, so hopefully when these packages are updated away from .NET6 things may start to work again...
Hey there! Any news or new workarounds about this? I got some problem today with Azure Pipelines, follow my deps:
Current Version .NET: 6.x
Function App: ~4
Environment: Windows
Platform: 32 bit
Version: Isolated Worker
<PackageReference Include="JWT" Version="9.0.3" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.8.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.OpenApi" Version="1.3.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="System.Text.Json" Version="6.0.5" />