Skip to content
Enables declaring 'InternalsVisibleTo' items in a .NET project file, rather than declaring them to an AssemblyInfo.cs file.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build
buildCrossTargeting
InternalsVisibleTo.MSBuild.nuspec
LICENSE
README.md

README.md

InternalsVisibleTo.MSBuild

NuGet version

Enables declaring InternalsVisibleTo items in a .NET project file, rather than declaring them in an AssemblyInfo.cs file.

How to use

  1. Install the InternalsVisibleTo.MSBuild NuGet package.

  2. Edit your csproj file and add <InternalsVisibleTo> items in your project for each assembly that should have access to the internals of the current project:

      <ItemGroup>
        <InternalsVisibleTo Include="$(AssemblyName).UnitTests" />
        <InternalsVisibleTo Include="SomeOtherAssembly" />
        <InternalsVisibleTo Include="StronglyNamedAssembly, PublicKey=0123....." />
      </ItemGroup>

    This will generate the appropriate InternalsVisibleTo attributes for your assembly.

    Alternatively, you can also use <InternalsVisibleToSuffix> to specify that assemblies named $(AssemblyName).<suffix> will have access to the internals of the current project:

      <ItemGroup>
        <!-- $(AssemblyName).UnitTests will have access to the internals of this project -->
        <InternalsVisibleToSuffix Include=".UnitTests" />
      </ItemGroup>

Note

In fact, it's already possible to declare InternalsVisibleTo attributes in the project file without this package, but the syntax is ugly and hard to remember:

  <ItemGroup>
    <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
      <_Parameter1>SomeOtherAssembly</_Parameter1>
    </AssemblyAttribute>
  <ItemGroup>

This package just makes things easier by transforming <InternalsVisibleTo> elements into appropriate <AssemblyAttribute> elements.

You can’t perform that action at this time.