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
Allow package authors to define build assets which work transitively (using buildTransitive assets group) #6091
In summary, having a way to include compile in private assets as default unless project/package needs to expose it, i.e.: PrivateAssets="compile;contentfiles;analyzers;build" (I checked what the implicit default is and it seems to be contentfiles;analyzers;build).
We are considering bringing developmentDependency back, which should allow the author of PackageA to affect the default flowing behavior for the dependencies of PackageA.
PrivateAssets is basically a transitive flow control for the consumer of the package, while DevelopmentDependency would be a transitive flow control for the author the package.
@nkolev92 It's similar to development dependency but more general. If I am using a package like Newtonsoft.Json in my package, I don't want it to be exported to consumers of my package unless I explicitly need to (or I'm creating a meta-package). It's more like a runtimeDependency rather than an apiDependency.
I wouldn't want Newtonsoft.Json to be part of the contract of my package because some day I might move to a different Json library.
Just re-read the second bit of your comment. Perhaps I am mistaken, I haven't ever used DevelopmentDependency, but have assumed it is only for stopping dependencies going anywhere, i.e. PrivateAssets="All" which would be too extreme in my case as they are runtime dependencies that need to go up the chain and into bin folder.
changed the title [-]Consider changing the default transitive flowing behavior of the build assets[/-][+]Change the default behavior of build dependency asset to transitive[/+]on Nov 28, 2017
I think this is a good feature, worth pursuing, and one I wish we had from the beginning.
But since its a breaking change, my knee-jerk reaction to reading the spec on this is that it could cause compatibility issues with existing packages, like some of the ones we shipped in ASP.NET Core 1.0. They contain build props/targets written under the assumption that they only apply to one project file. For example, some using Microsoft.Extensions.Configuration.UserSecrets 1.x would get new build warnings. It may also cause some Visual Studio issues where it uses MSBuild properties set via PackageReference to change behavior (a feature I'm currently working on.)
Since this is a breaking change, we need to provide a switch for consumers to change back the dependency asset behavior.
Can you comment more on current thinking for this open question?
Related question: how would a user know they need to change back? New build errors are actually good. They force a user to figure out what changed. The more pernicious bugs will happen because some builds will continue working without failures/warnings, but the output of the build will change. i.e. new files in output, different build properties will be set, etc. How would we expect a user to figure out what caused these behavior changes?
My general feel for the the design of .props and .targets ingestion is that this should be considered an escape hatch for advanced package authoring so that cases like @onovotny where conventions don't work the developer has a 100% control. For this to work, they build scripts must flow across P2P, so I'm highly supportive of this change.
As a side note, have you opened this issue against dotnet/sdk? I think they would be interested in this feedback on the wpf/winforms problems.
Yes, we should discuss this more but this problem doesn't have good solutions IMHO. It either requires making WPF/WinForms a different TFM, inventing some new profile mechanism, or generalizing RIDs so that people can vary API surface based on them. Personally, I think Oren's scenario where a developer needs to inject different code based on whether the project references WPF/WinForms is rare -- and I think are also likely indicators of bugs in the library. In Oren's case the library depends on UI controls. This hasn't bitten anyone in .NET Framework because everything is there, all the time. But technically this was always a very clear layer violation.
Curious if you considered a bit in the nuspec metadata to indicate this behavior rather than forcing folks to copy their files into different directories. Your spec calls out that folks essentially need to duplicate the buildTransitive folder anyhow to work with old clients/packages.config. Seems to me like its a non-goal to enable folks to have different content in build and buildTransitive but giving them this option opens up that possibility.
It would've been contentFiles like, where there is still no way to configure all the switches like language.
The precedent with duplication played a role in the decision.
Not sure if/where that write-up is.
Not sure how much @jainaashish looks at GitHub these days to help with some pointers.
We indeed discussed multiple solutions while designing this feature and one such case was to introduce a flag in nuspec. All discussed solutions might still be there in Spec PR in Engineering private repo. But as far as i remember nuspec solution was not suitable for a) if you need both transitive and non-transitive build assets in a packae (which was a real usecase for some customers) and b) would not have worked for packages.config.
changed the title [-]Allow package authors to define build assets transitive behavior[/-][+]Allow package authors to define build assets which work transitively (using buildTransitive assets group)[/+]on Jan 27, 2020
Activity
mungojam commentedon Nov 17, 2017
Feels related: this discussion
In summary, having a way to include compile in private assets as default unless project/package needs to expose it, i.e.:
PrivateAssets="compile;contentfiles;analyzers;build"(I checked what the implicit default is and it seems to be contentfiles;analyzers;build).nkolev92 commentedon Nov 17, 2017
@mungojam
I think #4125 covers what you're articulating.
We are considering bringing developmentDependency back, which should allow the author of PackageA to affect the default flowing behavior for the dependencies of PackageA.
PrivateAssets is basically a transitive flow control for the consumer of the package, while DevelopmentDependency would be a transitive flow control for the author the package.
mungojam commentedon Nov 17, 2017
@nkolev92 It's similar to development dependency but more general. If I am using a package like Newtonsoft.Json in my package, I don't want it to be exported to consumers of my package unless I explicitly need to (or I'm creating a meta-package). It's more like a runtimeDependency rather than an apiDependency.
I wouldn't want Newtonsoft.Json to be part of the contract of my package because some day I might move to a different Json library.
It feels like this should be the default somehow.
mungojam commentedon Nov 17, 2017
Just re-read the second bit of your comment. Perhaps I am mistaken, I haven't ever used DevelopmentDependency, but have assumed it is only for stopping dependencies going anywhere, i.e. PrivateAssets="All" which would be too extreme in my case as they are runtime dependencies that need to go up the chain and into bin folder.
[-]Consider changing the default transitive flowing behavior of the build assets[/-][+]Change the default behavior of build dependency asset to transitive[/+]natemcmaster commentedon Jan 11, 2018
I think this is a good feature, worth pursuing, and one I wish we had from the beginning.
But since its a breaking change, my knee-jerk reaction to reading the spec on this is that it could cause compatibility issues with existing packages, like some of the ones we shipped in ASP.NET Core 1.0. They contain build props/targets written under the assumption that they only apply to one project file. For example, some using Microsoft.Extensions.Configuration.UserSecrets 1.x would get new build warnings. It may also cause some Visual Studio issues where it uses MSBuild properties set via PackageReference to change behavior (a feature I'm currently working on.)
The spec currently says:
Can you comment more on current thinking for this open question?
Related question: how would a user know they need to change back? New build errors are actually good. They force a user to figure out what changed. The more pernicious bugs will happen because some builds will continue working without failures/warnings, but the output of the build will change. i.e. new files in output, different build properties will be set, etc. How would we expect a user to figure out what caused these behavior changes?
cc @davidfowl
37 remaining items
terrajobst commentedon Jan 25, 2019
My general feel for the the design of .props and .targets ingestion is that this should be considered an escape hatch for advanced package authoring so that cases like @onovotny where conventions don't work the developer has a 100% control. For this to work, they build scripts must flow across P2P, so I'm highly supportive of this change.
Yes, we should discuss this more but this problem doesn't have good solutions IMHO. It either requires making WPF/WinForms a different TFM, inventing some new profile mechanism, or generalizing RIDs so that people can vary API surface based on them. Personally, I think Oren's scenario where a developer needs to inject different code based on whether the project references WPF/WinForms is rare -- and I think are also likely indicators of bugs in the library. In Oren's case the library depends on UI controls. This hasn't bitten anyone in .NET Framework because everything is there, all the time. But technically this was always a very clear layer violation.
xen2 commentedon Jan 27, 2019
Great, we can finally get rid of those custom
PrivateAssets!Will this make it only in VS 2019 or also in a VS 2017 update?
jainaashish commentedon Jan 28, 2019
For now, this will only be in VS 2019 (starting with VS 2019 preview3)
ericstj commentedon Apr 25, 2019
Curious if you considered a bit in the nuspec metadata to indicate this behavior rather than forcing folks to copy their files into different directories. Your spec calls out that folks essentially need to duplicate the buildTransitive folder anyhow to work with old clients/packages.config. Seems to me like its a non-goal to enable folks to have different content in build and buildTransitive but giving them this option opens up that possibility.
nkolev92 commentedon Apr 25, 2019
@ericstj
We did consider the nuspec option, but it would've led to an unenvious pack experience.
Having both build/buildTransitive imported was a non-goal at that point.
ericstj commentedon Apr 25, 2019
What does "unenvious pack experience" mean? If you can point me to that discussion I'll read up rather than rehash stuff here.
nkolev92 commentedon Apr 25, 2019
It would've been contentFiles like, where there is still no way to configure all the switches like language.
The precedent with duplication played a role in the decision.
Not sure if/where that write-up is.
Not sure how much @jainaashish looks at GitHub these days to help with some pointers.
jainaashish commentedon Apr 26, 2019
We indeed discussed multiple solutions while designing this feature and one such case was to introduce a flag in nuspec. All discussed solutions might still be there in Spec PR in Engineering private repo. But as far as i remember nuspec solution was not suitable for a) if you need both transitive and non-transitive build assets in a packae (which was a real usecase for some customers) and b) would not have worked for packages.config.
[-]Allow package authors to define build assets transitive behavior[/-][+]Allow package authors to define build assets which work transitively (using buildTransitive assets group)[/+][Assets] Make sure to explicitly include Xenko.Core for its targets u…