Skip to content

Commit

Permalink
Moved ref/netstandard2.0 into Lib.Harmony.Ref (#591)
Browse files Browse the repository at this point in the history
* Added a Ref package for netstandard2.0 reference assemblies
* Simplified the netstandard2.0 handling in Fat and Thin
* Added ref support for CI
  • Loading branch information
Aragas authored Mar 3, 2024
1 parent a43ef19 commit e8b8cb7
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 24 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ env:

# You are interested in changing these values
BUILD_CONFIGURATIONS: "['ReleaseFat', 'ReleaseThin']"
BUILD_CONFIGURATIONS_WITH_REF: "['ReleaseFat', 'ReleaseThin', 'ReleaseRef']"
DOTNET_TARGET_FRAMEWORKS: "['netcoreapp3.0', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0']"
DOTNET_TARGET_FRAMEWORKS_MACOS_ARM64: "['net6.0', 'net7.0', 'net8.0']"
FRAMEWORK_TARGET_FRAMEWORKS: "['net35', 'net452', 'net472', 'net48']"
Expand All @@ -51,6 +52,7 @@ jobs:
PARALLEL: ${{env.PARALLEL}}
PREBUILD: ${{env.PREBUILD}}
BUILD_CONFIGURATIONS: ${{env.BUILD_CONFIGURATIONS}}
BUILD_CONFIGURATIONS_WITH_REF: ${{env.BUILD_CONFIGURATIONS_WITH_REF}}
DOTNET_TARGET_FRAMEWORKS: ${{env.DOTNET_TARGET_FRAMEWORKS}}
DOTNET_TARGET_FRAMEWORKS_MACOS_ARM64: ${{env.DOTNET_TARGET_FRAMEWORKS_MACOS_ARM64}}
FRAMEWORK_TARGET_FRAMEWORKS: ${{env.FRAMEWORK_TARGET_FRAMEWORKS}}
Expand All @@ -61,6 +63,7 @@ jobs:
echo "PARALLEL=${{env.PARALLEL}}" >> $GITHUB_OUTPUT
echo "PREBUILD=${{env.PREBUILD}}" >> $GITHUB_OUTPUT
echo "BUILD_CONFIGURATIONS=${{env.BUILD_CONFIGURATIONS}}" >> $GITHUB_OUTPUT
echo "BUILD_CONFIGURATIONS_WITH_REF=${{env.BUILD_CONFIGURATIONS_WITH_REF}}" >> $GITHUB_OUTPUT
echo "DOTNET_TARGET_FRAMEWORKS=${{env.DOTNET_TARGET_FRAMEWORKS}}" >> $GITHUB_OUTPUT
echo "DOTNET_TARGET_FRAMEWORKS_MACOS_ARM64=${{env.DOTNET_TARGET_FRAMEWORKS_MACOS_ARM64}}" >> $GITHUB_OUTPUT
echo "FRAMEWORK_TARGET_FRAMEWORKS=${{env.FRAMEWORK_TARGET_FRAMEWORKS}}" >> $GITHUB_OUTPUT
Expand All @@ -73,7 +76,7 @@ jobs:
strategy:
matrix:
image: [ { os: 'windows', code: 'windows-latest' }, { os: 'ubuntu', code: 'ubuntu-latest' }, { os: 'macos', code: 'macos-13' }, { os: 'macos-arm64', code: 'macos-14' } ]
build_configuration: ${{fromJson(needs.variables.outputs.BUILD_CONFIGURATIONS)}}
build_configuration: ${{fromJson(needs.variables.outputs.BUILD_CONFIGURATIONS_WITH_REF)}}
uses: ./.github/workflows/test-build.yml
with:
os: ${{matrix.image.os}}
Expand Down
3 changes: 3 additions & 0 deletions Harmony.sln
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Global
DebugThin|Any CPU = DebugThin|Any CPU
ReleaseFat|Any CPU = ReleaseFat|Any CPU
ReleaseThin|Any CPU = ReleaseThin|Any CPU
ReleaseRef|Any CPU = ReleaseRef|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{69AEE16A-B6E7-4642-8081-3928B32455DF}.DebugFat|Any CPU.ActiveCfg = DebugFat|Any CPU
Expand All @@ -112,6 +113,8 @@ Global
{69AEE16A-B6E7-4642-8081-3928B32455DF}.ReleaseFat|Any CPU.Build.0 = ReleaseFat|Any CPU
{69AEE16A-B6E7-4642-8081-3928B32455DF}.ReleaseThin|Any CPU.ActiveCfg = ReleaseThin|Any CPU
{69AEE16A-B6E7-4642-8081-3928B32455DF}.ReleaseThin|Any CPU.Build.0 = ReleaseThin|Any CPU
{69AEE16A-B6E7-4642-8081-3928B32455DF}.ReleaseRef|Any CPU.ActiveCfg = ReleaseRef|Any CPU
{69AEE16A-B6E7-4642-8081-3928B32455DF}.ReleaseRef|Any CPU.Build.0 = ReleaseRef|Any CPU
{DEE74EFC-29A8-4704-8536-7DA38D3999F7}.DebugFat|Any CPU.ActiveCfg = Debug|Any CPU
{DEE74EFC-29A8-4704-8536-7DA38D3999F7}.DebugFat|Any CPU.Build.0 = Debug|Any CPU
{DEE74EFC-29A8-4704-8536-7DA38D3999F7}.DebugThin|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down
62 changes: 39 additions & 23 deletions Harmony/Harmony.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<PackageVersion>$(HarmonyVersion)$(HarmonyPrerelease)</PackageVersion>
<InformationalVersion>$(HarmonyVersion)$(HarmonyPrerelease)</InformationalVersion>
<NoWarn>$(NoWarn);SYSLIB0011;NU5131</NoWarn>
<Configurations>DebugThin;DebugFat;ReleaseThin;ReleaseFat</Configurations>
<Configurations>DebugThin;DebugFat;ReleaseThin;ReleaseFat;ReleaseRef</Configurations>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<ILRepackTargetsFile>$(SolutionDir)ILRepack.targets</ILRepackTargetsFile>
Expand All @@ -51,6 +51,7 @@
<None Include="..\README.md" Pack="true" PackagePath="" />
<None Include="..\LICENSE" Pack="true" PackagePath="" />
<None Include="..\HarmonyLogo.png" Pack="true" Visible="false" PackagePath="" />
<None Include="..\_._" Pack="true" Visible="false" PackagePath="lib/netstandard2.0" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)'=='DebugThin' Or '$(Configuration)'=='DebugFat'">
Expand All @@ -77,7 +78,7 @@
<PackageReference Include="MonoMod.Core" Version="$(MonoModCoreVersion)" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='DebugFat' Or '$(Configuration)'=='ReleaseFat'">
<ItemGroup Condition="'$(Configuration)'=='DebugFat' Or '$(Configuration)'=='ReleaseFat' Or '$(Configuration)'=='ReleaseRef'">
<PackageReference Include="MonoMod.Core" Version="$(MonoModCoreVersion)" PrivateAssets="all" />
</ItemGroup>

Expand All @@ -89,31 +90,17 @@
</ItemGroup>

<!-- netstandard2.0 reference assemblies -->
<PropertyGroup Condition="$(TargetFramework)=='netstandard2.0'">
<PropertyGroup Condition="$(Configuration)!='ReleaseRef' AND $(TargetFramework)=='netstandard2.0'">
<!-- Remove from /lib in NuGet -->
<IncludeBuildOutput>false</IncludeBuildOutput>
<!-- Create reference Assemblies instead of a full assembly -->
<ProduceOnlyReferenceAssembly>true</ProduceOnlyReferenceAssembly>
<!-- Add our target for packing -->
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);AddRefAssemblyToPackage</TargetsForTfmSpecificContentInPackage>
</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" PrivateAssets="all" IncludeAssets="compile" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" PrivateAssets="all" IncludeAssets="compile" />
<ItemGroup Condition="$(Configuration)!='ReleaseRef' AND $(TargetFramework)=='netstandard2.0'">
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" PrivateAssets="all" IncludeAssets="compile" />
</ItemGroup>
<Target Name="AddRefAssemblyToPackage" Condition="$(TargetFramework)=='netstandard2.0'">
<ItemGroup>
<!-- Adding the Reference Assembly and the xml documentation to /ref of NuGet -->
<TfmSpecificPackageFile Include="$(OutDir)$(AssemblyName).dll">
<PackagePath>ref/netstandard2.0</PackagePath>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Include="$(OutDir)$(AssemblyName).xml">
<PackagePath>ref/netstandard2.0</PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
</Target>
<ItemGroup Condition="$(Configuration)!='ReleaseRef' AND $(TargetFramework)=='netstandard2.0'">
<PackageReference Include="Lib.Harmony.Ref" Version="$(HarmonyVersion)" IncludeAssets="contentFiles" />
</ItemGroup>
<!-- netstandard2.0 reference assemblies -->

<ItemGroup Condition="'$(TargetFramework)'=='net5.0'">
<PackageReference Include="System.Text.Json" Version="5.0.2" />
Expand Down Expand Up @@ -173,4 +160,33 @@
<ZipDirectory SourceDirectory="$(MSBuildThisFileDirectory)bin\$(Configuration)" DestinationFile="$(MSBuildThisFileDirectory)bin\Harmony-Fat.$(Version).zip" Overwrite="true" Condition="'$(Configuration)'=='ReleaseFat'"/>
</Target>

<!-- ReleaseRef -->
<PropertyGroup Condition="$(Configuration)=='ReleaseRef'">
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
<PackageId>Lib.Harmony.Ref</PackageId>
<!-- Remove from /lib in NuGet -->
<IncludeBuildOutput>false</IncludeBuildOutput>
<!-- Create reference Assemblies instead of a full assembly -->
<ProduceOnlyReferenceAssembly>true</ProduceOnlyReferenceAssembly>
<!-- Add our target for packing -->
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);AddRefAssemblyToPackage</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>
<ItemGroup Condition="$(Configuration)=='ReleaseRef'">
<!-- 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" />
<None Remove="_._" />
</ItemGroup>
<Target Name="AddRefAssemblyToPackage" Condition="$(Configuration)=='ReleaseRef'">
<ItemGroup>
<!-- Adding the Reference Assembly and the xml documentation to /ref of NuGet -->
<TfmSpecificPackageFile Include="$(OutDir)$(AssemblyName).dll">
<PackagePath>ref/netstandard2.0</PackagePath>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Include="$(OutDir)$(AssemblyName).xml">
<PackagePath>ref/netstandard2.0</PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
</Target>
<!-- ReleaseRef -->

</Project>
Empty file added _._
Empty file.

0 comments on commit e8b8cb7

Please sign in to comment.