Skip to content

Commit

Permalink
feat: Add IsTrimmable False metadata to assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Jan 4, 2024
1 parent 496be7f commit 85e6f2a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,27 @@
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>

<!-- Generate the NotTrimmable.cs file -->
<Target Name="AddNotTrimmableFile" BeforeTargets="BeforeCompile" Condition=" $(IsPackable) ">
<PropertyGroup>
<!-- Define the file path -->
<NotTrimmableFilePath>$(IntermediateOutputPath)NotTrimmable.g.cs</NotTrimmableFilePath>
</PropertyGroup>

<!-- Ensure the intermediate output directory exists -->
<MakeDir Directories="$(IntermediateOutputPath)" />

<!-- Write the contents to the file -->
<WriteLinesToFile
File="$(NotTrimmableFilePath)"
Lines="[assembly: System.Reflection.AssemblyMetadata(&quot;IsTrimmable&quot;, &quot;False&quot;)]"
Overwrite="true"
Encoding="UTF-8" />

<!-- Include the generated file in the compilation -->
<ItemGroup>
<Compile Include="$(NotTrimmableFilePath)" />
</ItemGroup>
</Target>

</Project>

0 comments on commit 85e6f2a

Please sign in to comment.