项目引用的依赖项未复制到输出文件夹中
Dependency of project reference not being copied into output folder
在这被标记为欺骗之前 - 我确实找到了这个 并尝试了那个但它没有用
这一切都发生在测试项目中,正在调用有问题的方法,因为它们具有 OneTimeSetup 属性 - 不确定是否相关,但信息越多越好
项目 A
参考文献
- System.Collections.Immutable v 1.3.33 - 使用 ScriptCs 的依赖,但也直接在代码中使用
cs proj 有这个条目
<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>
项目 A 包含一个基础 Class
[SetUpFixture]
public abstract class BaseClass
{
[OneTimeSetup]
public void DoSomething()
{
var MyClass = new MyClass();
MyClass.DoStuff();
//etc etc
}
}
它还包含 class MyClass - 这个 class 直接使用来自 System.Collections.Immutable
的类型
public class MyClass
{
private ImmutableDictionary<string,string> myImmutableDictionary = ImmutableDictionary.Create<string,string>();
public void DoStuff()
{
//does things
}
}
项目 B
- 没有直接引用 System.Immutable.Collections
- 对项目 A 的项目引用
在项目 B 中,我们有一个 class 继承自项目 B
中的 BaseClass
[SetUpFixture]
public class SubClass : BaseClass
{
[OneTimeSetup]
public void SomeMethod()
{
DoSomething(); //Here it goes bang
}
}
因此我们收到了一个问题的警告,即我们在构建服务器上的所有测试都因同样的原因而失败
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.
我在本地 运行 遇到了同样的问题。我调查了项目 B 的输出文件夹,令我惊讶的是它不包含 'System.Collections.Immutable.dll' - 因此找不到它的原因。
我的一个同事 运行 他们在他们的机器上进行了测试 运行 我们查看了他们项目 B 的输出文件夹,更令人惊讶的是有一个 'System.Collections.Immutable.dll' 文件那里。然而...它不是在项目 A 的输出文件夹 (1.1.33) 中找到的版本,它是 4.x.x - 我认为这来自 GAC 但由于其他一些奇怪的事情我们无法确认是否他们的 GAC 中有那个 dll
所以我有点震惊
我的理解是 MSBuild 将 GAC 的 dll 作为最后的手段,应该首先使用提示路径(是的,我检查过提示路径也指向的地方存在 dll)
所以..
- 为什么 System.Collections.Immutable.dll 没有从项目 A 的输出文件夹复制到项目 B?
- 我的 collegeues 机器到底是从哪里来的?
我正在使用 Visual Studio 2019,如果有区别的话
Why is the System.Collections.Immutable.dll not being copied from
Project A's output folder into Project B?
可能是您使用了 Build Depeencies=>Project Dependencies 导致了这个问题。请转到添加=>引用=>项目=>添加项目引用的解决方案。
Where the hell is coming from on my collegeues machine?
我查了vs2019,projectB中的dll版本是对应projectA中的。(我已经通过nuget包管理器将System.Collections.Immutable包版本从1.4.0更改为1.6.0 , 他们的版本都匹配 )
由于您的项目(根据描述判断)正在使用 packages.config,您还需要将项目 A 中使用的 NuGet 包显式安装到项目 B 中,因为它们不会传递。
但是:System.Collections.Immutable.dll 首先不应该是 ScriptCs 包的一部分。这可能是 ScriptCs 的打包问题。
另外:您可能无法在测试项目中生成绑定重定向。如果是这样,请尝试将此 xml 添加到测试项目文件中:
(参见 )
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
在这被标记为欺骗之前 - 我确实找到了这个
这一切都发生在测试项目中,正在调用有问题的方法,因为它们具有 OneTimeSetup 属性 - 不确定是否相关,但信息越多越好
项目 A
参考文献 - System.Collections.Immutable v 1.3.33 - 使用 ScriptCs 的依赖,但也直接在代码中使用 cs proj 有这个条目
<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>
项目 A 包含一个基础 Class
[SetUpFixture]
public abstract class BaseClass
{
[OneTimeSetup]
public void DoSomething()
{
var MyClass = new MyClass();
MyClass.DoStuff();
//etc etc
}
}
它还包含 class MyClass - 这个 class 直接使用来自 System.Collections.Immutable
的类型public class MyClass
{
private ImmutableDictionary<string,string> myImmutableDictionary = ImmutableDictionary.Create<string,string>();
public void DoStuff()
{
//does things
}
}
项目 B - 没有直接引用 System.Immutable.Collections - 对项目 A 的项目引用
在项目 B 中,我们有一个 class 继承自项目 B
中的 BaseClass [SetUpFixture]
public class SubClass : BaseClass
{
[OneTimeSetup]
public void SomeMethod()
{
DoSomething(); //Here it goes bang
}
}
因此我们收到了一个问题的警告,即我们在构建服务器上的所有测试都因同样的原因而失败
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.
我在本地 运行 遇到了同样的问题。我调查了项目 B 的输出文件夹,令我惊讶的是它不包含 'System.Collections.Immutable.dll' - 因此找不到它的原因。
我的一个同事 运行 他们在他们的机器上进行了测试 运行 我们查看了他们项目 B 的输出文件夹,更令人惊讶的是有一个 'System.Collections.Immutable.dll' 文件那里。然而...它不是在项目 A 的输出文件夹 (1.1.33) 中找到的版本,它是 4.x.x - 我认为这来自 GAC 但由于其他一些奇怪的事情我们无法确认是否他们的 GAC 中有那个 dll
所以我有点震惊
我的理解是 MSBuild 将 GAC 的 dll 作为最后的手段,应该首先使用提示路径(是的,我检查过提示路径也指向的地方存在 dll)
所以..
- 为什么 System.Collections.Immutable.dll 没有从项目 A 的输出文件夹复制到项目 B?
- 我的 collegeues 机器到底是从哪里来的?
我正在使用 Visual Studio 2019,如果有区别的话
Why is the System.Collections.Immutable.dll not being copied from Project A's output folder into Project B?
可能是您使用了 Build Depeencies=>Project Dependencies 导致了这个问题。请转到添加=>引用=>项目=>添加项目引用的解决方案。
Where the hell is coming from on my collegeues machine?
我查了vs2019,projectB中的dll版本是对应projectA中的。(我已经通过nuget包管理器将System.Collections.Immutable包版本从1.4.0更改为1.6.0 , 他们的版本都匹配 )
由于您的项目(根据描述判断)正在使用 packages.config,您还需要将项目 A 中使用的 NuGet 包显式安装到项目 B 中,因为它们不会传递。
但是:System.Collections.Immutable.dll 首先不应该是 ScriptCs 包的一部分。这可能是 ScriptCs 的打包问题。
另外:您可能无法在测试项目中生成绑定重定向。如果是这样,请尝试将此 xml 添加到测试项目文件中:
(参见
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>