Josh Mouch
Josh Mouch

Reputation: 3558

Overriding nuget package name when using "nuget pack" with a visual studio project

I am currently generating nuget packages by passing in a csproj file instead of a nuspec file. The problem is that I need to change the name of the nuget package to avoid conflicts with another project.

This is the command I'm running:

"C:\Program Files\dotnet\dotnet.exe" pack C:\VSTS\Agent\_work\1\s\src\MyProject\MyProject.csproj --include-symbols --include-source --output C:\VSTS\Agent\_work\1\a --no-build /p:Configuration=debug --include-symbols --include-source /p:PackageVersion=2018.10.11.3

I tried appending the following to the command, but it seems to be ignored:

/p:Id=ThisIsWhatThePackageNameShouldBe

And also tried changing the assembly name in the project (but not the project name), and then doing this:

/p:Id=$(AssemblyName)

But this was also ignored.

Upvotes: 1

Views: 3116

Answers (1)

Josh Mouch
Josh Mouch

Reputation: 3558

Something automatically added a <PackageId> element into the csproj file, and that was taking precedence. I updated this value to what I want the package named and now it's working as expected.

I'm guessing the reason /p:Id argument was being ignored, was because it might have needed to be /p:PackageId, instead.

Upvotes: 2

Related Questions