Fix netfx & netcore build targets, and add target framework variants

This commit is contained in:
Bepis committed 2023-11-27 04:18:48 +11:00
1 parent 82077ec7c9
commit 4dccfaa437
5 files changed
+72 -36

No files matched your search

@@ -2,10 +2,10 @@
<PropertyGroup> <PropertyGroup>
<Description>BepInEx support library for CoreCLR games</Description> <Description>BepInEx support library for CoreCLR games</Description>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFrameworks>netcoreapp3.1;net6</TargetFrameworks>
<OutputPath>$(BuildDir)/NET.CoreCLR</OutputPath> <OutputPath>$(BuildDir)/NET.CoreCLR</OutputPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -2,9 +2,9 @@
<PropertyGroup> <PropertyGroup>
<Description>BepInEx support library for .NET Framework games</Description> <Description>BepInEx support library for .NET Framework games</Description>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net452</TargetFramework> <TargetFrameworks>net40;net452</TargetFrameworks>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<OutputPath>$(BuildDir)/NET.Framework</OutputPath> <OutputPath>$(BuildDir)/NET.Framework</OutputPath>
</PropertyGroup> </PropertyGroup>
@@ -16,6 +16,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="HarmonyX" Version="2.10.1"/> <PackageReference Include="HarmonyX" Version="2.10.1"/>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All"/> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All"/>
<PackageReference Include="MonoMod.RuntimeDetour" Version="22.5.1.1" />
</ItemGroup> </ItemGroup>
<Import Project="..\BepInEx.NET.Shared\BepInEx.NET.Shared.projitems" Label="Shared"/> <Import Project="..\BepInEx.NET.Shared\BepInEx.NET.Shared.projitems" Label="Shared"/>
</Project> </Project>
@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>067bcc8c-fc25-4929-b4f4-c6a5a7496994</ProjectGuid> <ProjectGuid>067bcc8c-fc25-4929-b4f4-c6a5a7496994</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion> <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props"/> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props"/> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup/> <PropertyGroup />
<Import Project="BepInEx.NetLauncher.Shared.projitems" Label="Shared"/> <ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets"/> <Compile Include="SharedEntrypoint.cs" />
</Project> </ItemGroup>
<Import Project="BepInEx.NetLauncher.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
+30 -7
View File
@@ -1,12 +1,35 @@
using System; using System;
readonly record struct DistributionTarget(string DistributionIdentifier, string RuntimeIndentifier) readonly struct DistributionTarget
{ {
public readonly string Arch = RuntimeIndentifier.Split('-')[1]; public DistributionTarget(string distributionIdentifier, string runtimeIdentifier)
public readonly string Engine = DistributionIdentifier.Split('.')[0]; {
public readonly string Os = RuntimeIndentifier.Split('-')[0]; DistributionIdentifier = distributionIdentifier;
public readonly string Runtime = DistributionIdentifier.Split('.')[1]; RuntimeIdentifier = runtimeIdentifier;
public readonly string Target = $"{DistributionIdentifier}-{RuntimeIndentifier}"; FrameworkTarget = null;
Os = RuntimeIdentifier.Split('-')[0];
Arch = RuntimeIdentifier.Split('-')[1];
Engine = DistributionIdentifier.Split('.')[0];
Runtime = DistributionIdentifier.Split('.')[1];
Target = $"{DistributionIdentifier}-{RuntimeIdentifier}";
}
public DistributionTarget(string distributionIdentifier, string runtimeIdentifier, string frameworkTarget) : this(distributionIdentifier, runtimeIdentifier)
{
FrameworkTarget = frameworkTarget;
Target = $"{DistributionIdentifier}-{FrameworkTarget}-{RuntimeIdentifier}";
}
public readonly string DistributionIdentifier;
public readonly string RuntimeIdentifier;
public readonly string FrameworkTarget;
public readonly string Arch;
public readonly string Engine;
public readonly string Os;
public readonly string Runtime;
public readonly string Target;
public string ClearOsName => Os switch public string ClearOsName => Os switch
{ {
+23 -14
View File
@@ -50,8 +50,10 @@ public class BuildContext : FrostingContext
new("Unity.IL2CPP", "win-x64"), new("Unity.IL2CPP", "win-x64"),
new("Unity.IL2CPP", "linux-x64"), new("Unity.IL2CPP", "linux-x64"),
new("Unity.IL2CPP", "macos-x64"), new("Unity.IL2CPP", "macos-x64"),
new("NET.Framework", "win-x64"), new("NET.Framework", "win-x86", "net40"),
new("NET.CoreCLR", "win-x64") new("NET.Framework", "win-x86", "net452"),
new("NET.CoreCLR", "win-x64", "netcoreapp3.1"),
new("NET.CoreCLR", "win-x64", "net6")
}; };
@@ -241,8 +243,12 @@ public sealed class MakeDistTask : FrostingTask<BuildContext>
ctx.CreateDirectory(bepInExDir.Combine("patchers")); ctx.CreateDirectory(bepInExDir.Combine("patchers"));
File.WriteAllText(targetDir.CombineWithFilePath("changelog.txt").FullPath, changelog); File.WriteAllText(targetDir.CombineWithFilePath("changelog.txt").FullPath, changelog);
foreach (var filePath in ctx.GetFiles(ctx.OutputDirectory.Combine(dist.DistributionIdentifier)
.Combine("*.*").FullPath)) var sourceDirectory = ctx.OutputDirectory.Combine(dist.DistributionIdentifier);
if (dist.FrameworkTarget != null)
sourceDirectory = sourceDirectory.Combine(dist.FrameworkTarget);
foreach (var filePath in ctx.GetFiles(sourceDirectory.Combine("*.*").FullPath))
ctx.CopyFileToDirectory(filePath, bepInExCoreDir); ctx.CopyFileToDirectory(filePath, bepInExCoreDir);
if (dist.Engine == "Unity") if (dist.Engine == "Unity")
@@ -269,21 +275,24 @@ public sealed class MakeDistTask : FrostingTask<BuildContext>
{ {
ctx.CopyFile(ctx.CacheDirectory.Combine("dobby").Combine($"dobby_{dist.Os}").CombineWithFilePath($"{dist.DllPrefix}dobby_{dist.Arch}.{dist.DllExtension}"), ctx.CopyFile(ctx.CacheDirectory.Combine("dobby").Combine($"dobby_{dist.Os}").CombineWithFilePath($"{dist.DllPrefix}dobby_{dist.Arch}.{dist.DllExtension}"),
bepInExCoreDir.CombineWithFilePath($"{dist.DllPrefix}dobby.{dist.DllExtension}")); bepInExCoreDir.CombineWithFilePath($"{dist.DllPrefix}dobby.{dist.DllExtension}"));
ctx.CopyDirectory(ctx.CacheDirectory.Combine("dotnet").Combine(dist.RuntimeIndentifier), ctx.CopyDirectory(ctx.CacheDirectory.Combine("dotnet").Combine(dist.RuntimeIdentifier),
targetDir.Combine("dotnet")); targetDir.Combine("dotnet"));
} }
} }
else if (dist.Engine == "NET")
if (dist.DistributionIdentifier == "NET.Framework")
{ {
ctx.DeleteFile(bepInExCoreDir.CombineWithFilePath("BepInEx.NET.Framework.Launcher.exe.config")); if (dist.Runtime == "Framework")
foreach (var filePath in ctx.GetFiles(bepInExCoreDir.Combine("BepInEx.NET.*").FullPath)) {
ctx.MoveFileToDirectory(filePath, targetDir); ctx.DeleteFile(bepInExCoreDir.CombineWithFilePath("BepInEx.NET.Framework.Launcher.exe.config"));
}
if (dist.DistributionIdentifier == "NET.CoreCLR") ctx.MoveFileToDirectory(bepInExCoreDir.CombineWithFilePath("BepInEx.NET.Framework.Launcher.exe"), targetDir);
foreach (var filePath in ctx.GetFiles(bepInExCoreDir.Combine("BepInEx.NET.CoreCLR.*").FullPath)) }
ctx.MoveFileToDirectory(filePath, targetDir); else if (dist.Runtime == "CoreCLR")
{
foreach (var filePath in ctx.GetFiles(bepInExCoreDir.Combine("BepInEx.NET.CoreCLR.*").FullPath))
ctx.MoveFileToDirectory(filePath, targetDir);
}
}
} }
} }
} }