I am verified in DevOps using an ssh key (at least for git)
So I pulled a solution from mycompany#vs-ssh.visualstudio.com:v3/mycompany/thing/thing, and tried to build it using dotnet build, but get the error
/usr/local/share/dotnet/sdk/3.1.402/NuGet.targets(128,5): error : Unable to load the service index for source https://mycompany.pkgs.visualstudio.com/_packaging/SomeProject/nuget/v3/index.json.
/usr/local/share/dotnet/sdk/3.1.402/NuGet.targets(128,5): error : Response status code does not indicate success: 401 (Unauthorized).
How can I get around this (I assume by authenticating with the sources server) and build the project?
Please install Azure Artifacts Credential Provider and once you do it run dotnet restore --interactive and then you will be prompted to login to a page like below:
Related
I have a .net core 3.1 project I am attempting to build on an Ubuntu 20.04 virtual machine.
The project was building successfully, I now need to update one of the NuGet packages in the project. Once I change the package version in the .csproj file to the required version, when I either build or perform "dotnet restore" I get the following message:
/usr/share/dotnet/sdk/3.1.415/NuGet.targets(128,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/home/ic/Source/redacted.csproj]
/usr/share/dotnet/sdk/3.1.415/NuGet.targets(128,5): error : The SSL connection could not be established, see inner exception. [/home/ic/Source/redacted.csproj]
/usr/share/dotnet/sdk/3.1.415/NuGet.targets(128,5): error : The remote certificate is invalid according to the validation procedure. [/home/ic/Source/redacted.csproj]
If I browse to https://api.nuget.org/v3/index.json I can successfully view the json in the browser and the certificate appears to be trusted.
I have:
Updated packages (apt-get update AND apt-get upgrade)
Updated NuGet
Set certificate thumbnails in NuGet.Config as per the update in this question: Problem resolving Nuget Packages in Devops Build Agent due to Certificate issues
I can see the DigiCert root certificate for nuget.org in the trusted certificates on Ubuntu
Not sure in the end what actually solved my problem, but, long story short, I think the following worked:
Running wget on api.nuget.org gave:
--2021-12-02 09:38:34-- https://api.nuget.org/v3/index.json
Resolving api.nuget.org (api.nuget.org)... 152.199.40.167
Connecting to api.nuget.org (api.nuget.org)|152.199.40.167|:443... connected.
ERROR: cannot verify api.nuget.org's certificate, issued by 'CN=Microsoft Azure TLS Issuing CA 05,O=Microsoft Corporation,C=US’:
Unable to locally verify the issuer's authority.
To connect to api.nuget.org insecurely, use `--no-check-certificate'.
At some point in researching that error, I reinstalled ca-certificates (not sure if that has anything to do with resolving the problem):
sudo apt-get install --reinstall ca-certificates
Ultimately, I found: "dotnet restore" fails with "SSL peer certificate or SSH remote key was not OK" which led me to setting the SSL_CERT_FILE environment variable:
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
That seems to have been the key and dotnet restore now works correctly.
I am trying to port a legacy project to push nuget artifacts to Github Packages as a proof-of-concept, and learning on the job.
The push currently fails without an explanation:
C:\Users\m86194\source\repos\my-project>dotnet nuget push "**/*.nupkg" --source github --skip-duplicate --api-key ***
Pushing my-project.1.0.0.nupkg to 'https://nuget.pkg.github.com/me'...
PUT https://nuget.pkg.github.com/me/
warn : No destination repository detected. Ensure the source project has a 'RepositoryUrl' property defined. If you're using a nuspec file, ensure that it has a repository element with the required 'type' and 'url' attributes.
BadRequest https://nuget.pkg.github.com/me/ 4721ms
error: Response status code does not indicate success: 400 (Bad Request).
(project and username changed by hand). I understand that the warning given by dotnet locally about the RepositoryUrl is most likely correct even though it should be in there, but I would expect an explanatory rejection reason from the backend which I would like to see.
I did not notice such a debug log in my unexperienced browsing of the Github Packaging guides, and the help page for dotnet nuget push does not indicate a -v flag.
How do I get debug information from the server here?
I deployed new private NuGet server (NuGet.Server.3.4.1) and set up API key in web.config.
Then I created first nuget package from my .net core class library project.
But when I try to run following command
dotnet nuget push packageName.1.0.0.nupkg --api-key myKey --source https://privateNugetServer.com/nuget
I get an error from the server
error: Response status code does not indicate success: 502 (Bad
Gateway).
I tried workaround when I uploaded package manually with Nuget server itself, but than I still got this error when I add additional Package source to visual studio nuget manager pointing to my server.
error: Response status code does not indicate success: 502 (Bad
Gateway).
What might be an issue ?
In Azure DevOps I have my company nuget repository. I have created some new nuget packages and I included them in my projects. Locally the projects are working fine.
When I run the dotnet build on DevOps there is error because there is an unauthorize access to the nuget repository.
[error]C:\Program Files\dotnet\sdk\3.1.202\NuGet.targets(124,5): Error : Unable to load the service index for source
https://vs.pkgs.visualstudio.com/Vs/_packaging/vs.com/nuget/v3/index.json.
Response status code does not indicate success: 401 (Unauthorized).
C:\Program Files\dotnet\sdk\3.1.202\NuGet.targets(124,5): error :
Unable to load the service index for source
https://vs.pkgs.visualstudio.com/Vs/_packaging/vs.com/nuget/v3/index.json.
[d:\a\1\s\Payments\Payments.csproj]
C:\Program
Files\dotnet\sdk\3.1.202\NuGet.targets(124,5): error : Response
status code does not indicate success: 401 (Unauthorized).
[d:\a\1\s\PiP.Payments.Stripe\PiP.Payments.csproj]
Build FAILED.
C:\Program Files\dotnet\sdk\3.1.202\NuGet.targets(124,5): error :
Unable to load the service index for source
https://vs.pkgs.visualstudio.com/Vs/_packaging/vs.com/nuget/v3/index.json.
[d:\a\1\s\PiP.Payments.Stripe\PiP.Payments.csproj]
C:\Program
Files\dotnet\sdk\3.1.202\NuGet.targets(124,5): error : Response
status code does not indicate success: 401 (Unauthorized).
We have had this error several times before. We were always able to fix it with an extra dotnet restore command before the dotnet build command.
There is a small hint in the documentation here:
https://learn.microsoft.com/en-us/azure/devops/artifacts/nuget/dotnet-exe?view=azure-devops#on-build-machines-and-in-non-interactive-scenarios
In Azure Pipelines, use the .NET Core step's restore command, which automatically handles authentication to Azure Artifacts feeds. Otherwise, use the Azure Artifacts Credential Provider and pass in credentials using the VSS_NUGET_EXTERNAL_FEED_ENDPOINTS environment variable.
Here is an example yaml:
- task: DotNetCoreCLI#2
displayName: 'Restore Packages'
inputs:
command: restore
projects: 'MyCsproj.csproj'
vstsFeed: 'voxspan'
- task: DotNetCoreCLI#2
displayName: 'Build'
inputs:
command: build
projects: 'MyCsproj.csproj'
I have a little dotnet core application and want to build it on jenkins.
In order to make it happen, ive installed dotnet core on the build slave.
Locally i can restore with the same command successfuly (even on my mac)
dotnet restore --configfile .nuget/NuGet.Config
On the build server the restore fails for one package.
Started by user jenkins
Building remotely on 2c3bff31e594 in workspace /root/workspace/Test
Cloning the remote Git repository
...
+ dotnet restore --configfile .nuget/NuGet.Config
Welcome to .NET Core!
---------------------
...
log : Installing System.Runtime 4.1.0-rc2-24027.
log : Installing System.Diagnostics.Tools 4.0.1-rc2-24027.
log : Installing System.Reflection.Extensions 4.0.1-rc2-24027.
...
log : Restoring packages for /root/workspace/Test/test/Test.DataAccess.Tests/project.json...
log : Failed to download package from 'https://api.nuget.org/v3-flatcontainer/remotion.linq/2.1.1/remotion.linq.2.1.1.nupkg'.
log : Response status code does not indicate success: 404 (Not Found).
The strange thing here is, that if i hit the url
"https://api.nuget.org/v3-flatcontainer/remotion.linq/2.1.1/remotion.linq.2.1.1.nupkg" link from the log, the package is their.
probably a firewall or any other local setting
probably firewall. id install fiddler on the computer and look what is the exact request
add fiddler as nuget porxy like this:
https://docs.nuget.org/consume/nuget-config-settings#proxy-settings
Proxy settings
section: config
keys: http_proxy, http_proxy.user, http_proxy.password and no_proxy.
Allows you to set the proxy settings to be used while connecting to your NuGet feed. More details here.
This key can be added using NuGet.exe Config -Set command.
It can also be set via environment variables http_proxy and no_proxy. http_proxy should be specified in the format http://[username]:[password]#proxy.com whereas no_proxy should be a comma-separated list of domains to bypass the proxy server.
Note
The "http_proxy.password" key value is encrypted before storing in the nuget.config file. Hence it can not be added manually by directly updating the config file.