Skip to content

Commit 49775dc

Browse files
authored
Merge pull request #715 from BepInEx/netfx-improvements
Fix netfx & netcore build targets, and add target framework variants
2 parents 82077ec + b841c78 commit 49775dc

File tree

5 files changed

+68
-33
lines changed

5 files changed

+68
-33
lines changed

Runtimes/NET/BepInEx.NET.CoreCLR/BepInEx.NET.CoreCLR.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
<PropertyGroup>
44
<Description>BepInEx support library for CoreCLR games</Description>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
66
<OutputPath>$(BuildDir)/NET.CoreCLR</OutputPath>
77
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
8-
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
8+
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
99
</PropertyGroup>
1010

1111
<ItemGroup>

Runtimes/NET/BepInEx.NET.Framework.Launcher/BepInEx.NET.Framework.Launcher.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<PropertyGroup>
33
<Description>BepInEx support library for .NET Framework games</Description>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net452</TargetFramework>
5+
<TargetFrameworks>net40;net452</TargetFrameworks>
66
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
7-
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
7+
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
88
<PlatformTarget>x86</PlatformTarget>
99
<OutputPath>$(BuildDir)/NET.Framework</OutputPath>
1010
</PropertyGroup>

Runtimes/NET/BepInEx.NET.Shared/BepInEx.NET.Shared.shproj

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
<ProjectGuid>067bcc8c-fc25-4929-b4f4-c6a5a7496994</ProjectGuid>
55
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
66
</PropertyGroup>
7-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
8-
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props"/>
9-
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props"/>
10-
<PropertyGroup/>
11-
<Import Project="BepInEx.NetLauncher.Shared.projitems" Label="Shared"/>
12-
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets"/>
13-
</Project>
7+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
8+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
9+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
10+
<PropertyGroup />
11+
<ItemGroup>
12+
<Compile Include="SharedEntrypoint.cs" />
13+
</ItemGroup>
14+
<Import Project="BepInEx.NetLauncher.Shared.projitems" Label="Shared" />
15+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
16+
</Project>

build/DistributionTarget.cs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
1-
using System;
1+
using System;
22

3-
readonly record struct DistributionTarget(string DistributionIdentifier, string RuntimeIndentifier)
3+
readonly struct DistributionTarget
44
{
5-
public readonly string Arch = RuntimeIndentifier.Split('-')[1];
6-
public readonly string Engine = DistributionIdentifier.Split('.')[0];
7-
public readonly string Os = RuntimeIndentifier.Split('-')[0];
8-
public readonly string Runtime = DistributionIdentifier.Split('.')[1];
9-
public readonly string Target = $"{DistributionIdentifier}-{RuntimeIndentifier}";
5+
public DistributionTarget(string distributionIdentifier, string runtimeIdentifier)
6+
{
7+
DistributionIdentifier = distributionIdentifier;
8+
RuntimeIdentifier = runtimeIdentifier;
9+
FrameworkTarget = null;
10+
11+
Os = RuntimeIdentifier.Split('-')[0];
12+
Arch = RuntimeIdentifier.Split('-')[1];
13+
Engine = DistributionIdentifier.Split('.')[0];
14+
Runtime = DistributionIdentifier.Split('.')[1];
15+
Target = $"{DistributionIdentifier}-{RuntimeIdentifier}";
16+
}
17+
18+
public DistributionTarget(string distributionIdentifier, string runtimeIdentifier, string frameworkTarget) : this(distributionIdentifier, runtimeIdentifier)
19+
{
20+
FrameworkTarget = frameworkTarget;
21+
Target = $"{DistributionIdentifier}-{FrameworkTarget}-{RuntimeIdentifier}";
22+
}
23+
24+
public readonly string DistributionIdentifier;
25+
public readonly string RuntimeIdentifier;
26+
public readonly string FrameworkTarget;
27+
28+
public readonly string Arch;
29+
public readonly string Engine;
30+
public readonly string Os;
31+
public readonly string Runtime;
32+
public readonly string Target;
1033

1134
public string ClearOsName => Os switch
1235
{

build/Program.cs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ public enum ProjectBuildType
5050
new("Unity.IL2CPP", "win-x64"),
5151
new("Unity.IL2CPP", "linux-x64"),
5252
new("Unity.IL2CPP", "macos-x64"),
53-
new("NET.Framework", "win-x64"),
54-
new("NET.CoreCLR", "win-x64")
53+
new("NET.Framework", "win-x86", "net40"),
54+
new("NET.Framework", "win-x86", "net452"),
55+
new("NET.CoreCLR", "win-x64", "netcoreapp3.1"),
56+
new("NET.CoreCLR", "win-x64", "net6.0")
5557
};
5658

5759

@@ -241,8 +243,12 @@ public override void Run(BuildContext ctx)
241243
ctx.CreateDirectory(bepInExDir.Combine("patchers"));
242244

243245
File.WriteAllText(targetDir.CombineWithFilePath("changelog.txt").FullPath, changelog);
244-
foreach (var filePath in ctx.GetFiles(ctx.OutputDirectory.Combine(dist.DistributionIdentifier)
245-
.Combine("*.*").FullPath))
246+
247+
var sourceDirectory = ctx.OutputDirectory.Combine(dist.DistributionIdentifier);
248+
if (dist.FrameworkTarget != null)
249+
sourceDirectory = sourceDirectory.Combine(dist.FrameworkTarget);
250+
251+
foreach (var filePath in ctx.GetFiles(sourceDirectory.Combine("*.*").FullPath))
246252
ctx.CopyFileToDirectory(filePath, bepInExCoreDir);
247253

248254
if (dist.Engine == "Unity")
@@ -269,21 +275,24 @@ public override void Run(BuildContext ctx)
269275
{
270276
ctx.CopyFile(ctx.CacheDirectory.Combine("dobby").Combine($"dobby_{dist.Os}").CombineWithFilePath($"{dist.DllPrefix}dobby_{dist.Arch}.{dist.DllExtension}"),
271277
bepInExCoreDir.CombineWithFilePath($"{dist.DllPrefix}dobby.{dist.DllExtension}"));
272-
ctx.CopyDirectory(ctx.CacheDirectory.Combine("dotnet").Combine(dist.RuntimeIndentifier),
278+
ctx.CopyDirectory(ctx.CacheDirectory.Combine("dotnet").Combine(dist.RuntimeIdentifier),
273279
targetDir.Combine("dotnet"));
274280
}
275281
}
276-
277-
if (dist.DistributionIdentifier == "NET.Framework")
282+
else if (dist.Engine == "NET")
278283
{
279-
ctx.DeleteFile(bepInExCoreDir.CombineWithFilePath("BepInEx.NET.Framework.Launcher.exe.config"));
280-
foreach (var filePath in ctx.GetFiles(bepInExCoreDir.Combine("BepInEx.NET.*").FullPath))
281-
ctx.MoveFileToDirectory(filePath, targetDir);
282-
}
284+
if (dist.Runtime == "Framework")
285+
{
286+
ctx.DeleteFile(bepInExCoreDir.CombineWithFilePath("BepInEx.NET.Framework.Launcher.exe.config"));
283287

284-
if (dist.DistributionIdentifier == "NET.CoreCLR")
285-
foreach (var filePath in ctx.GetFiles(bepInExCoreDir.Combine("BepInEx.NET.CoreCLR.*").FullPath))
286-
ctx.MoveFileToDirectory(filePath, targetDir);
288+
ctx.MoveFileToDirectory(bepInExCoreDir.CombineWithFilePath("BepInEx.NET.Framework.Launcher.exe"), targetDir);
289+
}
290+
else if (dist.Runtime == "CoreCLR")
291+
{
292+
foreach (var filePath in ctx.GetFiles(bepInExCoreDir.Combine("BepInEx.NET.CoreCLR.*").FullPath))
293+
ctx.MoveFileToDirectory(filePath, targetDir);
294+
}
295+
}
287296
}
288297
}
289298
}
@@ -347,7 +356,7 @@ public override void Run(BuildContext ctx)
347356
{
348357
["file"] = $"BepInEx-{d.Target}-{ctx.BuildPackageVersion}.zip",
349358
["description"] =
350-
$"BepInEx {d.Engine} ({d.Runtime}) for {d.ClearOsName} ({d.Arch}) games"
359+
$"BepInEx {d.Engine} ({d.Runtime}{(d.FrameworkTarget == null ? "" : " " + d.FrameworkTarget)}) for {d.ClearOsName} ({d.Arch}) games"
351360
}).ToArray()
352361
});
353362
}

0 commit comments

Comments
 (0)