类型或命名空间名称' InternalsVisibleToAttribute'缺少构建

时间:2017-08-16 17:16:52

标签: c# appveyor

我最近在AppVeyor上构建了一个项目,用于构建徽章和GitHub集成,但我收到错误The type or namespace name 'InternalsVisibleToAttribute' could not be found (are you missing a using directive or an assembly reference?)。我在构建过程中运行nuget还原。它只是在添加InternalsVisibleTo后才开始失败。该解决方案在本地构建完美。

我正在使用该属性,以便我可以将某些类公开给测试项目而不公开公开。

我想使用InternalsVisibleTo,因为它在我的测试项目中更容易管理。

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

根据ilyaf关于该问题的建议链接,我必须在属性上使用完全限定的命名空间,在文件中将命名空间作为using语句是不够的。

修复Build:

// This compiles and builds successfully on AppVeyor.
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("ProjectA"),
           System.Runtime.CompilerServices.InternalsVisibleTo("ProjectATests")]