Skip to content

Commit

Permalink
Added pdb generation (#588)
Browse files Browse the repository at this point in the history
* Added pdb generation
* for Thin they are embedded
* for Fat they are portable
* Excluded ILRepack target from Thin
* Exclude the secondary System.Reflection.* packages from NuGet
  • Loading branch information
Aragas authored Mar 2, 2024
1 parent c419782 commit 14eebba
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
29 changes: 22 additions & 7 deletions Harmony/Harmony.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<Configurations>DebugThin;DebugFat;ReleaseThin;ReleaseFat</Configurations>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<CopyDebugSymbolFilesFromPackages>true</CopyDebugSymbolFilesFromPackages>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='net5.0' Or '$(TargetFramework)'=='net6.0' Or '$(TargetFramework)'=='net7.0' Or '$(TargetFramework)'=='net8.0'">
Expand All @@ -59,10 +59,18 @@
<DefineConstants>DEBUG</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='ReleaseThin' Or '$(Configuration)'=='ReleaseFat'">
<PropertyGroup Condition="'$(Configuration)'=='ReleaseThin'">
<Optimize>true</Optimize>
<DebugType>embedded</DebugType>
<DebugSymbols>true</DebugSymbols>
<ILRepackTargetsFile>$(SolutionDir)ILRepack.targets</ILRepackTargetsFile>
<ClearOutputDirectory>True</ClearOutputDirectory>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='ReleaseFat'">
<Optimize>true</Optimize>
<DebugType>portable</DebugType>
<DebugSymbols>false</DebugSymbols>
<DebugSymbols>true</DebugSymbols>
<ILRepackTargetsFile>$(SolutionDir)ILRepack.targets</ILRepackTargetsFile>
<ClearOutputDirectory>True</ClearOutputDirectory>
</PropertyGroup>
Expand Down Expand Up @@ -93,9 +101,9 @@
</PropertyGroup>
<ItemGroup Condition="$(TargetFramework)=='netstandard2.0'">
<!-- Adding System.Reflection.Emit.* because there are public types exposed from its's package -->
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" IncludeAssets="compile" />
<PackageReference Include="System.Reflection.Emit.ILGeneration" Version="4.7.0" IncludeAssets="compile" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" IncludeAssets="compile" />
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" IncludeAssets="compile" />
<PackageReference Include="System.Reflection.Emit.ILGeneration" Version="4.7.0" PrivateAssets="all" IncludeAssets="compile" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" PrivateAssets="all" IncludeAssets="compile" />
</ItemGroup>
<Target Name="AddRefAssemblyToPackage" Condition="$(TargetFramework)=='netstandard2.0'">
<ItemGroup>
Expand Down Expand Up @@ -138,6 +146,13 @@
<Delete Files="@(OldNugetPackages)" />
</Target>

<Target Name="RemoveFaultyPdb" BeforeTargets="Build">
<ItemGroup>
<FilesToDelete Include="$(ProjectDir)\$(OutDir)\MonoMod.ILHelpers.pdb"/>
</ItemGroup>
<Delete Files="@(FilesToDelete)" />
</Target>

<Target Name="CleanZip" AfterTargets="Clean">
<ItemGroup>
<OldZipFiles Include="$(MSBuildThisFileDirectory)bin\Harmony-Thin.*.zip" Condition="'$(Configuration)'=='ReleaseThin'"/>
Expand Down
5 changes: 5 additions & 0 deletions ILRepack.targets
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="ILRepacker" AfterTargets="Build" Condition="'$(Configuration)' == 'DebugFat' Or '$(Configuration)' == 'ReleaseFat'">
<PropertyGroup>
<DebugInfo Condition="'$(TargetFramework)' == 'netstandard2.0'">false</DebugInfo>
<DebugInfo Condition="'$(TargetFramework)' != 'netstandard2.0'">true</DebugInfo>
</PropertyGroup>
<ItemGroup>
<InputAssemblies Include="$(OutputPath)\*.dll" />
</ItemGroup>
<ILRepack
InputAssemblies="@(InputAssemblies)"
OutputFile="$(OutputPath)\$(AssemblyName).dll"
DebugInfo="$(DebugInfo)"
CopyAttributes="false"
XmlDocumentation="true"
Internalize="true"
Expand Down

0 comments on commit 14eebba

Please sign in to comment.