diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 00000000..727dfd76 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "cake.tool": { + "version": "0.38.5", + "commands": [ + "dotnet-cake" + ] + } + } +} \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..e75f5389 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,29 @@ +name: Cake + +on: + push: + branches: [ reactor ] + pull_request: + branches: [ reactor ] + +jobs: + build: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.101 + + - name: Cake Action + uses: cake-build/cake-action@v1.2.0 + + - uses: actions/upload-artifact@v2 + with: + name: BepInEx-reactor + path: bin/dist/BepInEx_UnityIL2CPP_x86*.zip diff --git a/BepInEx.Core/Contract/Attributes.cs b/BepInEx.Core/Contract/Attributes.cs index f18ff3f7..5a76d818 100644 --- a/BepInEx.Core/Contract/Attributes.cs +++ b/BepInEx.Core/Contract/Attributes.cs @@ -5,6 +5,7 @@ using System.Reflection; using BepInEx.Bootstrap; using Mono.Cecil; +using MonoMod.Utils; namespace BepInEx { @@ -33,14 +34,14 @@ public class BepInPlugin : Attribute /// public SemVer.Version Version { get; protected set; } - /// The unique identifier of the plugin. Should not change between plugin versions. - /// The user friendly name of the plugin. Is able to be changed between versions. - /// The specific version of the plugin. - public BepInPlugin(string GUID, string Name, string Version) + /// The unique identifier of the plugin. Should not change between plugin versions. + /// The user friendly name of the plugin. Is able to be changed between versions. + /// The specific version of the plugin. + public BepInPlugin(string guid, string name = null, string version = null) { - this.GUID = GUID; - this.Name = Name; - this.Version = TryParseLongVersion(Version); + this.GUID = guid; + this.Name = name; + this.Version = TryParseLongVersion(version); } private static SemVer.Version TryParseLongVersion(string version) @@ -67,7 +68,66 @@ internal static BepInPlugin FromCecilType(TypeDefinition td) if (attr == null) return null; - return new BepInPlugin((string)attr.ConstructorArguments[0].Value, (string)attr.ConstructorArguments[1].Value, (string)attr.ConstructorArguments[2].Value); + var guid = (string)attr.ConstructorArguments[0].Value; + var name = (string)attr.ConstructorArguments[1].Value; + var version = (string)attr.ConstructorArguments[2].Value; + + var assembly = td.Module.Assembly; + + if (name == null) + { + name = assembly.Name.Name; + + var nameAttribute = assembly.GetCustomAttribute(typeof(AssemblyTitleAttribute).FullName); + if (nameAttribute != null && nameAttribute.ConstructorArguments.Count == 1) + { + name = (string)nameAttribute.ConstructorArguments.Single().Value; + } + } + + if (version == null) + { + version = assembly.Name.Version.ToString(); + + var versionAttribute = assembly.GetCustomAttribute(typeof(AssemblyInformationalVersionAttribute).FullName); + if (versionAttribute != null && versionAttribute.ConstructorArguments.Count == 1) + { + version = (string)versionAttribute.ConstructorArguments.Single().Value; + } + } + + return new BepInPlugin(guid, name, version); + } + + internal void Update(Type pluginType) + { + var assembly = pluginType.Assembly; + + if (Name == null) + { + Name = assembly.GetName().Name; + + var nameAttribute = MetadataHelper.GetAttributes(assembly).Single(); + if (nameAttribute != null) + { + Name = nameAttribute.Title; + } + } + + if (Version == null) + { + var version = assembly.GetName().Version; + Version = new SemVer.Version(version.Major, version.Minor, version.Build != -1 ? version.Build : 0); + + var versionAttribute = MetadataHelper.GetAttributes(assembly).Single(); + if (versionAttribute != null) + { + if (SemVer.Version.TryParse(versionAttribute.InformationalVersion, out var v)) + { + Version = v; + } + } + } } } @@ -264,7 +324,10 @@ public static BepInPlugin GetMetadata(Type pluginType) if (attributes.Length == 0) return null; - return (BepInPlugin)attributes[0]; + var attribute = (BepInPlugin)attributes[0]; + attribute.Update(pluginType); + + return attribute; } /// diff --git a/BepInEx.IL2CPP/BepInEx.IL2CPP.csproj b/BepInEx.IL2CPP/BepInEx.IL2CPP.csproj index 3c9d64b3..079de501 100644 --- a/BepInEx.IL2CPP/BepInEx.IL2CPP.csproj +++ b/BepInEx.IL2CPP/BepInEx.IL2CPP.csproj @@ -28,10 +28,6 @@ ..\lib\Il2Cppmscorlib.dll False - - ..\lib\UnhollowerBaseLib.dll - True - ..\lib\UnityEngine-IL2CPP.dll False @@ -41,6 +37,8 @@ False il2cpp + + @@ -49,7 +47,7 @@ - + diff --git a/BepInEx.Shared/BepInEx.Shared.projitems b/BepInEx.Shared/BepInEx.Shared.projitems index c90c02a8..0ea36935 100644 --- a/BepInEx.Shared/BepInEx.Shared.projitems +++ b/BepInEx.Shared/BepInEx.Shared.projitems @@ -5,7 +5,7 @@ true E312EFD4-47ED-4DCE-B279-6B0EE314989F Copyright © 2020 BepInEx Team - 6.0.0 + 6.0.0-reactor BepInEx.Shared diff --git a/BepInExTests/BepInExTests.csproj b/BepInExTests/BepInExTests.csproj index 4d4a160e..264a52cc 100644 --- a/BepInExTests/BepInExTests.csproj +++ b/BepInExTests/BepInExTests.csproj @@ -22,7 +22,7 @@ - + diff --git a/build.cake b/build.cake index cde2b4c8..1dde30a0 100644 --- a/build.cake +++ b/build.cake @@ -4,9 +4,9 @@ #addin nuget:?package=Cake.Json&version=5.2.0 #addin nuget:?package=Newtonsoft.Json&version=12.0.3 -var target = Argument("target", "Build"); -var isBleedingEdge = Argument("bleeding_edge", false); -var buildId = Argument("build_id", 0); +var target = Argument("target", "Pack"); +var buildId = Argument("build_id", EnvironmentVariable("GITHUB_RUN_NUMBER", 0)); +var isBleedingEdge = Argument("bleeding_edge", buildId != 0); var lastBuildCommit = Argument("last_build_commit", ""); var buildVersion = ""; @@ -53,7 +53,7 @@ Task("Build") { var bepinExProperties = Directory("./BepInEx.Shared"); - buildVersion = FindRegexMatchGroupInFile(bepinExProperties + File("BepInEx.Shared.projitems"), @"\([0-9]+\.[0-9]+\.[0-9]+)\<\/Version\>", 1, System.Text.RegularExpressions.RegexOptions.None).Value; + buildVersion = FindRegexMatchGroupInFile(bepinExProperties + File("BepInEx.Shared.projitems"), @"\([0-9]+\.[0-9]+\.[0-9]+)-reactor\<\/Version\>", 1, System.Text.RegularExpressions.RegexOptions.None).Value; var buildSettings = new MSBuildSettings { Configuration = "Release", @@ -72,9 +72,13 @@ Task("Build") buildSettings.Properties["AssemblyVersion"] = new[] { buildVersion + "." + buildId }; - buildVersion += "-be." + buildId; + buildVersion += "-reactor." + buildId; buildSettings.Properties["Version"] = new[] { buildVersion }; + } + else + { + buildVersion += "-reactor"; } //buildSettings.Properties["TargetFrameworks"] = new []{ "net35" }; @@ -122,6 +126,7 @@ Task("DownloadDependencies") var monoPath = Directory("./bin/doorstop/mono"); var monoX64Path = doorstopPath + File("mono_x64.zip"); var monoX86Path = doorstopPath + File("mono_x86.zip"); + var baseLibs = doorstopPath + File("2019.4.9.zip"); CreateDirectory(monoPath); DownloadFile($"https://github.com/BepInEx/mono/releases/download/{MONO_VER}/mono-x64.zip", monoX64Path); @@ -131,6 +136,9 @@ Task("DownloadDependencies") ZipUncompress(monoX64Path, monoPath + Directory("x64")); ZipUncompress(monoX86Path, monoPath + Directory("x86")); + + DownloadFile("http://raw.githubusercontent.com/HerpDerpinstine/MelonLoader/master/BaseLibs/UnityDependencies/2019.4.9.zip", baseLibs); + ZipUncompress(baseLibs, doorstopPath + Directory("BaseLibs")); }); Task("MakeDist") @@ -190,13 +198,14 @@ Task("MakeDist") if (copyMono) { CopyDirectory("./bin/doorstop/mono/" + arch + "/mono", Directory(distArchDir) + Directory("mono")); + CopyDirectory("./bin/doorstop/BaseLibs", Directory(distArchDir) + Directory("BepInEx") + Directory("unhollowed") + Directory("base")); } } CopyFiles("./bin/" + Directory(originDir) + "/*.*", Directory(bepinDir) + Directory("core")); - FileWriteText(distArchDir + File("changelog.txt"), changelog); +// FileWriteText(distArchDir + File("changelog.txt"), changelog); if (platform == "NetLauncher") { diff --git a/lib/AssemblyUnhollower.exe b/lib/AssemblyUnhollower.exe deleted file mode 100644 index 4d76c47e..00000000 Binary files a/lib/AssemblyUnhollower.exe and /dev/null differ diff --git a/lib/UnhollowerBaseLib.dll b/lib/UnhollowerBaseLib.dll deleted file mode 100644 index 3c7682b5..00000000 Binary files a/lib/UnhollowerBaseLib.dll and /dev/null differ diff --git a/lib/UnhollowerRuntimeLib.dll b/lib/UnhollowerRuntimeLib.dll deleted file mode 100644 index 26634ea4..00000000 Binary files a/lib/UnhollowerRuntimeLib.dll and /dev/null differ