I want to package my project by packing the project file .csproj
and not the .nuspec
. But I also want to explicitly specify the dependencies.
The problem is that when packing the project file (so that I can use the props from my project) the <dependencies>
in the .nuspec
file is not being used.
I'm doing this so that I can change my props in one place (in AssemblyInfo.cs
) without having to change the .nuspec
also with every version. I know I can pack the .nuspec
where I'll have full control but this already defeats the purpose. (I'm actually doing exactly this for now until I can override the dependencies)
Is there a way to override the dependencies explicitly in the .nuspec
?
EDIT:
Incorporating developmentDependency
this almost worked. I'm using dependency groups in the nuspec and for some reason nuget is flattening it after packing (of course only when packing the csproj). So this: (just for demonstration)
<dependencies>
<group>
<dependency id="Some.Core" version="0.1.0" />
</group>
<group targetFramework="net4">
<dependency id="Microsoft.Bcl.Async" version="1.0.168" />
</group>
<group targetFramework="net45">
<dependency id="Some" version="0.1.0" />
</group>
</dependencies>
becomes this:
<dependencies>
<dependency id="Some.Core" version="0.1.0" />
<dependency id="Microsoft.Bcl.Async" version="1.0.168" />
<dependency id="Some" version="0.1.0" />
</dependencies>
And because of that, when using the same package as dependency in different groups an error shows up when packing:
An item with the same key has already been added.