3
votes

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.

enter image description here

2
Where did you get the error, from local build or from Azure DevOps Pipeline? How did you download packages from the feed, with a task in pipeline or from a command?Cece Dong - MSFT

2 Answers

1
votes

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"
0
votes

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.