Open joeltankam opened 5 years ago
Any update on the topic please ?
You could use <DisableTransitiveProjectReferences>true</DisableTransitiveProjectReferences>
to turn this off for Project to project references.
Ok, thanks. I'll try that.
@livarcocc <DisableTransitiveProjectReferences>true</DisableTransitiveProjectReferences>
works fine as far as compilation is concerned.
However, ProjectA
is still present in ProjectC
asset file (same as mentioned in the description); which is a false information since this dependency doesn't exist anymore at compile time.
Any update please ?
<DisableTransitiveProjectReferences>true</DisableTransitiveProjectReferences>
and
<Private>false</Private>
<ExcludeAssets>all</ExcludeAssets>
seems to work to me
You could use
<DisableTransitiveProjectReferences>true</DisableTransitiveProjectReferences>
to turn this off for Project to project references.
@thank you @livarcocc It works perfect. Do you know if there is any documentation for this settings? I cannot find anything. I also don't know when it was introduced (in which version of MSBuild/SDK/VisualStudio?)
Not sure if you are the right person to ask, but just to clarify I have some questions:
So this DisableTransitiveProjectReferences
setting changes ProjectReference
behavior in new SDK-csproj to be the same as in old csproj where ProjectReference
wasn't transitive but the transitive projects' .dlls
were copied to bin
folder ?
Is the effect the same as setting PrivateAssets="All"
on all the dependencies of dependand project? Just that with DisableTransitiveProjectReferences
you control this behavior in different place, on project that reference other projects, not on project that might be referenced by other projects.
In other word PrivateAssets="All"
is more flexible and fine-grained and you can achieve the same end result like with DisableTransitiveProjectReferences
but DisableTransitiveProjectReferences
is just more useful if you prefer "old non-SDK csproj" non-transitive behavior of ProjectReference
s (or if you are in process of migrating to .NET Core or SDK-style csproj)
I had put a community item in about the bahaviour of mixed C++/CLI, C# solutions that seems related to this https://developercommunity.visualstudio.com/t/Transitive-usage-of-nuget-package-types/1424201 I was wondering if someone knows what the behaviour should be for .vcxproj projects. If it is meant to be non-transitive is there a flag to make it transitive as that is what I needed.
Any update on this question? Is this intended but undocumented?
However, these metadatas are originally applicable only for PackageReference and I can't find any documentation of this behavior for ProjectReference (in the ProjectReference item reference for example). So, should this (PrivateAssets or ExcludeAsssets) be really used in ProjectReference tag ?
Steps to reproduce
Let's consider these 3 project files :
ProjectA
ProjectB
ProjectC
The 3 projects depends on each other as follows :
ProjectC -(depends on)-> ProjectB -> ProjectA
Expected behavior
ProjectC
should not be able to use elements fromProjectA
(public classes for example) since it doesn't reference this project directly.Actual behavior
ProjectC
has access toProjectA
via transitivity as it can be seen in his assets file :As mentioned in https://github.com/dotnet/project-system/issues/2313, it appears that this behavior can be cancelled by using
PrivateAssets
, fromPackageReference
dependency assets, when referencingProjectA
:Using
ExcludeAssets
when referencingProjectB
also works :However, these metadatas are originally applicable only for
PackageReference
and I can't find any documentation of this behavior forProjectReference
(in theProjectReference
item reference for example). So, should this (PrivateAssets
orExcludeAsssets
) be really used inProjectReference
tag ?Environment data
msbuild /version
output: 15.9.21.664 Visual Studio : Professional 2017, version 15.9.15