You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PackageReference should support DevelopmentDependency metadata #4125
msbuild /t:pack fails when building a stable versioned package that depends on an unstable one, even though that unstable one is a DevelopmentDependency:
Build fails with a crashed MSBuild task with this message:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): error MSB4018:
The "PackTask" task failed unexpectedly.\r [C:\Users\andre\OneDrive\Documents\Visual Studio 2017\Projects\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): error MSB4018: System.IO.InvalidDataException: A stable release of a package should not have a prerelease dependency. Either modify the version spec of dependency "Nerdbank.GitVersionin
g [1.5.61-ga5f362ccc1, )" or update the version field in the nuspec.\r [C:\Users\andre\OneDrive\Documents\Visual Studio 2017\Projects\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj]
In fact I shouldn't even have to specify DevelopmentDependency="true" in my reference because the nuspec of the referenced package itself has that property set.
Reacted by Sergey Shandar, Christian Gunderman, Moily, Jeff Hotchkiss, John Crim, Immo Landwerth, Legacy Eben Zhang 4 Pull Request Search, jp2masa, Karan Nandwani, Nico Jansen and 7 more
Thanks @emgarten. Should that be a default then when the package's own nuspec sets DevelopmentDependency=true?
Also, I'm guessing that's not quite equivalent to what we have in project.json (in an MSBuild project). I can add a package dependency to a developmentDependency package and that propagates across project references (as I usually want), yet that doesn't limit my ability to compile those projects into stable packages that don't depend on it. Your PrivateAssets=all metadata suggests to me that it won't propagate across P2Ps.
Reacted by Sergey Shandar, Michael Hallock, Michael Conrad, Tomáš Matoušek, Rudi Visser, Jaroslav Malec, Nirmal Guru, glopesdev, Giorgi Chakhidze and James Brooke
I need this as well for GitVersionTask for the same reason. The GitVersionTask nuspec has developmentDependency set to true.
When a project references it, it should default the <PrivateAssets>all</PrivateAssets> metadata on that package ref...or whatever is needed to ensure it doesn't get added to the generated nuspec with /t:pack
Reacted by Asbjørn Ulsberg, Márton Balassa, Matt B and Paulo Morgado
We need a way for a package to express what assets get exported when referenced in a project .e.g If I want all projects that reference me to have effectively <PrivateAssets>all</PrivateAssets> by default then I should be able to express that in the nuspec.
We should infer developmentDependency set to true as implicitly saying <PrivateAssets>all</PrivateAssets> .
Reacted by Andrew Arnott, Claire Novotny, Marius Gundersen, Asbjørn Ulsberg, Julian Dominguez, Mohamed Hassan, Daniel Sturm, Jaroslav Malec, Nirmal Guru, Giorgi Chakhidze and 1 more
Can we at a minimum for Dev15 RTW get developmentDependency=true in a nuspec file to be honored by having the dotnet SDK project type not propagate the dependency in nuget packages it packs?
@davidfowl points out that PrivateAssets=all at the consuming side should workaround this issue. This is also consistent with the documentation. But I tried it, and the dotnet pack step still emits a package dependency on it (with the default exclude="Build,Analyzers" attribute no less).
@AArnott pack should not emit a dependency when <PrivateAssets>all</PrivateAssets> is specified. Did you make sure you restored after you added the <PrivateAssets> tag to your dependency? Pack relies on reading the dependencies and their metadata from the assets file, so if the assets file doesn't reflect your changes, pack wouldn't know about them.
No. There's still the matter of developmentDependency being ignored that should have set PrivateAssets=all by default, which @davidfowl seems to agree with as well.
Reacted by Claire Novotny, Brice Lambson, David Fowler, Asbjørn Ulsberg and Jeremy Koritzinsky
@AArnott
Packages can still be both today. There's nothing enforcing that today. It won't work because of the tangential problem because of how build assets transitive flow is handled today, but it's still possible.
But as you point out, in our case they are different.
There's no point in fragmenting this experience among PR/MsBuildSDKs.
The MSBuildSDKs is the correct approach, because itself participates in restore, which allows for a more comprehensive experience.
Additionally, there's no enforcement on whether development dependency marked packages bring in developmen dependencies themselves.
If they bring in some runtime dependencies, and the consumer accidentally uses those, it'll break the package when packed later on.
Sdks don't have that since they have to be self-contained.
Additionally with development dependency we would introduce a needless basic feature discrepancy among VS and commandline which we've worked very hard not to do.
We are basically adding an install gesture in PR, which is currently non-existent (other than in name ofc)
Since we had to revert this change because of EF tools package broken with ExcludeAssets=Runtime, I'm reopening this issue. We'll bring it back in 15.8 with more validations.
So, gentlemen, what's the bottom line here? I contend that seamlessly supporting rolling up developmentDependencies is desirable, with a minimum of files or other assets that I need to touch, whether by hand of via tooling of any kind. PrivateAssets, etc, just introduces a lower signal to noise ratio, IMO, i.e. makes it harder, not easier, to discern whether a dependency ought to be rolled up in the NuGet package.
When a package manager adds a "development dependency" package as a PackageReference, the PackageReference's PrivateAssets is set to all and compile is removed from IncludeAssets if applicable. compile assets refer to binaries in a package's lib directory.
<!-- This package was published with <developmentDependency>true</developmentDependency> in its nuspec -->
<PackageReferenceInclude="Microsoft.SourceLink.GitHub"Version="8.0.0"PrivateAssets="all" />
When a package manager adds a "development dependency" package as a PackageReference, the PackageReference's PrivateAssets is set to all and compile is removed from IncludeAssets if applicable. compile assets refer to binaries in a package's lib directory.
<!-- This package was published with <developmentDependency>true</developmentDependency> in its nuspec -->
<PackageReferenceInclude="Microsoft.SourceLink.GitHub"Version="8.0.0"PrivateAssets="all" />
<!-- This package was NOT published with developmentDependency set. -->
<PackageReferenceInclude="Newtonsoft.Json"Version="13.0.3" />
Adding DevelopmentDependency="true" or developmentDependency="true" to a PackageReference will do nothing.
<!-- still treated as a normal dependency -->
<PackageReferenceInclude="Newtonsoft.Json"Version="13.0.3"DevelopmentDependency="true"
/>
Instead you must use PrivateAssets="all" ExcludeAssets="compile".
<!-- treated as a development dependency -->
<PackageReferenceInclude="Newtonsoft.Json"Version="13.0.3"PrivateAssets="all"ExcludeAssets="compile"
/>
ExcludeAssets="compile" is unnecessary if the package does not contain any libs i.e. the nupkg does not have a "libs" directory. If the package has no compile assets, then it doesn't matter if the compile assets are included. Likewise, package managers won't modify the IncludeAssets of a development dependency if there are no libs to exclude—despite the example indicating IncludeAssets is modified regardless. It better serves as an example of a development dependency that mistakenly includes libs, thereby requiring its compile assets (libs) to be excluded.
Activity
davidfowl commentedon Dec 18, 2016
You're aiming to have this package excluded from the output package right?
AArnott commentedon Dec 18, 2016
Correct: no dependency, no embedding.
And thus no restriction on using unstable packages while building a stable one.
emgarten commentedon Dec 18, 2016
PrivateAssets is the equivalent.
AArnott commentedon Dec 18, 2016
Thanks @emgarten. Should that be a default then when the package's own nuspec sets DevelopmentDependency=true?
Also, I'm guessing that's not quite equivalent to what we have in project.json (in an MSBuild project). I can add a package dependency to a developmentDependency package and that propagates across project references (as I usually want), yet that doesn't limit my ability to compile those projects into stable packages that don't depend on it. Your PrivateAssets=all metadata suggests to me that it won't propagate across P2Ps.
clairernovotny commentedon Dec 21, 2016
I need this as well for
GitVersionTaskfor the same reason. The GitVersionTask nuspec hasdevelopmentDependencyset to true.When a project references it, it should default the
<PrivateAssets>all</PrivateAssets>metadata on that package ref...or whatever is needed to ensure it doesn't get added to the generated nuspec with/t:packdavidfowl commentedon Dec 21, 2016
@emgarten we need 2 things:
<PrivateAssets>all</PrivateAssets>by default then I should be able to express that in the nuspec.developmentDependencyset to true as implicitly saying<PrivateAssets>all</PrivateAssets>.AArnott commentedon Feb 16, 2017
Can we at a minimum for Dev15 RTW get developmentDependency=true in a nuspec file to be honored by having the dotnet SDK project type not propagate the dependency in nuget packages it packs?
AArnott commentedon Feb 17, 2017
@davidfowl points out that
PrivateAssets=allat the consuming side should workaround this issue. This is also consistent with the documentation. But I tried it, and thedotnet packstep still emits a package dependency on it (with the defaultexclude="Build,Analyzers"attribute no less).rohit21agrawal commentedon Feb 17, 2017
@AArnott pack should not emit a dependency when
<PrivateAssets>all</PrivateAssets>is specified. Did you make sure you restored after you added the<PrivateAssets>tag to your dependency? Pack relies on reading the dependencies and their metadata from the assets file, so if the assets file doesn't reflect your changes, pack wouldn't know about them.AArnott commentedon Feb 17, 2017
Thanks, @rohit21agrawal. That was the trick. I was only running
dotnet packafter my change rather than a restore as well.rohit21agrawal commentedon Feb 17, 2017
Great! Are we good to close this issue now?
AArnott commentedon Feb 17, 2017
No. There's still the matter of
developmentDependencybeing ignored that should have set PrivateAssets=all by default, which @davidfowl seems to agree with as well.67 remaining items
nkolev92 commentedon Mar 12, 2018
@AArnott
Packages can still be both today. There's nothing enforcing that today. It won't work because of the tangential problem because of how build assets transitive flow is handled today, but it's still possible.
But as you point out, in our case they are different.
There's no point in fragmenting this experience among PR/MsBuildSDKs.
The MSBuildSDKs is the correct approach, because itself participates in restore, which allows for a more comprehensive experience.
Additionally, there's no enforcement on whether development dependency marked packages bring in developmen dependencies themselves.
If they bring in some runtime dependencies, and the consumer accidentally uses those, it'll break the package when packed later on.
Sdks don't have that since they have to be self-contained.
Additionally with development dependency we would introduce a needless basic feature discrepancy among VS and commandline which we've worked very hard not to do.
We are basically adding an install gesture in PR, which is currently non-existent (other than in name ofc)
bricelam commentedon Mar 26, 2018
I think the decision to use
ExcludeAssets="Runtime"has some unintended consequences. See dotnet/efcore#11437jainaashish commentedon Apr 3, 2018
Since we had to revert this change because of EF tools package broken with
ExcludeAssets=Runtime, I'm reopening this issue. We'll bring it back in 15.8 with more validations.mwpowellhtx commentedon May 13, 2018
👍 re: @bording 's responses.
So, gentlemen, what's the bottom line here? I contend that seamlessly supporting rolling up
developmentDependenciesis desirable, with a minimum of files or other assets that I need to touch, whether by hand of via tooling of any kind.PrivateAssets, etc, just introduces a lower signal to noise ratio, IMO, i.e. makes it harder, not easier, to discern whether a dependency ought to be rolled up in the NuGet package.Because logic, so to say.
bugproof commentedon Jun 27, 2019
I tried setting
developmentDependencyto true and it doesn't work. OnlyPrivateAssetswork.nkolev92 commentedon Jun 27, 2019
@wrathofodin https://github.com/NuGet/Home/wiki/DevelopmentDependency-support-for-PackageReference
🔄 🏗🐛 Prevents Transitive Flow of Development-Only NuGet Dependencies
BinToss commentedon Jul 25, 2024
I also misunderstood the spec at https://learn.microsoft.com/en-us/nuget/reference/nuspec#developmentdependency.
To clarify any confusion...
<developmentDependency>true</developmentDependency>in a package's nuspec indicates to package managers that the package is a development dependency. See https://learn.microsoft.com/en-us/nuget/reference/nuspec#developmentdependency.SDK-style projects generate their nuspec. You can set the value of
developmentDependencyvia the MSBuild propertyDevelopmentDependency. See https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#pack-target-inputs.or
When a package manager adds a "development dependency" package as a PackageReference, the PackageReference's
PrivateAssetsis set toallandcompileis removed fromIncludeAssetsif applicable.compileassets refer to binaries in a package'slibdirectory.Adding
DevelopmentDependency="true"ordevelopmentDependency="true"to a PackageReference will do nothing.I also misunderstood the spec at https://learn.microsoft.com/en-us/nuget/reference/nuspec#developmentdependency.
To clarify any confusion...
<developmentDependency>true</developmentDependency>in a package's nuspec indicates to package managers that the package is a development dependency. See https://learn.microsoft.com/en-us/nuget/reference/nuspec#developmentdependency.SDK-style projects generate their nuspec. You can set the value of
developmentDependencyvia the MSBuild propertyDevelopmentDependency. See https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#pack-target-inputs.or
When a package manager adds a "development dependency" package as a PackageReference, the PackageReference's
PrivateAssetsis set toallandcompileis removed fromIncludeAssetsif applicable.compileassets refer to binaries in a package'slibdirectory.Adding
DevelopmentDependency="true"ordevelopmentDependency="true"to a PackageReference will do nothing.Instead you must use
PrivateAssets="all" ExcludeAssets="compile".ExcludeAssets="compile"is unnecessary if the package does not contain any libs i.e. the nupkg does not have a "libs" directory. If the package has no compile assets, then it doesn't matter if the compile assets are included. Likewise, package managers won't modify the IncludeAssets of a development dependency if there are no libs to exclude—despite the example indicating IncludeAssets is modified regardless. It better serves as an example of a development dependency that mistakenly includes libs, thereby requiring itscompileassets (libs) to be excluded.