Search code examples
c#appveyor

The type or namespace name 'InternalsVisibleToAttribute' missing on build


I've recently setup a project to build on AppVeyor for the build badge and GitHub integration, but I'm getting the error The type or namespace name 'InternalsVisibleToAttribute' could not be found (are you missing a using directive or an assembly reference?). I am running a nuget restore in the build process. It only started failing since adding InternalsVisibleTo. The solution builds perfectly fine locally.

I'm using the attribute so that I can expose certain classes to a test project without exposing it publicly.

I wanted to use the InternalsVisibleTo because it's easier to manage in my test project.

Any help is greatly appreciated!


Solution

  • As per ilyaf's suggested link on the question, I had to use a fully qualified namespace on the attribute, having the namespace in as a using statement in the file is not enough.

    To fix Build:

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