Original source: https://www.meziantou.net/declaring-internalsvisibleto-in-the-csproj.htm
Created
March 10, 2020 11:33
-
-
Save Gh0stWalk3r/2fe9c9cf8f7d5aad0bde473dbd3fb958 to your computer and use it in GitHub Desktop.
Add InternalsVisibleTo to new csproj SDK format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project> | |
<Target Name="AddInternalsVisibleTo" BeforeTargets="CoreCompile"> | |
<!-- Add default suffix if there is no InternalsVisibleTo or InternalsVisibleToSuffix defined --> | |
<ItemGroup Condition="@(InternalsVisibleToSuffix->Count()) == 0 AND @(InternalsVisibleTo->Count()) == 0"> | |
<InternalsVisibleToSuffix Include=".Tests" /> | |
</ItemGroup> | |
<!-- Handle InternalsVisibleTo --> | |
<ItemGroup Condition="'@(InternalsVisibleTo->Count())' > 0"> | |
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo"> | |
<_Parameter1>%(InternalsVisibleTo.Identity)</_Parameter1> | |
</AssemblyAttribute> | |
</ItemGroup> | |
<!-- Handle InternalsVisibleToSuffix --> | |
<ItemGroup Condition="@(InternalsVisibleToSuffix->Count()) > 0"> | |
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo"> | |
<_Parameter1>$(AssemblyName)%(InternalsVisibleToSuffix.Identity)</_Parameter1> | |
</AssemblyAttribute> | |
</ItemGroup> | |
</Target> | |
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>netcoreapp3.0</TargetFramework> | |
<LangVersion>8.0</LangVersion> | |
<Nullable>enable</Nullable> | |
</PropertyGroup> | |
<ItemGroup> | |
<InternalsVisibleTo Include="CustomTest1" /> <!-- [assembly: InternalsVisibleTo("CustomTest1")] --> | |
<InternalsVisibleTo Include="CustomTest2, PublicKey=abc" /> <!-- [assembly: InternalsVisibleTo("CustomTest2, PublicKey=abc")] --> | |
<InternalsVisibleTo Include="$(AssemblyName).Custom" /> <!-- [assembly: InternalsVisibleTo("ClassLibrary1.Custom")] --> | |
<InternalsVisibleToSuffix Include=".Tests" /> <!-- [assembly: InternalsVisibleTo("ClassLibrary1.Tests")] --> | |
<InternalsVisibleToSuffix Include=".FunctionalTests" /> <!-- [assembly: InternalsVisibleTo("ClassLibrary1.FunctionalTests")] --> | |
</ItemGroup> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment