Nuget package is not listed on ADO Artifacts, but I can't upload because it already exists? - azure-devops

I have a newly created Feed in Azure DevOps where I'm hosting my Nuget packages. I uploaded a bunch, but when I tried to download My.Package.1.0.4 it isn't listed in the feed; neither in VS nor on the web portal. My.Package.1.0.5-beta-2 is there, but even in the version list 1.0.4 is not shown.
I figured it just didn't get uploaded - so tried again; when I do, I get the error Response status code does not indicate success: 409 (Conflict - The feed already contains 'My.Package 1.0.4'.
My question is: where is it hiding? It doesn't show up in the feed anywhere, but it apparently uploaded successfully. What do I do now?

It could happen when package was deleted:
When you publish a particular version of a package to a feed, that version number is permanently reserved. You cannot upload a newer revision package with that same version number, or delete it and upload a new package at the same version.
You can check it here:

Related

Azure DevOps : not possible to publish again a deleted artifact

I have a deleted artifact in a feed (and no more visible in the recycle bin, because permently deleted) :
And I can't republish the same artifact, because It seems still present in the feed :
I tried also to create a new feed :
And I tried to publish the same artifact in the new feed, but I have the following error message :
Could you tell me how can I republish the artifact please?
Regards,
Yannick
Azure DevOps : not possible to publish again a deleted artifact
This is the default behavior.
I understand how frustrating this is for you. But this is what Azure Artifacts deliberately designed to ensure the correctness of the build results.
Check the document: Understand immutability of packages.
Once you publish a particular version of a package to a feed, that
version number is permanently reserved. You cannot upload a newer
revision package with that same version number, or delete it and
upload a new package at the same version.
You could check my previous thread for the reason for this design.
To resolve this issue, you could try to publish the artifact with another version. If you do not want to change the version, you need to upload this artifact to another feed, and add this feed as package source.

Is there a way to skip checking if package exists when publishing artifact to feed?

I have an azure pipeline that at the end creates azure artifacts out of my deliverables.
I then publish them to azure feeds so other pipelines can use them.
I have been facing error An unexpected error occurred while trying to push the package. Exit code(17).
Looking at the log I can see it claims The package myPackage 1.0122.0 already exists in myUuidString.
Is there a way to bypass the check whether the package exists or not ? In other words, is not there a way to overwrite a package in case it exists?
Is there a way to clear/delete the contents of a feed before publishing?
Could not find neither answer in the docs.
Is there a way to skip checking if package exists when publishing artifact to feed?
For the Universal Package task, I am farid there is no such way to skip checking if package exists when publishing artifact to feed at this moment.
Unlike the nuget push task, there is currently no such option for the Universal Package task to allow duplicates to be skipped:
Besides, since the document: Understand immutability of packages:
Once you publish a particular version of a package to a feed, that
version number is permanently reserved. You cannot upload a newer
revision package with that same version number, or delete it and
upload a new package at the same version.
So, we could not updalod the same version to the feed.
As workaround, we could publish the package with a new version. And we could add a user voice for the same option Allow duplicates to be skipped on the Github.

Is there a way to check if a nuget package is already on a ProGet Repo?

So, I've been working on an azure pipeline that is supposed to download a NuGet package and then upload it to a ProGet feet. But it should only upload the package if it doesn't yet exist on the feed to avoid redundancy. (If the package already exists on the feed, but the version is different, it should still be uploaded). Is there a way to check if a package already exists on a ProGet feed using nuget.exe or some other kind of NuGet tool?
You can use one of the several options here.
The first one is to use nuget.exe, in particular, its list command. The following command will list all versions of the package available on the feed:
nuget list <PackageName> -Source <ProgetFeedURL> -AllVersions
where <PackageName> is obviously the [part of the] package name, and <ProgetFeedURL> is the feed URL. The output is a list of packages along with their versions you can easily parse to find out whether the version in question is already on the feed.
The other approach could be to form a download URL for a package in ProGet and send a simple GET request to that URL. The URL is generally formed like this (note that your version of ProGet might form a different URL. You can verify that if you hover a mouse over the Download button in the browser):
http(s)://<ProGetServer>/nuget/<ProGetFeed>/package/<PackageName>/<PackageVersion>
In case this GET request results in 404, you can be sure there's no such version of that package on the feed.
I suppose there must be some REST API of Proget to verify a similar stuff, but I haven't worked with that.

How Can You Replace a Package in Artifacts

We have a custom feed in Azure DevOps Server for NuGet packages. When uploading the Microsoft.AspNetCore.Authentication.Core 2.2.0 package something went wrong and now we have a bad package in our feed.
According to this question, asked and answered several years ago, it is not possible to replace the package, only increment the number and push a new version.
What are supposed to do when we don't control the version number of the package and need to replace the bad upload?
Right now, the only option we can see is to create a new feed and reupload everything from the old feed.
What are supposed to do when we don't control the version number of the package and need to replace the bad upload?
As I mentioned in that thread, in order to avoid contamination of the package source, MS strictly controls the package version, does not allow upload a newer revision package with that same version number, or delete it and upload a new package at the same version.
So, if we don't control the version number of the package and need to replace the bad upload, we have to create a new feed to save this specify package.
BTW, if you do not want to reupload everything from the old feed, you could try following workaround:
Upload the package Microsoft.AspNetCore.Authentication.Core 2.2.0
to the new feed.
Delete the damaged package from the old feed.
Add the new feed as upstream source for the old feed.
Now, we could restore the nuget package from the old feed.
Note: Do not reverse the order of step 1 and 3, otherwise you could upload the package due to the 409 conflict error.

How to update a maven dependency with a same version number in Azure Artifacts

We changed our maven private repository Nexus to Azure Artifacts.
And when we upload a private maven dependency with a some version, it told us below info:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
(default-deploy) on project HmapBasic: Failed to deploy artifacts:
Could not transfer artifact com.hand:HmapBasic:pom:3.0.3-RELEASE
from/to dev-azure-com-kohlerdevops-konnect-unified
(https://pkgs.dev.azure.com/KohlerDevOps/_packaging/Konnect-Unified/maven/v1/):
Failed to transfer file:
https://pkgs.dev.azure.com/KohlerDevOps/_packaging/Konnect-Unified/maven/v1/com/hand/HmapBasic/3.0.3-RELEASE/HmapBasic-3.0.3-RELEASE.pom.
Return code is: 409
I searched the code 409 error. It means we have already uploaded the dependency with this version and we can't upload this again.
We want to use the new dependency cover the old one without changing version(because if we change the version, all of our projects need to change pom.xml)
how can we do that in Azure Artifacts?
How to update a maven dependency with a same version number in Azure Artifacts
I am afraid you have to change the pom.xml, I understand how frustrating this is for you. But this is what Azure Artifacts deliberately designed to ensure the correctness of the build results.
Check the document: Understand immutability of packages.
Once you publish a particular version of a package to a feed, that
version number is permanently reserved. You cannot upload a newer
revision package with that same version number, or delete it and
upload a new package at the same version.
The reason for this design:
That because many package clients, including NuGet, keep a local cache
of packages on your machine. Once a client has cached a particular
package#version, it will return that copy on future install/restore
requests. If, on the server, you replace package#version (rev 1) with
a new package#version (rev 2), the client is unable to tell the
difference. the client still use the old version in cache. This can lead to indeterminate build results from
different machines.
So we could not overwrite all packages that have already been
uploaded, even we could not delete them and re-uploaded. To resolve
this issue, the only way is that upload the packages with a new
version.
Check my another thread for some more info.
Hope this helps.
I just made a test on Azure DevOps and if you use the "SNAPSHOT" suffix it will overwrite the previous package/artifact. For instance 2.0.0-SNAPSHOT.