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?
Related
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:
I have two aspnet core 3.1 applications and have set up two azure piplines:
One pipeline is working fine building and testing my project, the other one (similar structure and referencing same projects) is failing with following error:
C:\hostedtoolcache\windows\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets(404,5): warning RAZORSDK1006: Detected Razor language version downgrade. This is typically caused by a reference to the Microsoft.AspNetCore.Razor.Design package. Consider removing this package reference. [d:\a\1\s\Sources\Web\Web.csproj]
CSC : warning CS8034: Unable to load Analyzer assembly C:\Users\VssAdministrator\.nuget\packages\microsoft.aspnetcore.mvc.analyzers\2.2.0\analyzers\dotnet\cs\Microsoft.AspNetCore.Mvc.Analyzers.dll : Assembly with same name is already loaded [d:\a\1\s\Sources\Web\Web.csproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.aspnetcore.razor.design\2.2.0\build\netstandard2.0\Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets(79,5): error : rzc discover exited with code -2147450730. [d:\a\1\s\Sources\Web\Web.csproj]
54 Warning(s)
1 Error(s)
Time Elapsed 00:02:41.66
##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x SDK/Runtime along with 2.2 & 2.1. Unless you have locked down a SDK version for your project(s), 3.x SDK might be picked up which might have breaking behavior as compared to previous versions.
Some commonly encountered changes are:
If you're using `Publish` command with -o or --Output argument, you will see that the output folder is now being created at root directory rather than Project File's directory. To learn about more such changes and troubleshoot, refer here: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
##[error]Dotnet command failed with non-zero exit code on the following projects : d:\a\1\s\Sources\Web\Web.csproj
Does someone have an idea what I can check?
Kind regards
I got a build in VSTS that are triggered on every commit in the repository. Everything works great with one exception.
We do not release a new version of the nuget package on every commit. So our nuget push build step fails with http status code 409. I've configured that step so that it can continue anyway.
Due to the error the build is just "partially successful". I'm using the a build badge which also states the same (without context).
How can I tell VSTS to ignore 409 or just replace the existing package (on nuget.org)?
You can’t ignore 409 error in VSTS build and can’t replace the existing package in server.
I recommend that you can push the package in the release and fail the release if package is existing.
Another way is that, you can check the package in server before push package (e.g. PowerShell, REST API) during the build and set the condition for push package task (Custom Condition).
For example:
Add a variable to build definition (e.g. hasPackage true)
Check packages (PowerShell, Rest API etc…)
If the package is existing, set the variable to false ("##vso[task.setvariable variable=hasPackage;]false")
Set Custom condition for push package task (e.g. eq(variables['hasPackage'],'false'))
Update:
Allow duplicates to be skipped is supported in NuGet Push Task now! (Just check Allow duplicates to be skipped option in NuGet Push task.
Use -SkipDuplicate flag (available since NuGet 5.1):
(5.1+) If a package and version already exists, skip it and continue with the next package in the push, if any.
Source: https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-push#options
We had the same problem with duplicated packages on Azure Pipelines.
Solution proposed by starian chen-MSFT is cool but it requires some scripting.
We came to solution which requires less efforts. You can create command line step and invoke dotnet nuget push with the following parameters:
dotnet nuget push $(Build.ArtifactStagingDirectory)/*.nupkg --skip-duplicate --api-key $(Config.NuGetApiKey) --source https://api.nuget.org/v3/index.json
The key is parameter --skip-duplicate which just skips the packages if they already exist.
In variable $(Config.NuGetApiKey) define your API key for NuGet.org. You should make it secret variable, so that it does not appear anywhere in the logs.
Here is the YAML for this command:
steps:
- script: |
dotnet nuget push $(Build.ArtifactStagingDirectory)/*.nupkg --skip-duplicate --api-key $(Config.NuGetApiKey) --source https://api.nuget.org/v3/index.json
failOnStderr: true
displayName: 'Publish NuGet Package'
I have had zero luck with dotnet push - and here's my context:
My dotnet pack is set to include symbols and source
and always generating a unique preRelease semVer.. (here's yaml version of above dotnet pack)
steps:
- task: DotNetCoreCLI#2
displayName: 'dotnet pack'
inputs:
command: pack
nobuild: true
includesymbols: true
includesource: true
versioningScheme: byPrereleaseNumber
majorVersion: '$(AssemblyInfo.AssemblyInformationalVersion.Major)'
minorVersion: '$(AssemblyInfo.AssemblyInformationalVersion.Minor)'
patchVersion: '$(AssemblyInfo.AssemblyInformationalVersion.Patch)'
... and yet I get 409 responses with my freshly generated semVer!!
** BLAH!! **
My Solution: just use NuGet Push instead!
- task: NuGetCommand#2
displayName: 'NuGet push'
inputs:
command: push
publishVstsFeed: 'b64b1c9a-18fc-4e6f-aae7-3726c813f034'
continueOnError: true
Now my debug build-configuration CI pipeline builds full-source-and-symbol-accompanied NuGet packages in pre-release mode without failing the pipeline or putting caution symbols on it. YAY
I use a separate near identical CI pipeline to build in 'release' mode and create 'release' style semVer's.
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.
I am trying to run the sample Vision API project. I basically copied and pasted the code Program.cs into my application and executed it.
This line (which is line #36-#37 in Program.cs)
GoogleCredential credential = GoogleCredential.GetApplicationDefaultAsync().Result;
throws a System.AggregateException in mscorlib.dll with Additional information: One or more errors occurred..
By examining InnerException, I found out that the actual exception thrown is InvalidOperationException with Error deserializing JSON credential data..
Nonetheless, my cloud project is a basic project, with a Service Account, and Cloud Vision API enabled, nothing else. I checked that my environment variable was set to the JSON file by writing:
Console.WriteLine(Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS"));
before the line above. The output of that (just before the crash) is (something like):
C:\Users\me\Documents\Projects\MyProject\MyProject-ba31aae6efa1.json
I checked the file, and it is the file that I got when I enabled my service account. Every property in it looks fine (i.e. project name is correct, path's correct, ...).
I installed the Google Cloud SDK and executed gcloud beta auth application-default login and authorized access to my cloud account.
Any ideas on what might be causing this?
By examining the detailed build log, I found out that the packages for the Google APIs had a dependency for Newtonsoft.Json version 9.0.1 (the latest at the time of this writing).
For whatever reason, the Google APIs packages have a dependency (which is installed along with them) on Newtonsoft.Json version 7.0.0.
The packages came with the wrong version!
Installing the latest version (9.0.1 in this case) fixes the issue.