Hossein A
Hossein A

Reputation: 1260

Auto update the nuspec file during the build process

I have been able to use NuGetter to create a build definition to automate the NuGet package creation process and to upload the package to the NuGet repository.

But, I would like to automate the process even further. The following is a list of steps I would like to automate as part of the build process:

The nuspec fields that I really want to be able to automate are:

Authors I would like the build process to replace this field in the nuspec file with the name of the person who is check-in the code.

releaseNotes I would like the build process to replace this field in the nuspec file with the check-in comment.

Has anyone been able to accomplish this? If so, how did you go about automating it?

Upvotes: 9

Views: 6228

Answers (3)

Aviram Fireberger
Aviram Fireberger

Reputation: 4168

You can add a new post build event that trigger a script that's taking the version from the "packages.config" file and write them back to the nuspec file.

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -Command .'$(ProjectDir)..\PathToScirptLocation\NuspecAutoUpdate.ps1' -NuspecPath '$(ProjectDir)API.nuspec' -PackagesConfigPath '$(ProjectDir)packages.config'

I upload the script and the post build event to my GIT for anyone who will need it.

https://github.com/avrum/NuspecAutoUpdate

Upvotes: 0

Jason Jarrett
Jason Jarrett

Reputation: 3987

This may help.

I created an automated process to publish updates for an open source project.

https://github.com/DefinitelyTyped/NugetAutomation

Some things of interest to you are possibly.

  • How we use powershell to copy a 'template' nuspec and inject the fields we need. (you can use this to similarly replace the 'authors, releaseNotes' fields)
  • Ping the public nuget server to get the current version and increase the version.

It requires some Powershell knowledge, but I hope it gives you a start.

Upvotes: 4

Deepak
Deepak

Reputation: 2233

this post here How to avoid xml document generation when using nuget pack has some ideas

<XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/licenseUrl" Value="http://someurl" />          
<XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/projectUrl" Value="http://someurl" />          
<XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/iconUrl" Value="http://somenice.png" />            
<XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/tags" Value="My.Assembly" />           
<XmlUpdate Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" XmlFileName="My.Assembly.nuspec" XPath="//package/metadata/releaseNotes" Value="Review readme.txt for details." />  

Upvotes: 0

Related Questions