-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PackageReference should support DevelopmentDependency metadata #4125
Comments
You're aiming to have this package excluded from the output package right? |
Correct: no dependency, no embedding. |
PrivateAssets is the equivalent. <PackageReference Include="Nerdbank.GitVersioning" Version="1.5.28-rc">
<PrivateAssets>all</PrivateAssets>
</PackageReference> |
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. |
I need this as well for When a project references it, it should default the |
@emgarten we need 2 things:
|
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 |
@AArnott pack should not emit a dependency when |
Thanks, @rohit21agrawal. That was the trick. I was only running |
Great! Are we good to close this issue now? |
No. There's still the matter of |
We're seeing this as well in .NETCore/.NETStandard projects. Adding a package reference to a development dependency does not add the Repro: 1 - Create a .NETCore/.NETStandard project Result: This is a regression IMHO. |
Until this issue is fixed by the Nuget.Client team: NuGet/Home#4125 (comment)
Until this issue is fixed by the Nuget.Client team: NuGet/Home#4125 (comment)
Bug 389581:[Feedback] Installing NuGet package that is marked as a development dependency doesn't add the PrivateAssets="All" attribute to the PackageReference element |
Should this really be an install time action? Shouldn't it be part of the task? |
Agree with @davidfowl. This shouldn't be an install-time action, the task should set it when it reads the package meta-data during restore. A user may choose to override this by explicitly setting the metadata on PackageRef, but not sure why anyone would really do that. |
I think the decision to use |
Since we had to revert this change because of EF tools package broken with |
👍 re: @bording 's responses. So, gentlemen, what's the bottom line here? I contend that seamlessly supporting rolling up Because logic, so to say. |
I tried setting |
This should keep downstream dependents from having our build-time references to static analysis tools flow to them transitively. For more information, see: NuGet/Home#4125 and https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#controlling-dependency-assets. 🔄 Original Commit: https://github.com/foxguardsolutions/Pump/commit/0e7fd3c48787d7b029de8aa52967b905cf7ced4f
I also misunderstood the spec at https://learn.microsoft.com/en-us/nuget/reference/nuspec#developmentdependency. To clarify any confusion...
<!-- microsoft.sourcelink.github.nuspec -->
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
...
<developmentDependency>true</developmentDependency>
...
</metadata>
</package> SDK-style projects generate their nuspec. You can set the value of <PropertyGroup>
<DevelopmentDependency>true</DevelopmentDependency>
</PropertyGroup> or dotnet pack -p:DevelopmentDependency=true When a package manager adds a "development dependency" package as a PackageReference, the PackageReference's dotnet add package Microsoft.SourceLink.GitHub --version 8.0.0 <!-- This package was published with <developmentDependency>true</developmentDependency> in its nuspec -->
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" /> dotnet add package Newtonsoft.Json --version 13.0.3 <!-- This package was NOT published with developmentDependency set. -->
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> Adding
I also misunderstood the spec at https://learn.microsoft.com/en-us/nuget/reference/nuspec#developmentdependency. To clarify any confusion...
<!-- microsoft.sourcelink.github.nuspec -->
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
...
<developmentDependency>true</developmentDependency>
...
</metadata>
</package> SDK-style projects generate their nuspec. You can set the value of <PropertyGroup>
<DevelopmentDependency>true</DevelopmentDependency>
</PropertyGroup> or dotnet pack -p:DevelopmentDependency=true When a package manager adds a "development dependency" package as a PackageReference, the PackageReference's dotnet add package Microsoft.SourceLink.GitHub --version 8.0.0 <!-- This package was published with <developmentDependency>true</developmentDependency> in its nuspec -->
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" /> dotnet add package Newtonsoft.Json --version 13.0.3 <!-- This package was NOT published with developmentDependency set. -->
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> Adding <!-- still treated as a normal dependency -->
<PackageReference
Include="Newtonsoft.Json"
Version="13.0.3"
DevelopmentDependency="true"
/> Instead you must use <!-- treated as a development dependency -->
<PackageReference
Include="Newtonsoft.Json"
Version="13.0.3"
PrivateAssets="all"
ExcludeAssets="compile"
/>
|
msbuild /t:pack
fails when building a stable versioned package that depends on an unstable one, even though that unstable one is a DevelopmentDependency:msbuild /t:pack
Build fails with a crashed MSBuild task with this message:
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.The text was updated successfully, but these errors were encountered: