Last active
January 4, 2022 20:19
-
-
Save lomholdt/0c36cf22fa4af5076aee0907e2b10a65 to your computer and use it in GitHub Desktop.
Make internals visible to other projects (eg. test projects)
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="InternalsVisibleToTask" BeforeTargets="GenerateAdditionalSources" Condition="@(InternalsVisibleTo) != ''"> | |
<ItemGroup> | |
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo"> | |
<_Parameter1>%(InternalsVisibleTo.Identity)</_Parameter1> | |
</AssemblyAttribute> | |
</ItemGroup> | |
</Target> | |
</Project> |
As of .NET 5, this is natively supported
https://jolo.codes/blog/make-internals-visible-to-test-projects/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
Add a
Directory.Build.props
to yoursrc
folder with the above build task.In the
.csproj
file containing the internal class add a