0
votes

I would like to pack nuget package using a .csproj file. Following command will be executed:

nuget pack MyProject.csproj -IncludeReferencedProjects

In the project folder I have two nuspec files, one depending to the MyProject.csproj and another which will be used to make a different package but depending on this project to. Folder structure looks like:

-ProjectFolder
 |-MyProject.csproj
 |-AdditionalMyProject.nuspec
 |-MyProject.nuspec

When calling the nuget pack command, it always takes the first nuspec file (AdditionalMyProject.nuspec - lower naming) to get metadata for nuget package but the correct nuspec should be MyProject.nuspec (matching the name of project file).

Is there a way to tell nuget pack which nuspec it should use when packing a csproj?

Something like this:

nuget pack MyProject.csproj -nuspec MyProject.nuspec -IncludeReferencedProjectsenter
1
I don't understand the purpose of AdditionalMyProject.nuspec. If there's another project that has a dependency on MyProject, I don't see why you would need a special nuspec for MyProject. This might be a case of the XY problem. Why do you want two nuspec files?zivkan
@Ziv I would like to provide two packages with different purpose. The AdditionalMyProject.nuspec should provide dependencies to other nuget packages including MyProject.nupkg. MyProject is only base package for a defined purpose.Michi-2142
if AdditionalMyProject is a meta package, then there's no need for the nuspec to be in the same folder as the csproj, right? move it to its own folder, then there's only 1 nuspec next to the csproj.zivkan
That's an answer which makes sense. I tried and it worked, can you post it as answer?Michi-2142

1 Answers

0
votes

AdditionalMyProject.nuspec is a different project, even if it doesn't have a MSBuild project associated (it is a different .nupkg after all), so you're less likely to have tooling problems if you keep the nuspec in its own directory. Similar to how different csproj files live in different directories, even when one has a dependency on the other, I recommend putting the different .nuspec files in different directories, even if MyProject is a nuget dependency of AdditionalMyProject.