使用伪造Microsoft的 C# 测试项目中的错误"The extern alias 'snh' was not specified in a /reference option "



我有一个使用Microsoft假货的C#测试项目。项目引用的外部库 (abc.dll( 最近已更新为 .net 标准 2.0。将 abc.dll 库引用更新到最新版本后,测试项目不再生成,也不会为该库 (dll( 生成假程序集。 我在生成的 .csproj 文件中看到以下错误。

外部别名"snh"未在/reference 选项中指定

我看着生成的.csproj 文件和别名 snh 对应于 System.Net.Http

测试项目针对.net 4.6.1,我使用的是最新的VS 2017

知道如何解决这个问题吗?

这是目前项目面向 .Net Framework 4.7.1 并引用 netstandard 库的未决问题。它在这里被跟踪:https://github.com/dotnet/sdk/issues/2254。

我将包括对我有用的解决方法:作为参考,针对Fakes问题发布的解决方法是将以下内容放在Directory.Build.targets中:

<ItemGroup Condition="'@(_NETStandardLibraryNETFrameworkLib)' != ''">
  <SnhReference Include = "@(_NETStandardLibraryNETFrameworkLib)" Condition="'%(_NETStandardLibraryNETFrameworkLib.FileName)' == 'System.Net.Http'" />
  <Reference Remove="%(SnhReference.FileName)" Condition="'@(SnhReference)' != ''"/>
  <Reference Include="%(SnhReference.FileName)" Condition="'@(SnhReference)' != ''">
    <HintPath>%(SnhReference.Identity)</HintPath>
    <Private>false</Private>
    <Aliases>snh</Aliases>
  </Reference>
</ItemGroup>

相关内容

最新更新