3

.Net Core 1.1 introduced convenient feature of reference inheritance and it seems to be the same for 2.0.

While usually nice to have it gives me some problems, or maybe bugs, with transient references ignoring "Copy Local" set to false.

I can disable this feature with PrivateAssets directive or by overriding it with direct reference, but I do not want to disable it as me and my team like this feature. Additionally, as it is default behavior of NetCore, it will be quite bothersome to "fix" (and keep "fixed") in huge solution.

<UseCommonOutputDirectory>true</UseCommonOutputDirectory> is not really a solution, as it will break CopyLocal=true, and it still will require modifications in every project file which will be bothersome to maintain.

Basically I have this:

solution

With CopyLocal=false wherever I can:

enter image description here

Which allows me to do this without adding hordes of additional references:

using A;
using B;
using System;

namespace TransientRefTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Aclass aa = new Aclass();
            Bclass bb = new Bclass();
            Console.WriteLine("Hello World!");
        }
    }
}

But B still gets copied to output directory:

enter image description here

which leads clutter in output directory and nasty surprises with obsolete binary being loaded (dynamically loaded plugin architecture)

Is this a bug or a feature? Can I get CopyLocal=false to be respected with Transient References? If what I want is not possible for whatever reason, is there some easy way to disable transitive references solution-wide?

Please have in mind that due to release dates of .NET Core questions from before 2016 might be not related to NetCore issues.

PTwr
  • 1,225
  • 1
  • 11
  • 16

0 Answers0