When using dotnet pack, how do I pass a variable to my nuspec file?
I am trying to pass the version. Here is the nuspec:
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<!-- Required elements-->
<id>1</id>
<version>$PackageVersion$</version>
<description>1</description>
<authors>1</authors>
</metadata>
</package>
And here is my command:
dotnet.exe pack /p:NuspecFile=./App.Nuspec /p:PackageVersion=9.7.28170
I get the error: Value cannot be null or an empty string.
Interestingly, if I change the variable to be the description:
<version>1.1.0</version>
<description>$PackageVersion$</description>
I get the error: Description is required.
When the tag is description the tag name is in the error message. However, when the tag is version there is no tag name in the error message - only the term value. Both are required fields.
I am doing this with the command line on my local machine, but the TFS build gives the same error. Here is the TFS tooltip for the Additional build properties for that step. Specifies a list of token = value pairs, separated by semicolons, where each occurrence of $token$ in the .nuspec file will be replaced with the given value. Values can be strings in quotation marks.
It sounds like I am following those rules. And here is what TFS generates:
"C:\Program Files\dotnet\dotnet.exe" pack D:\Agent_work\5\s\MyProject\MyProject.csproj --output D:\Agent_work\5\a /p:NuspecFile=App.nuspec /p:PackageVersion=9.7.28170 --verbosity Normal
Same as my command.
What am I doing wrong?