Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The dotnet pack doesn't work together with -p:NuspecProperties when multiple properties provided

See original GitHub issue

When calling the

dotnet pack project.csproj -p:NuspecFile=project.nuspec -p:NuspecProperties="version=11.0.0;year=2021" --verbosity quiet --output c:/temp

command to pack a NuGet package providing multiple properties (version, year), only the first one is replaced in nuspec file with the provided value. Others are resolved as an empty string.

project.csproj file image

project.nuspec file image

nuspec file in resulted package image

Is there anything I am missing or there might be a bug in passing the properties?


Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

kordyscommented, Feb 9, 2021

It looks like this approach works as you described.

The thing is I followed the documentation here:

Where there is this statement: NuspecProperties: a semicolon-separated list of key=value pairs. Due to the way MSBuild command-line parsing works, multiple properties must be specified as follows: -p:NuspecProperties=“key1=value1;key2=value2”.

And since the values of the properties are in my case dynamically populated (evaluated as part of the build pipeline), I wanted them to be provided as dotnet pack arguments.

For now, I use plain string replace to provide the values to the nuspec file as a workaround.

Hopefully, it makes sense.

kordyscommented, Jan 29, 2021

When I reverse the order it’s the same behavior - only the first parameter is replaced - the year in this case. SPlitting the properties this way:

dotnet pack project.csproj -p:NuspecFile=project.nuspec -p:NuspecProperties="version=11.0.0" -p:NuspecProperties="year=2021" --verbosity quiet --output c:/temp

doesn’t help either. Unfortunately, the second argument value overrides the first one, so in this case, only the ‘year’ is replaced (Actually the pack fails because the version is empty since it is not replaced with the correct value).

So sadly nothing from the provided workarounds work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to pack a NuGet package using dotnet CLI and ...
As a result, I'm trying to use the dotnet pack command to create my NuGet package while using my nuspec file with tokens....
Read more >
dotnet pack command - .NET CLI
The dotnet pack command creates NuGet packages for your .NET project.
Read more >
NuGet pack and restore as MSBuild targets
NuGet pack and restore can work directly as MSBuild targets with NuGet ... Owners and Summary properties from .nuspec are not supported with ......
Read more >
MSBuild reference for .NET SDK projects
This page is a reference for the MSBuild properties and items that you can use to configure .NET projects. Note. This page is...
Read more >
PackageReference in project files - NuGet
In this article ... Package references, using <PackageReference> MSBuild items, specify NuGet package dependencies directly within project files, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found