edit nuspec file in nupkg

1.4k views Asked by At

I would like to create a semantically versioned nupkg after ci process on TFS. The nupkg should be as shown below.

MSVersioningSample.1.0.7-ci-20170926-184446.nupkg

But, when I decided it is a release version. I would like to rename nupgk and republish it to nuget feed as the release version.

MSVersioningSample.1.0.7.nupkg

When I rename nupkg file and publish it, its version number still stay same and conflict occurs during publish.

Then, I realized. There is a .nuspec file inside the nupkg file and I have to change version number in the nuspec file.

My question is, How could I edit nuspec file in nupkg with (powershell) script?

1

There are 1 answers

0
PatrickLu-MSFT On

Seems you want to use prerelease versions nupkg, but remove the prerelease when ready to release. You have to rewrite the <version> element in the nuspec file. But it's not so easy to handle all situations, such as if your build produced multiple packages, some of which depend on each other? Now you also need to discover the dependency graph and rewrite the appropriate elements.

To update the versions field in the '*.nuspec' file, you could reference this powershell script in GitHub: Nuspec Auto Update

Another workaround is adding two nuget packaging steps to build process. One packages with the -ci number and one doesn’t.

Then you just have to make sure only copy the ‘release’ package to ArtifactStagingDirectory which already does not have the prelease segment

Also set up your Release so that it use the build number as the release name. A minor issue that this includes the -ci number.