Azure pipeline and DotNet core project: Unable to load the service index for source api.nuget.org - nuget

I was given the task to create a pipeline on our Windows Self Hosted agent to build a DotNet Core project located on GitHub.
I have a pipeline that does that already and works well but using it with the second project, it fails with this message:
Determining projects to restore...
C:\Program Files\dotnet\sdk\5.0.100\NuGet.targets(131,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [E:\Agent\_work\24\s\src\myProject\ myProject.csproj]
C:\Program Files\dotnet\sdk\5.0.100\NuGet.targets(131,5): error : Response status code does not indicate success: 302 (Moved Temporarily). [E:\Agent\_work\24\s\src\ myProject \ myProject.csproj]
##[error]Cmd.exe exited with code '1'.
We have firewall constraints so we have setup an artifact feed with upstream source to Nuget, I cannot tell for sure that the project that works tries to use it but at least, it does not fail. I am not the author of the projects and don’t use Nuget a lot, could I have some help finding what can be the issue? Would it be burried in the Nuget files of the project ?

Ok, I added a nuget.config file to the solution with path to my feed with the upstream:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="REPO" value="https://...com//_packaging/REPO/nuget/v3/index.json" />
</packageSources>
</configuration>
Used only this in my YAML:
- task: NuGetAuthenticate#0
displayName: 'Step 1: Authenticate with NuGet'

Related

Dot net test fails to restore EnterpriseLibrary.Logging Nuget in Azure DevOps

My AzureDevOps YML Looks like this:
- task: NuGetCommand#2
displayName: "Restore Test Solution"
inputs:
restoreSolution: $(Build.SourcesDirectory)\TestSln\*.sln
feedsToUse: config
nugetConfigPath: NuGet.config
allowPackageConflicts: true
includeNuGetOrg: true
- task: VSBuild#1
displayName: 'Build Test Solution'
inputs:
solution: $(Build.SourcesDirectory)\TestSln\*.sln
platform: x64
configuration: $(buildConfiguration)
clean: false
- task: DotNetCoreCLI#2
inputs:
command: 'test'
projects: |
$(Build.SourcesDirectory)\TestSln\**\*.csproj
arguments: '--filter TestCategory=RunOnServerBuild'
testRunTitle: 'TestSln Dot Net Test'
EnterpriseLibrary.Logging is Nuget Package hosted at nuget.org : https://www.nuget.org/packages/EnterpriseLibrary.Logging/
My Nuget.config that is used by azure dev ops does have the entry:
Restore Solution works fine:
2021-08-19T13:43:51.5771525Z WARNING: NU1603: EnterpriseLibrary.Logging 6.0.1304 depends on EnterpriseLibrary.Common (>= 6.0.0) but EnterpriseLibrary.Common 6.0.0 was not found. An approximate best match of EnterpriseLibrary.Common 6.0.1304 was resolved.
Build Works fine
During Dot Net Test run , when it's trying to restore .Net Core 3.1 Tests, it fails to restore the same library from nuget.org. it's trying to access other private feeds and fails with 401 unauthorized error
--- : hiding our domain for privacy purposes.
2021-08-19T13:45:58.9657200Z Restored D:\a\1\s\TestSln\SomeProject\SomeProject.csproj (in 609 ms).
2021-08-19T13:45:58.9658040Z Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/---/_packaging/428bdd6d-11e8-4a49-b9c9-63fec137af86/nuget/v3/flat2/enterpriselibrary.common/index.json'.
2021-08-19T13:45:58.9659145Z Response status code does not indicate success: 401 (Unauthorized).
2021-08-19T13:45:58.9660077Z Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/---/_packaging/428bdd6d-11e8-4a49-b9c9-63fec137af86/nuget/v3/flat2/enterpriselibrary.common/index.json'.
2021-08-19T13:45:58.9661165Z Response status code does not indicate success: 401 (Unauthorized).
2021-08-19T13:45:58.9662152Z C:\Program Files\dotnet\sdk\5.0.400\NuGet.targets(131,5): error : Failed to retrieve information about 'EnterpriseLibrary.Common' from remote source 'https://pkgs.dev.azure.com/---/_packaging/428bdd6d-11e8-4a49-b9c9-63fec137af86/nuget/v3/flat2/enterpriselibrary.common/index.json'. [D:\a\1\s\TestSln\SomeProject\SomeProject.csproj]
2021-08-19T13:45:58.9664792Z C:\Program Files\dotnet\sdk\5.0.400\NuGet.targets(131,5): error : Response status code does not indicate success: 401 (Unauthorized). [D:\a\1\s\TestSln\SomeProject\SomeProject.csproj]
2021-08-19T13:45:59.0226475Z ##[debug]Exit code 1 received from tool 'C:\Program Files\dotnet\dotnet.exe'
2021-08-19T13:45:59.0444559Z ##[debug]STDIO streams have closed for tool 'C:\Program Files\dotnet\dotnet.exe'
2021-08-19T13:45:59.0458377Z ##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
2021-08-19T13:45:59.0459252Z ##[debug]Processed: ##vso[task.issue type=error;]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
My Nuget.config that is used to restore solution contains link to nuget json
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />
<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="PrivateFeed1" value="https://pkgs.dev.azure.com/---/_packaging/PrivateFeed1/nuget/v3/index.json" />
<add key="PrivateFeed2" value="https://pkgs.dev.azure.com/---/_packaging/PrivateFeed2/nuget/v3/index.json" />
</packageSources>
</configuration>
even in debug mode, during dotnet test run ,it never shows it tried to access nuget.org to restore Enterpriselibrary.common
Please help, i have tried almost all the solutions but the test project still fails
thanks
Based on the warning and error message, the task is trying to restore the Enterpriselibrary.common 6.0.0.
You could refer to the nuget package in Nuget Org: EnterpriseLibrary.Common.
The supportted version is 6.0.1304 and 5.0.505.
Since it cannot find the 6.0.0 package in nuget.org, he will look for it in the private feed.
To solve this issue, you need to reference the version 6.0.1304 of EnterpriseLibrary.Common in your project.
Then the task will restore the package from nuget.org.

Azure build pipeline publishUrl nesting indefinitely

I just took over DevOps of a continuously integrated, continuously delivered Azure build pipeline, and all was going well… until today, when it's begun failing. I think the failures are due to an overlong file path on the web server.
Here is my error message:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.targets(3000,5): Error : Copying file bin\Release\Published\bin\Release\Published\bin\Release\Published\bin\Release\Published\bin\Release\Published\bin\Release\Published\bin\Release\Published\bootstrap\fonts\glyphicons-halflings-regular.eot to obj\Release\Package\PackageTmp\bin\Release\Published\bin\Release\Published\bin\Release\Published\bin\Release\Published\bin\Release\Published\bin\Release\Published\bin\Release\Published\bootstrap\fonts\glyphicons-halflings-regular.eot failed. Could not find a part of the path 'obj\Release\Package\PackageTmp\bin\Release\Published\bin\Release\Published\bin\Release\Published\bin\Release\Published\bin\Release\Published\bin\Release\Published\bin\Release\Published\bootstrap\fonts\glyphicons-halflings-regular.eot'.
Process 'msbuild.exe' exited with code '1'.
Evidently, it's just been dumping the project files into an ever-deeper rabbit hole of nested bin\Release\Published directories!
I checked what the resultant server path would be, and it amounts to 262 characters. My understanding is that this is longer than the Windows MAX_PATH value of 260, and I think that this is why my build is failing.
But I can't figure out how to stop that from happening.
My .pubxml file looks like this…
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>bin\Release\Published</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
</PropertyGroup>
</Project>
…but I end up with a bottomless pit of bin\Release\Published\bin\Release\Published\bin\Release\Published\bin…!!
I've updated the .pubxml file and checked it in successfully, but that seemed to have no effect. Here are my "Visual Studio build" pipeline details:
https://i.stack.imgur.com/jNO9U.png
$(BuildPlatform) = any cpu and $(BuildConfiguration) = release. I've tried supplying a different MSBuild argument for /p:PublishUrl, but that also didn't work.
How can I get this endless nesting to stop and my project to build!?
Thank you.

NU1101 erratically on MS Hosted windows agents

We have been erratically getting NU110 erros in our Azure DevOps pipeline for the MS hosted Windows (vs2017-win2016) based agents. This is been going on for a few days now
error NU1101: Unable to find package CommandLineParser. No packages exist with this id in source(s):
Is this some kind of a known issue and is there anything required from our end for addressing this?
Thanks
error NU1101: Unable to find package CommandLineParser. No packages exist with this id in source(s):
As far as I know, the CommandLineParser package exists in the nuget.org.
Here are two methods, you could refer to them.
When you use the feeds in Nuget Restore task. You could select the Use packages from NuGet.org.
When you use the Nuget.config file to restore the package, you could add the Nuget.org as the package source.
For example:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!-- remove any machine-wide sources with <clear/> -->
<clear />
<!-- get packages from the NuGet Gallery -->
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
Based on my test, the package could be found successfully.
Updates:
Now the "Dotnet Restore" task has some issues itself. It sometimes causes the Unable to find package issue. For more information, you could refer to this ticket.
Workaround:
You could change to use the Nuget Restore task. This task has the same function and it could work fine.

Build Fails with NU1101: Unable to find package Microsoft.Bot.Protocol.StreamingExtensions.NetCore

I am trying to set up a DevOps pipeline with Azure DevOps and BotFramework. My build is failing due to the package Microsoft.Bot.Protocol.StreamingExtensions.NetCore with the error NU1101: Unable to find package Microsoft.Bot.Protocol.StreamingExtensions.NetCore. No packages exist with this id in source(s): NuGetOrg
I tried to uninstall this package, but then I started getting the same error locally. When I tried to reinstall I couldn't find the package on NuGet which is probably why this error is occurring, so I had to revert to a previous commit to get a working version of my bot.
It would be expected for the package to be able to be installed when the project is being built on Azure DevOps. Any help with this is appreciated.
Build Fails with NU1101: Unable to find package Microsoft.Bot.Protocol.StreamingExtensions.NetCore
That because the package Microsoft.Bot.Protocol.StreamingExtensions.NetCore was only published to the myget.org Not nuget.org. That is also the reason why the error message show that this id in source(s): NuGetOrg.
You can find that package on the myget.org:
https://botbuilder.myget.org/gallery/experimental
Then get the URL to connect the feed is:
https://botbuilder.myget.org/F/experimental/api/v3/index.json
To resolve this issue on Azure DevOps, you can add a nuget.config under the solution folder with following content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="MyGetFeed" value="https://botbuilder.myget.org/F/experimental/api/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
Then submit and push this file to the Azure Devops repos. Use this file when you restore nuget packages:
As test, it works fine on my side.
Hope this helps.

Devops using packages from private Azure Artifacts feed: unexpected status code '404 Not Found'

My solution contains references to some private Nuget packages in a feed hosted in a Devops Artifact.
It builds on my machine.
However the Dev ops build fails because I need to set up access to the private Nuget Feed.
I am studying the docs
I have a nuget.config file in my solution with a reference to my private feed.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<activePackageSource>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</activePackageSource>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="MyFeed" value="myfeed/nuget/v3/index.js" />
<!-- Others -->
</packageSources>
<packageSourceCredentials>
<!-- secret stuff -->
</packageSourceCredentials>
</configuration>
The NugetCommand task has an error (edited)
NU1000: Unable to find version 'myversion' of package 'MyPackageName'.
C:\Users\VssAdministrator\.nuget\packages\: Package 'MyPackageName-Version' is not found on source 'C:\Users\VssAdministrator\.nuget\packages\'.
The build pipeline has a task
- task: NuGetCommand#2
inputs:
restoreSolution: '**\*.sln'
feedsToUse: config
nugetConfigPath: 'myproject/nuget.config'
The edited error is
NU1000: Unable to find version 'myversion' of package 'mypackage'.
C:\Users\VssAdministrator\.nuget\packages\: Package 'mypackage-versionumber' is not found on source 'C:\Users\VssAdministrator\.nuget\packages\'.
myfeed/nuget/v3/index.js: The V2 feed at 'myfeed/nuget/v3/index.js/FindPackagesById()?id='mypackage'&semVerLevel=2.0.0' returned an unexpected status code '404 Not Found'.
https://api.nuget.org/v3/index.json: Package 'mypackage' is not found on source 'https://api.nuget.org/v3/index.json'.
Why would the error mention a V2 feed?
In VS2017 15.9.7 Help About, I see that NuGet Package Manager is 4.6.0
I wonder if it could be an access issue.
In Devops the project containing the package feed is in the same organisation as the consuming project.
Configure Devops to use packages from private Azure Artifacts feed
Your YAML file and configuration steps are correct. I test it on my side and it works fine, but I found that your private Nuget packages feed path does not seem to be incorrect, so confirm with you by comments.
The path should be .json file. We could copy it from Azure Artifacts feed with connect to feed button:
Post it as answer, hope it would be helpful to anyone who encounters similar issues.
Thanks also to the confirmation of #Kirsten Greed.