Azure / Azure-Functions

1.11k stars 194 forks source link

dotnet restore on Azure Functions projects ignores local NuGet.config #2445

Open costin-zaharia-sonarsource opened 7 months ago

costin-zaharia-sonarsource commented 7 months ago

Azure Functions project cannot be properly restored if there is no machine-level package source defined.

Steps to reproduce:

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.

bhagyshricompany commented 7 months ago

Thanks for reporting will check and update.

bhagyshricompany commented 7 months ago

@fabiocav pls comment and validate.

mxrss2 commented 1 month ago

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.

henrylyons commented 1 month ago

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.