Before this gets flagged as dupe - I did find this question and tried that and it didn't work
This is all happening in Test projects the methods in question are being called as they have the OneTimeSetup attribute - not sure if relevent but the more info the better right
Project A
References - System.Collections.Immutable v 1.3.33 - a dependency of using ScriptCs but also utilised directly in code cs proj has this entry
<Reference Include="System.Collections.Immutable, Version=1.1.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <HintPath>......\packages\ScriptCs.Engine.Roslyn.0.16.1\lib\net45\System.Collections.Immutable.dll</HintPath>
<Private>True<<Private> </Reference>
Project A contains a Base Class
[SetUpFixture]
public abstract class BaseClass
{
[OneTimeSetup]
public void DoSomething()
{
var MyClass = new MyClass();
MyClass.DoStuff();
//etc etc
}
}
it also contains the class MyClass - this class directly uses types from System.Collections.Immutable
public class MyClass
{
private ImmutableDictionary<string,string> myImmutableDictionary = ImmutableDictionary.Create<string,string>();
public void DoStuff()
{
//does things
}
}
Project B - Has no direct reference to System.Immutable.Collections - Has project reference to Project A
In project B we have a class that inherits from BaseClass in project B
[SetUpFixture]
public class SubClass : BaseClass
{
[OneTimeSetup]
public void SomeMethod()
{
DoSomething(); //Here it goes bang
}
}
So we were alerted to an issue where all our tests on the build server where failing for the same reason
Could not load file or assembly 'System.Collections.Immutable, Version=1.1.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
I ran this locally and got the same issue. I investiaged the output folder for Project B and to my surprise it did not contain 'System.Collections.Immutable.dll' - hence why it couldn't find it.
A collegue of mine ran them on their machine and the tests did run and we looked in their output folder of Project B and even more surprisingly there was a 'System.Collections.Immutable.dll' file there. HOWEVER... it was not the version that was found in Project A's output folder (1.1.33) it was 4.x.x - I'm thinking this came from the GAC but due to someother oddity we couldn't confirm if they had that dll in their GAC
So my mind was a bit blown
My understanding is the MSBuild takes the dll from the GAC as a last resort and the Hint path should be used first (Yes I checked the dll is present where the hint path is pointing too)
So..
- Why is the System.Collections.Immutable.dll not being copied from Project A's output folder into Project B?
- Where the hell is coming from on my collegeues machine?
I am using Visual Studio 2019 if that makes a difference