I'm creating a .NuSpec file with
<metadata>
<version>$version$</version>
<!-- ... -->
</metadata>
Unfortunately, that returns the assembly's version in Major.Minor.Build.Revision format. I need to trim this down to 3 parts only (Major.Minor.Build) for compatibility with SemVersion as used by Squirrel.
Is there any way to do this? I'd prefer not having to put in the version number by hand for each release.
If you do not want to modify the version number by hand for each release, you probably don't need
.nuspec
. You can runnuget pack
with the project file directly:According to the Replacement tokens, when we pack the
.csproj
directly, the value source of$version$
comes from fileAssemblyInfo.cs
orAssemblyInfo.vb
:So nuget will use the value of
AssemblyInformationalVersion
if present, otherwise AssemblyVersion. It is removed by default, because they don’t apply to semantic versioning. when we add it to theAssemblyInfo.cs
file:Nuget will actually apply whatever is in that string as the package version. Notice that the informational version only contains three numbers. So it compatibility with SemVersion as used by Squirrel.
Source:How to Version Assemblies Destined for Nuget
Hope this helps.