Giter Site home page Giter Site logo

Transitive package reference from project reference ignores Copy Local/Private setting for .Net Framework projects. about msbuild HOT 5 CLOSED

General-Fault avatar General-Fault commented on June 11, 2024
Transitive package reference from project reference ignores Copy Local/Private setting for .Net Framework projects.

from msbuild.

Comments (5)

KalleOlaviNiemitalo avatar KalleOlaviNiemitalo commented on June 11, 2024 1

One workaround is to let ProjectB copy the assemblies to the output directory, but then copy the assemblies from there to a separate directory and exclude the indirect references from that copy. Microsoft.Build.Artifacts can be used for that.

from msbuild.

JanKrivanek avatar JanKrivanek commented on June 11, 2024 1

@General-Fault No - you are right, this is a known bug in MSBuild/sdk/nuget: dotnet/sdk#1366
Closing this as duplicate now

from msbuild.

JanKrivanek avatar JanKrivanek commented on June 11, 2024

Is this a correct problem statement?: You want to influence copying of PackageReference items from the referenced project (through ProjectReference) within the referencing project. E.g. you want PackageReference items from ProjectA not to be copied to output of referencing ProjectB, but to be copied to output of referencing ProjectC.

If that's correct - I do not believe it's supported today (but I'll dig further) - but can you workaround by specifying PrivateAssets on the PackageReference items in ProjectA (so that they are excluded by referencing projects) and explicitly adding those to ProjectC (so that they are copied there)?

from msbuild.

General-Fault avatar General-Fault commented on June 11, 2024

Is this a correct problem statement?: You want to influence copying of PackageReference items from the referenced project (through ProjectReference) within the referencing project. E.g. you want PackageReference items from ProjectA not to be copied to output of referencing ProjectB, but to be copied to output of referencing ProjectC.

If that's correct - I do not believe it's supported today (but I'll dig further) - but can you workaround by specifying PrivateAssets on the PackageReference items in ProjectA (so that they are excluded by referencing projects) and explicitly adding those to ProjectC (so that they are copied there)?

Not quite... ProjectC in this case also has a reference to ProjectA and the necessary packages. In my use-case, ProjectA is a "common" assembly that includes shared interfaces. ProjectB is a runtime discoverable plugin. By the time the plugin is loaded by the ProjectC executable, the shared ProjectA.dll its dependencies have already been loaded. By this token, the PrivateAssets approach is not usable here.

What I'm trying to do here is have the output directory for ProjectB (and installer generated from those outputs) only contain assemblies that are specific to that plugin and not the "common" assemblies also used by Project A and ProjectC.

For what it's worth, I think I may have solved my own problem using <IncludeAssets>compile</IncludeAssets> in the ProjectReference tag in ProjectB. So, is the "bug" here only in my head where I simply didn't understand the intention of the MSBuild developers? Or should <Private>False</Private> imply that the dependencies of the referenced project also not be included in the output as I had expected?

from msbuild.

General-Fault avatar General-Fault commented on June 11, 2024

@KalleOlaviNiemitalo Thank you for pointing me toward Microsoft.Build.Artifacts! This probably isn't the ideal solution for the project that led to me filing this issue. However, this may solve another related challenge I'm facing.

from msbuild.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.