Skip to content
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

Creating a plugin project will copy dependencies of your plugin base to the plugins output #31636

Open
tisis2 opened this issue Apr 6, 2023 · 7 comments
Milestone

Comments

@tisis2
Copy link

tisis2 commented Apr 6, 2023

Describe the bug

i created a plugin like is described in https://learn.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support
this will still cause dependencies of your PluginBase to be copied to the output of your Plugin project. in the Plugin project <Private>false</Private> is added to avoid the dll of PluginBase being copied but its dependencies will still be copied.

i created a small sample to illustrate that issue: PluginSample.zip
here is the tree that gets built:

SolutionDirectory
|   PluginSample.sln
|
+---Plugin
|   |   ...
|   +---bin
|   |   \---Debug
|   |       \---net6.0
|   |               Plugin.deps.json
|   |               Plugin.dll
|   |               Plugin.pdb
|   |               PluginBaseDependency.dll <-------- Should not be here
|   |               PluginBaseDependency.pdb <-------- Should not be here
|   |               PluginDependency.dll
|   |               PluginDependency.pdb
|   \---obj
|       ...
|
+---PluginBase
|   |   ...
|   +---bin
|   |   \---Debug
|   |       \---net6.0
|   |               PluginBase.deps.json
|   |               PluginBase.dll
|   |               PluginBase.pdb
|   |               PluginBaseDependency.dll
|   |               PluginBaseDependency.pdb
|   \---obj
|       ...
|
+---PluginBaseDependency
|   |   ...
|   +---bin
|   |   \---Debug
|   |       \---net6.0
|   |               PluginBaseDependency.deps.json
|   |               PluginBaseDependency.dll
|   |               PluginBaseDependency.pdb
|   \---obj
|       ...
|
+---PluginDependency
|   |   ...
|   +---bin
|   |   \---Debug
|   |       \---net6.0
|   |               PluginDependency.deps.json
|   |               PluginDependency.dll
|   |               PluginDependency.pdb
|   \---obj
|       ...
|
\---PluginSampleApp
    |   ...
    +---bin
    |   \---Debug
    |       \---net6.0
    |           |   PluginBase.dll
    |           |   PluginBase.pdb
    |           |   PluginBaseDependency.dll
    |           |   PluginBaseDependency.pdb
    |           |   PluginSampleApp.deps.json
    |           |   PluginSampleApp.dll
    |           |   PluginSampleApp.exe
    |           |   PluginSampleApp.pdb
    |           |   PluginSampleApp.runtimeconfig.json
    |           \---plugins
    \---obj
        ...

since the dependencies of the PluginBase is already part of your application, they should not be copied to the output of your plugin. they should be used from your application like it is with the PluginBase itself

To Reproduce

Further technical details

  • Include the output of dotnet --info
dotnet --info
.NET SDK:
 Version:   7.0.202
 Commit:    6c74320bc3

Laufzeitumgebung:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.202\

Host:
  Version:      7.0.4
  Architecture: x64
  Commit:       0a396acafe

.NET SDKs installed:
  6.0.401 [C:\Program Files\dotnet\sdk]
  6.0.402 [C:\Program Files\dotnet\sdk]
  6.0.407 [C:\Program Files\dotnet\sdk]
  7.0.100 [C:\Program Files\dotnet\sdk]
  7.0.202 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
    • VS2022(17.5.3) and Rider but it should not matter actually
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Apr 6, 2023
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@KalleOlaviNiemitalo
Copy link
Contributor

Same result with <IncludeAssets>compile</IncludeAssets>, using .NET SDK 8.0.100-preview.1.23115.2.

dotnet/msbuild#4371 (comment) suggests setting <DisableTransitiveProjectReferences>true</DisableTransitiveProjectReferences>. That does not work here as is, because Plugin uses a type defined in PluginBaseDependency and so needs some kind of reference to it. If you add a direct reference to PluginBaseDependency as well, then it's OK:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <DisableTransitiveProjectReferences>true</DisableTransitiveProjectReferences>
    </PropertyGroup>

    <ItemGroup>
        <ProjectReference Include="..\PluginBase\PluginBase.csproj">
            <Private>false</Private>
            <ExcludeAssets>runtime</ExcludeAssets>
        </ProjectReference>

        <ProjectReference Include="..\PluginBaseDependency\PluginBaseDependency.csproj">
            <Private>false</Private>
            <ExcludeAssets>runtime</ExcludeAssets>
        </ProjectReference>
        
        <ProjectReference Include="..\PluginDependency\PluginDependency.csproj" />
    </ItemGroup>

</Project>

I do feel there should be a better way to control this, though.

@KalleOlaviNiemitalo
Copy link
Contributor

Also related dotnet/msbuild#8494 and dotnet/msbuild#8507.

@marcpopMSFT marcpopMSFT self-assigned this Apr 11, 2023
@marcpopMSFT marcpopMSFT added the needs team triage Requires a full team discussion label Jun 1, 2023
@marcpopMSFT
Copy link
Member

@nkolev92 @JonDouglas Is there a way to disable transitive package reference copy in this case? Is this a feature update needed in NuGet?

@marcpopMSFT marcpopMSFT added this to the Discussion milestone Jun 6, 2023
@nkolev92
Copy link
Contributor

nkolev92 commented Jun 9, 2023

There's no knobs for controlling transitivity in any way right now.

IE, you can't specify includeassets/excludeassets for transitive packages or anything like that.

I think I've seen related issues, but I was unable to find it.

@marcpopMSFT marcpopMSFT removed untriaged Request triage from a team member needs team triage Requires a full team discussion labels Jun 13, 2023
@marcpopMSFT marcpopMSFT modified the milestones: Discussion, Backlog Jun 13, 2023
@marcpopMSFT
Copy link
Member

Thanks. Sounds like there's no built in way to do this today. Moving to the backlog to gather additional feedback for consideration in the future.

@marcpopMSFT marcpopMSFT removed their assignment Jun 26, 2023
@Kkamikadzee
Copy link

I encountered a similar problem, the issue is in the backlog and you can’t expect a solution? Can anyone share workarounds to solve the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants