I have a private nuget feed that I use to host some packages for my app, I’m using Azure Pipelines for builds and I have noticed a restore issue with PackageSourceMappings
, I believe I have followed the guidance accordingly.
I have installed the tool and generated a source map using packagesourcemapper generate nuget.config --remove-unused-sources
Following the guidance in the docs I have verified this works locally by clearing local nuget cache, restarting VS & running a clean restore.
When I run the restore on the build agent:
- task: NuGetToolInstaller@1
displayName: Use latest NuGet
inputs:
checkLatest: true
- task: UseDotNet@2
displayName: 'Use global.json SDK'
inputs:
packageType: 'sdk'
useGlobalJson: true
- task: DotNetCoreCLI@2
displayName: dotnet restore
inputs:
command: 'restore'
projects: ${{ parameters.solution }}
feedsToUse: 'config'
nugetConfigPath: 'NuGet.config'
The restore will fail and all the failed packages listed are from my private feed:
/Users/runner/work/1/s/tests/MyApp.UnitTests/MyApp.UnitTests.csproj : error NU1100: Unable to resolve 'Acme.MyPackage (>= X.X.X-pre)' for 'net8.0'. PackageSourceMapping is enabled, the following source(s) were not considered: /Users/runner/hostedtoolcache/dotnet/library-packs, feed-MyApp, nuget.org. [/Users/runner/work/1/s/MyApp.sln]
My private feed is listed in my Nuget.config
:
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Acme" value="https://pkgs.dev.azure.com/Acme/MyApp/_packaging/MyFeed/nuget/v3/index.json" />
</packageSources>
And my source map looks like this:
<packageSourceMapping>
<clear />
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
<packageSource key="Acme">
<package pattern="Acme.*" />
</packageSource>
</packageSourceMapping>
<disabledPackageSources>
<clear />
</disabledPackageSources>
Reading the documentation I can’t see what is going wrong, I don’t understand why nuget is completely ignoring my private feed when I have this map. I have tried the same config but with all packages explicitly named (using PackageSourceMapper
to generate)
What is throwing me is that this operation clearly knows about my private source since it lists it, why is it ignoring it for my private packages?