Reputation: 115
I created an Azure Artifact Feed and configured nuget gallery as upstream, however when I try to install package Newtonsoft.Json.Bson it always fails with error: Install-Package : NU1101: Unable to find package Newtonsoft.Json.Bson. No packages exist with this id in source(s): MyFeed, Microsoft Visual Studio Offline Packages
, it's very confusing that some packages work fine but some not.
Upvotes: 4
Views: 4348
Reputation: 1589
You have to allow packages that have been fetched from a private repo to be fetched from a public repo.
See the documentation here
Here is a powershell snippet from the docs that will allow a package to be fetched from a public repo:
$env:PATVAR = "YOUR_PAT_GOES_HERE"
$token = [Convert]::ToBase64String(([Text.Encoding]::ASCII.GetBytes("username:$PatVar")))
$headers = @{
Authorization = "Basic $token"
}
$url =
"https://pkgs.dev.azure.com/{OrganizationName}/{ProjectName}/_apis/packaging/feeds/{FeedName}/{Protocol}/packages/{PackageName}/upstreaming?api-version=6.1-preview.1"
$body = '{"versionsFromExternalUpstreams": "AllowExternalVersions"}'
Invoke-RestMethod -Uri $url -Headers $headers -Body $body -Method Patch -ContentType "application/json"
Upvotes: 3
Reputation: 31003
In order for your feed to provide deterministic restore, it's important to ensure that your package feed configuration file (.npmrc_ or _nuget.config) references only your Azure Artifacts feed with upstream sources enabled. For NuGet, the <packageSources>
section should look like this:
<packageSources>
<clear />
<add key="FabrikamFiber" value="https://pkgs.dev.azure.com/fabrikam/_packaging/FabrikamFiber/nuget/v3/index.json" />
</packageSources>
The
<clear />
tag is required because NuGet composes several configuration files to determine the full set of options to use.<clear />
tells NuGet to ignore all other<packageSources>
defined in higher-level configuration files.
Upvotes: 0