-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
'Private' metadata is not propagated to transitive dependencies #1366
Comments
Note: this is not a partner blocking issue. @nguerrera helped me out with a work around here. For the VSIX projects we can just override the IncludeTransitiveProjectReferences target to do nothing. Still would be nice to have this fixed at some point. |
So private assets on the project reference did not work? |
I mean PrivateAssets=All |
@nguerrera I tried that but looking back at your message I worry I may have done it incorrectly. What I tried was adding the following to the ProjectReference node: <PrivateAssets>All</PrivateAssets> Your message suggested the following <ItemDefinitionGroup>
<ProjectReference>
<PrivateAssets>All</PrivateAssets>
</ProjectReference>
</ItemDefinitionGroup> Not sure if that makes a difference or not. |
I expected either to work. The definition group was just a way to apply it to all project references. |
The IDG would apply it to all ProjectReference items, even those dynamically created by NuGet. My guess is that NuGet isn't propagating that metadata from the reference to its transitive closure when it dynamically discovers/inserts the closure (based only on this issue, opinion unsullied by looking at any code). |
Here is the work around we employed |
Note there are two pieces of metadata with similar names and different meanings. Private and PrivateAssets. My expectation was that PrivateAssets (read by NuGet not build) would impact the assets file such that transitive project references would be suppressed coming through that reference. But I realize now that private assets decides whether a reference flows to your consumers, not that you want to consume something but not its dependencies. IDG for Private=false might work, but it's not the semantic we're after. We're trying to prevent extra project references from being raised, not to raise them with Private=false. |
@nguerrera from within the SDK, overriding the target seems like the best way. The only other way would be to take a direct dependency on each offending implicit project reference, and set them all to private. |
By default the new SDK will cause projecs to reference the full transitive closure of project references, not just the direct references. This is fine in most cases but caused breaks in our VSIX projects. Our VSIX projects often reference project with specific extra metadata to control whether or not their contents are included in the final VSIX. That extra metadata is not applied to projects which are implicitly referenced by the new SDK. That caused our VSIX to bloat in size and have functionally incorrect contents. Fixed this by disabling implicit transitive references for our VSIX projects. dotnet/sdk#1366
Wow I just lost hours on this issue. My fix was to not only set Private to false like @nguerrera suggested, but also ExcludeAssets on the ProjectReference element. PrivateAssets did not seem to do anything. My scenario is with a project that provides a API for a plugin implementation. The API assembly (and it's dependencies) must never be copied to the output folder of the plugin. My final file ended up something like this:
(Also found this similar to #952 but with dependencies) Now the big challenge will be how to enforce this to always be set and no developers make mistakes :( Edit: this doesn't seem very consistent with the ExcludeAssets semantic on PackageReferences, since I had a similar situation there and add to change the "all" to "runtime" so it would still let me compile against it. So changed these as well to ExcludeAssets="runtime" to make them consistent in my projects and it seems to be enough. |
This is also an issue for VS for Mac. Here are my notes, in case it's helpful:
And here's my workaround: <Target Name="_MakeTransitiveProjectRefsNonPrivate" AfterTargets="IncludeTransitiveProjectReferences">
<ItemGroup>
<!-- remove the transitive project references and re-add them as non-private project references -->
<ProjectReference Remove="@(_TransitiveProjectReferences)" />
<ProjectReference Include="@(_TransitiveProjectReferences)" Private="False" />
</ItemGroup>
</Target> |
I suspect there isn't enough information in the assets file today to raise the transitive refs correctly in this case. We likely need to coordinate the fix with nuget. |
Is there any workaround for this problem ? I am using the new sdk project format, and I have a transitive dependency between my ProjectReferences (A => B => C). A references B with Private=true and B references C with Private=true. Currently, when I build project A, I have A and C assemblies in my output folder. I have two requirements:
Any idea? Thanks, |
For developing Plugins/Extensions just like VSIX but for other Applications, there should be an easier way to Disable Transitive references throughout the entire reference graph. Why wasn't this enabled at first when you guys implemented |
This was discovered moving Roslyn's VSIX projects to the new SDK.
Roslyn builds a number of VSIX projects and is very particular about which projects end up embedded in which VSIX. There are a number of patterns employed to accomplish this including
The intent here is to reference the project but not include its contents in the resulting VSIX by means of
<Private>false</Private>
. This continues to work in the new SDK.However implicit transitive references ends up pulling in all of the projects that ServicesVisualStudioImpl.csproj. None of those projects are marked as
<Private>false</Private>
and as a result end up included in the VSIX. This both bloats (in some cases 100 fold) and functionally breaks our VSIX (some cases 100 fold).The text was updated successfully, but these errors were encountered: