NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

Dotnet Add package - configure private assets #7755

Open mairaw opened 5 years ago

mairaw commented 5 years ago

Original GitHub issue https://github.com/dotnet/docs/issues/5968 from @Meberem

Is there a way to configure the PrivateAssets attirbute that this command creates? I wanted to add https://github.com/ctaggart/SourceLink#all-source-files to a number of projects and making the PrivateAssets flag scriptable would be really handy


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

nkolev92 commented 5 years ago

It's not possible right now. I'll consider this is a feature request for the scenario.

//cc @anangaur @rrelyea @kathleendollard

anangaur commented 5 years ago

If the SourceLink packages are published with DevDependency = true, wouldn’t we auto add the PrivateAssets flag to PackageReference?

KathleenDollard commented 5 years ago

If you provide support for this at the NuGet level, we would consider a CLI change to support, so feel free to create that issue as you consider this.

nkolev92 commented 5 years ago

If the SourceLink packages are published with DevDependency = true, wouldn’t we auto add the PrivateAssets flag to PackageReference?

Yes, it will add it PrivateAssets=all if it's a dev dependency.

The option could be useful for the general scenario.

anangaur commented 5 years ago

@tmat can you add devdependency flag to SourceLink packages? I think that would definitely help developers to not auto expose SourceLink as a dependency upwards.

anangaur commented 5 years ago

I agree on the general usecase but not sure how critical or costly the issue fix is. I do see, however, more and more people using SourceLink to get the snupkg and source code info generated for their packages automatically.

tmat commented 5 years ago

SourceLink packages have <developmentDependency>true</developmentDependency> in nuspec.

I think the problem is that it's only picked up when the package is added via UI, or perhaps into a project via dotnet CLI.

But pretty common use case is that the package reference is added manually to Directory.Build.props file that's in the repo root, so that all projects automatically get it.

tmat commented 5 years ago

BTW there might also be a bit of confusion between @ctaggart's SourceLink packages and ours. The link https://github.com/ctaggart/SourceLink#all-source-files points to @ctaggart's packages.

tmat commented 5 years ago

@KathleenDollard Have you though about supporting adding package references to Directory.Build.props via CLI?