I'm following along this official doc about creating a nuget package with nuget.exe
. I'm trying to create a nuspec file out of a Visual Studio project.
According to the docs, when you run
> nuget spec
From the directory where your .csproj
file resides, it creates a tokenized .nuspec
file. Then, when you run nuget pack <project-name>.csproj
the values from the project file are used to replace the tokens in the nuspec file.
So in my example, I have a project called Logger1
. After running nuget spec
, I have the following .nuspec
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>Yoav Klein</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
...
Now, this doc says that:
To use these tokens, run nuget pack with the project file rather than just the .nuspec. For example, when using the following command, the $id$ and $version$ tokens in a .nuspec file are replaced with the project's AssemblyName and AssemblyVersion values:
nuget pack MyProject.csproj
My Assembly version is:
# AssemblyInfo.cs
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Now I run nuget pack Logger1.csproj
and I expect the version of the package to be drawn from the AssemblyVersion
of the project, as promised by the docs.
After creating the package, I examine the .nuspec file in the package created:
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Logger1</id>
<version>1.0.0</version>
As you can see, for some reason, it doesn't take the correct value of the AssemblyVersion
which is 1.6.0
, but rather always uses the value 1.0.0
.
Can someone tell me what am I doing wrong?
NuGet Version: 5.8.1.7021
Just to confirm, after building the dll, I can see that the assembly version is 1.6.0:
PS> [Reflection.AssemblyName]::GetAssemblyName("$(pwd)\bin\Debug\Logger1.dll")
Version Name
------- ----
1.6.0.0 Logger1