Update NuSpec version from MsBuild

Here’s the sample script that updates NuGet version node in NuSpec file:

<target Name="UpdateNuspec">
    <getAssemblyIdentity AssemblyFiles="$(ReleaseFolder)/Redistributables/YourAssembly.dll">
      <output TaskParameter="Assemblies" ItemName="YourAssemblyInfo"/>
    </getAssemblyIdentity>
    <xmlUpdate
        Prefix="nu"
        Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"
        XmlFileName="YourAssembly.nuspec"
        XPath="package/nu:metadata/nu:version"
        Value="%(YourAssemblyInfo.Version)"/>
</target>

Tags:  

Questions?

Consider using our Q&A forum for asking questions.