Tim*_*imo 7 c# internals csproj .net-standard .net-standard-2.0
我有多个程序集,其中包括单个 .NET Standard 2.0 项目的单元测试。为了彻底测试我的项目,我希望内部类对两个程序集都可见。
这是我的文件的一部分.csproj
,它使内部结构对一个程序集可见:
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(MSBuildProjectName).Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
如何向此配置添加其他程序集?
现在它适用于我需要的两个值之一,但我还没有弄清楚如何让它同时适用于这两个值。这应该是可能的,因为我在 .NET 和 .NET Framework 中找到了解决方案,但在 .NET Standard 中没有找到。
有什么建议么?
Mar*_*kus 15
只需添加第二个AssemblyAttribute
块,例如:
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(MSBuildProjectName).Tests</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Other.Assembly.Name</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,Other.Assembly.Name
代表另一个程序集的名称(省略目录路径和扩展名)。