Merge pull request #715 from BepInEx/netfx-improvements

Fix netfx & netcore build targets, and add target framework variants
This commit is contained in:
Bepis authored and GitHub committed 2023-12-02 03:07:46 +11:00
commit 49775dc84f
5 files changed
+68 -33

No files matched your search

@@ -2,10 +2,10 @@
<PropertyGroup>
<Description>BepInEx support library for CoreCLR games</Description>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<OutputPath>$(BuildDir)/NET.CoreCLR</OutputPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<ItemGroup>
@@ -2,9 +2,9 @@
<PropertyGroup>
<Description>BepInEx support library for .NET Framework games</Description>
<OutputType>Exe</OutputType>
<TargetFramework>net452</TargetFramework>
<TargetFrameworks>net40;net452</TargetFrameworks>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<PlatformTarget>x86</PlatformTarget>
<OutputPath>$(BuildDir)/NET.Framework</OutputPath>
</PropertyGroup>
@@ -4,10 +4,13 @@
<ProjectGuid>067bcc8c-fc25-4929-b4f4-c6a5a7496994</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<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.props"/>
<PropertyGroup/>
<Import Project="BepInEx.NetLauncher.Shared.projitems" Label="Shared"/>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets"/>
</Project>
<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.props" />
<PropertyGroup />
<ItemGroup>
<Compile Include="SharedEntrypoint.cs" />
</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 readonly string Engine = DistributionIdentifier.Split('.')[0];
public readonly string Os = RuntimeIndentifier.Split('-')[0];
public readonly string Runtime = DistributionIdentifier.Split('.')[1];
public readonly string Target = $"{DistributionIdentifier}-{RuntimeIndentifier}";
public DistributionTarget(string distributionIdentifier, string runtimeIdentifier)
{
DistributionIdentifier = distributionIdentifier;
RuntimeIdentifier = runtimeIdentifier;
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
{
+24 -15
View File
@@ -50,8 +50,10 @@ public class BuildContext : FrostingContext
new("Unity.IL2CPP", "win-x64"),
new("Unity.IL2CPP", "linux-x64"),
new("Unity.IL2CPP", "macos-x64"),
new("NET.Framework", "win-x64"),
new("NET.CoreCLR", "win-x64")
new("NET.Framework", "win-x86", "net40"),
new("NET.Framework", "win-x86", "net452"),
new("NET.CoreCLR", "win-x64", "netcoreapp3.1"),
new("NET.CoreCLR", "win-x64", "net6.0")
};
@@ -241,8 +243,12 @@ public sealed class MakeDistTask : FrostingTask<BuildContext>
ctx.CreateDirectory(bepInExDir.Combine("patchers"));
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);
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}"),
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"));
}
}
if (dist.DistributionIdentifier == "NET.Framework")
else if (dist.Engine == "NET")
{
ctx.DeleteFile(bepInExCoreDir.CombineWithFilePath("BepInEx.NET.Framework.Launcher.exe.config"));
foreach (var filePath in ctx.GetFiles(bepInExCoreDir.Combine("BepInEx.NET.*").FullPath))
ctx.MoveFileToDirectory(filePath, targetDir);
}
if (dist.Runtime == "Framework")
{
ctx.DeleteFile(bepInExCoreDir.CombineWithFilePath("BepInEx.NET.Framework.Launcher.exe.config"));
if (dist.DistributionIdentifier == "NET.CoreCLR")
foreach (var filePath in ctx.GetFiles(bepInExCoreDir.Combine("BepInEx.NET.CoreCLR.*").FullPath))
ctx.MoveFileToDirectory(filePath, targetDir);
ctx.MoveFileToDirectory(bepInExCoreDir.CombineWithFilePath("BepInEx.NET.Framework.Launcher.exe"), targetDir);
}
else if (dist.Runtime == "CoreCLR")
{
foreach (var filePath in ctx.GetFiles(bepInExCoreDir.Combine("BepInEx.NET.CoreCLR.*").FullPath))
ctx.MoveFileToDirectory(filePath, targetDir);
}
}
}
}
}
@@ -347,7 +356,7 @@ public sealed class PublishTask : FrostingTask<BuildContext>
{
["file"] = $"BepInEx-{d.Target}-{ctx.BuildPackageVersion}.zip",
["description"] =
$"BepInEx {d.Engine} ({d.Runtime}) for {d.ClearOsName} ({d.Arch}) games"
$"BepInEx {d.Engine} ({d.Runtime}{(d.FrameworkTarget == null ? "" : " " + d.FrameworkTarget)}) for {d.ClearOsName} ({d.Arch}) games"
}).ToArray()
});
}