Add support for dotnet core for Windows
This commit is contained in:
13
.github/workflows/ci.yaml
vendored
13
.github/workflows/ci.yaml
vendored
@@ -18,7 +18,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mono --version
|
mono --version
|
||||||
make check
|
make check
|
||||||
mono ~/.nuget/packages/nunit.consolerunner/3.11.1/tools/nunit3-console.exe --noresult bin/OpenRA.Test.dll
|
|
||||||
|
|
||||||
- name: Check Mods
|
- name: Check Mods
|
||||||
run: |
|
run: |
|
||||||
@@ -27,18 +26,26 @@ jobs:
|
|||||||
make test
|
make test
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
name: Windows (Framework 4.7)
|
name: Windows (Net 5.0)
|
||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install .NET 5
|
||||||
|
uses: actions/setup-dotnet@v1
|
||||||
|
with:
|
||||||
|
dotnet-version: '5.0.x'
|
||||||
|
|
||||||
- name: Check Code
|
- name: Check Code
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
|
# Work around runtime failures on the GH Actions runner
|
||||||
|
dotnet nuget locals all --clear
|
||||||
.\make.ps1 check
|
.\make.ps1 check
|
||||||
Invoke-Expression "$home\.nuget\packages\nunit.consolerunner\3.11.1\tools\nunit3-console.exe --noresult bin/OpenRA.Test.dll"
|
dotnet build OpenRA.Test\OpenRA.Test.csproj -c Debug --nologo -p:TargetPlatform=win-x64
|
||||||
|
dotnet test bin\OpenRA.Test.dll --test-adapter-path:.
|
||||||
|
|
||||||
- name: Check Mods
|
- name: Check Mods
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
7
.github/workflows/packaging.yml
vendored
7
.github/workflows/packaging.yml
vendored
@@ -69,10 +69,15 @@ jobs:
|
|||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install .NET 5
|
||||||
|
uses: actions/setup-dotnet@v1
|
||||||
|
with:
|
||||||
|
dotnet-version: '5.0.x'
|
||||||
|
|
||||||
- name: Prepare Environment
|
- name: Prepare Environment
|
||||||
run: |
|
run: |
|
||||||
echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_ENV}
|
echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_ENV}
|
||||||
sudo apt install nsis
|
sudo apt install nsis wine64
|
||||||
|
|
||||||
- name: Package Installers
|
- name: Package Installers
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
10
INSTALL.md
10
INSTALL.md
@@ -8,18 +8,16 @@ Windows
|
|||||||
|
|
||||||
Compiling OpenRA requires the following dependencies:
|
Compiling OpenRA requires the following dependencies:
|
||||||
* [Windows PowerShell >= 4.0](http://microsoft.com/powershell) (included by default in recent Windows 10 versions)
|
* [Windows PowerShell >= 4.0](http://microsoft.com/powershell) (included by default in recent Windows 10 versions)
|
||||||
* [.NET Framework 4.7.2 (Developer Pack)](https://dotnet.microsoft.com/download/dotnet-framework/net472) (or via Visual Studio 2017)
|
* [.NET 5 SDK](https://dotnet.microsoft.com/download/dotnet/5.0) (or via Visual Studio)
|
||||||
* [.NET Core 2.2 SDK](https://dotnet.microsoft.com/download/dotnet-core/2.2) (or via Visual Studio 2017)
|
|
||||||
|
|
||||||
|
To compile OpenRA, open the `OpenRA.sln` solution in the main folder, build it from the command-line with `dotnet` or use the Makefile analogue command `make all` scripted in PowerShell syntax.
|
||||||
To compile OpenRA, open the `OpenRA.sln` solution in the main folder, build it from the command-line with MSBuild or use the Makefile analogue command `make all` scripted in PowerShell syntax.
|
|
||||||
|
|
||||||
Run the game with `launch-game.cmd`. It can be handed arguments that specify the exact mod one wishes to run, for example, run `launch-game.cmd Game.Mod=ra` to launch Red Alert, `launch-game.cmd Game.Mod=cnc` to start Tiberian dawn or `launch-game.cmd Game.Mod=d2k` to launch Dune 2000.
|
Run the game with `launch-game.cmd`. It can be handed arguments that specify the exact mod one wishes to run, for example, run `launch-game.cmd Game.Mod=ra` to launch Red Alert, `launch-game.cmd Game.Mod=cnc` to start Tiberian dawn or `launch-game.cmd Game.Mod=d2k` to launch Dune 2000.
|
||||||
|
|
||||||
Linux
|
Linux
|
||||||
=====
|
=====
|
||||||
|
|
||||||
Mono, version 5.18 or later, is required to compile OpenRA. You can add the [upstream mono repository](https://www.mono-project.com/download/stable/#download-lin) for your distro to obtain the latest version if your system packages are not sufficient.
|
Mono, version 6.4 or later, is required to compile OpenRA. You can add the [upstream mono repository](https://www.mono-project.com/download/stable/#download-lin) for your distro to obtain the latest version if your system packages are not sufficient.
|
||||||
|
|
||||||
To compile OpenRA, run `make` from the command line. After this one can run the game with `./launch-game.sh`. It is also possible to specify the mod you wish to run from the command line, e.g. with `./launch-game.sh Game.Mod=ts` if you wish to try the experimental Tiberian Sun mod.
|
To compile OpenRA, run `make` from the command line. After this one can run the game with `./launch-game.sh`. It is also possible to specify the mod you wish to run from the command line, e.g. with `./launch-game.sh Game.Mod=ts` if you wish to try the experimental Tiberian Sun mod.
|
||||||
|
|
||||||
@@ -99,7 +97,7 @@ macOS
|
|||||||
=====
|
=====
|
||||||
|
|
||||||
Before compiling OpenRA you must install the following dependencies:
|
Before compiling OpenRA you must install the following dependencies:
|
||||||
* [Mono >= 5.18](https://www.mono-project.com/download/stable/#download-mac)
|
* [Mono >= 6.4](https://www.mono-project.com/download/stable/#download-mac)
|
||||||
|
|
||||||
To compile OpenRA, run `make` from the command line. Run with `./launch-game.sh`.
|
To compile OpenRA, run `make` from the command line. Run with `./launch-game.sh`.
|
||||||
|
|
||||||
|
|||||||
12
Makefile
12
Makefile
@@ -28,14 +28,14 @@
|
|||||||
############################## TOOLCHAIN ###############################
|
############################## TOOLCHAIN ###############################
|
||||||
#
|
#
|
||||||
# List of .NET assemblies that we can guarantee exist
|
# List of .NET assemblies that we can guarantee exist
|
||||||
WHITELISTED_OPENRA_ASSEMBLIES = OpenRA.exe OpenRA.Utility.exe OpenRA.Server.exe OpenRA.Platforms.Default.dll OpenRA.Game.dll OpenRA.Mods.Common.dll OpenRA.Mods.Cnc.dll OpenRA.Mods.D2k.dll
|
WHITELISTED_OPENRA_ASSEMBLIES = OpenRA.dll OpenRA.Utility.dll OpenRA.Server.dll OpenRA.Platforms.Default.dll OpenRA.Game.dll OpenRA.Mods.Common.dll OpenRA.Mods.Cnc.dll OpenRA.Mods.D2k.dll
|
||||||
|
|
||||||
# These are explicitly shipped alongside our core files by the packaging script
|
# These are explicitly shipped alongside our core files by the packaging script
|
||||||
WHITELISTED_THIRDPARTY_ASSEMBLIES = ICSharpCode.SharpZipLib.dll FuzzyLogicLibrary.dll Eluant.dll BeaconLib.dll Open.Nat.dll SDL2-CS.dll OpenAL-CS.Core.dll DiscordRPC.dll Newtonsoft.Json.dll
|
WHITELISTED_THIRDPARTY_ASSEMBLIES = ICSharpCode.SharpZipLib.dll FuzzyLogicLibrary.dll Eluant.dll BeaconLib.dll Open.Nat.dll SDL2-CS.dll OpenAL-CS.Core.dll DiscordRPC.dll Newtonsoft.Json.dll
|
||||||
|
|
||||||
# These are shipped in our custom minimal mono runtime and also available in the full system-installed .NET/mono stack
|
# These are shipped in our custom minimal mono runtime and also available in the full system-installed .NET/mono stack
|
||||||
# This list *must* be kept in sync with the files packaged by the AppImageSupport and OpenRALauncherOSX repositories
|
# This list *must* be kept in sync with the files packaged by the AppImageSupport and OpenRALauncherOSX repositories
|
||||||
WHITELISTED_CORE_ASSEMBLIES = mscorlib.dll System.dll System.Configuration.dll System.Core.dll System.Numerics.dll System.Security.dll System.Xml.dll Mono.Security.dll netstandard.dll
|
WHITELISTED_CORE_ASSEMBLIES = mscorlib.dll System.dll System.Configuration.dll System.Core.dll System.Numerics.dll System.Security.dll System.Xml.dll Mono.Security.dll netstandard.dll Microsoft.Win32.Registry.dll System.Security.AccessControl.dll System.Security.Principal.Windows.dll System.Xml.Linq.dll System.Runtime.Serialization.dll
|
||||||
|
|
||||||
######################### UTILITIES/SETTINGS ###########################
|
######################### UTILITIES/SETTINGS ###########################
|
||||||
#
|
#
|
||||||
@@ -78,13 +78,13 @@ endif
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OPENRA_UTILITY = ENGINE_DIR=".." $(MONO) --debug bin/OpenRA.Utility.exe
|
OPENRA_UTILITY = ENGINE_DIR=".." $(MONO) --debug bin/OpenRA.Utility.dll
|
||||||
|
|
||||||
##################### DEVELOPMENT BUILDS AND TESTS #####################
|
##################### DEVELOPMENT BUILDS AND TESTS #####################
|
||||||
#
|
#
|
||||||
all:
|
all:
|
||||||
@command -v $(firstword $(MSBUILD)) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 5.18."; exit 1)
|
@command -v $(firstword $(MSBUILD)) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 5.18."; exit 1)
|
||||||
@$(MSBUILD) -t:Build -restore -p:Configuration=Release -p:TargetPlatform=$(TARGETPLATFORM)
|
@$(MSBUILD) -t:Build -restore -p:Configuration=Release -p:TargetPlatform=$(TARGETPLATFORM) -p:Mono=true -p:DefineConstants="MONO"
|
||||||
ifeq ($(TARGETPLATFORM), unix-generic)
|
ifeq ($(TARGETPLATFORM), unix-generic)
|
||||||
@./configure-system-libraries.sh
|
@./configure-system-libraries.sh
|
||||||
endif
|
endif
|
||||||
@@ -92,13 +92,13 @@ endif
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
@-$(RM_RF) ./bin ./*/bin ./*/obj
|
@-$(RM_RF) ./bin ./*/bin ./*/obj
|
||||||
@$(MSBUILD) -t:Clean
|
@$(MSBUILD) -t:Clean -p:Mono=true
|
||||||
@-$(RM_F) IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP
|
@-$(RM_F) IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP
|
||||||
|
|
||||||
check:
|
check:
|
||||||
@echo
|
@echo
|
||||||
@echo "Compiling in debug mode..."
|
@echo "Compiling in debug mode..."
|
||||||
@$(MSBUILD) -t:build -restore -p:Configuration=Debug
|
@$(MSBUILD) -t:build -restore -p:Configuration=Debug -p:TargetPlatform=$(TARGETPLATFORM) -p:Mono=true -p:DefineConstants="MONO"
|
||||||
@echo
|
@echo
|
||||||
@echo "Checking runtime assemblies..."
|
@echo "Checking runtime assemblies..."
|
||||||
@$(OPENRA_UTILITY) all --check-runtime-assemblies $(WHITELISTED_OPENRA_ASSEMBLIES) $(WHITELISTED_THIRDPARTY_ASSEMBLIES) $(WHITELISTED_CORE_ASSEMBLIES)
|
@$(OPENRA_UTILITY) all --check-runtime-assemblies $(WHITELISTED_OPENRA_ASSEMBLIES) $(WHITELISTED_THIRDPARTY_ASSEMBLIES) $(WHITELISTED_CORE_ASSEMBLIES)
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ namespace OpenRA
|
|||||||
EngineVersion = "Unknown";
|
EngineVersion = "Unknown";
|
||||||
|
|
||||||
Console.WriteLine("Engine version is {0}", EngineVersion);
|
Console.WriteLine("Engine version is {0}", EngineVersion);
|
||||||
|
Console.WriteLine("Runtime: {0}", Platform.RuntimeVersion);
|
||||||
|
|
||||||
// Special case handling of Game.Mod argument: if it matches a real filesystem path
|
// Special case handling of Game.Mod argument: if it matches a real filesystem path
|
||||||
// then we use this to override the mod search path, and replace it with the mod id
|
// then we use this to override the mod search path, and replace it with the mod id
|
||||||
@@ -329,9 +330,16 @@ namespace OpenRA
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var rendererPath = Path.Combine(Platform.BinDir, "OpenRA.Platforms." + p + ".dll");
|
var rendererPath = Path.Combine(Platform.BinDir, "OpenRA.Platforms." + p + ".dll");
|
||||||
var assembly = Assembly.LoadFile(rendererPath);
|
|
||||||
|
|
||||||
|
#if !MONO
|
||||||
|
var loader = new AssemblyLoader(rendererPath);
|
||||||
|
var platformType = loader.LoadDefaultAssembly().GetTypes().SingleOrDefault(t => typeof(IPlatform).IsAssignableFrom(t));
|
||||||
|
|
||||||
|
#else
|
||||||
|
var assembly = Assembly.LoadFile(rendererPath);
|
||||||
var platformType = assembly.GetTypes().SingleOrDefault(t => typeof(IPlatform).IsAssignableFrom(t));
|
var platformType = assembly.GetTypes().SingleOrDefault(t => typeof(IPlatform).IsAssignableFrom(t));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (platformType == null)
|
if (platformType == null)
|
||||||
throw new InvalidOperationException("Platform dll must include exactly one IPlatform implementation.");
|
throw new InvalidOperationException("Platform dll must include exactly one IPlatform implementation.");
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
|
using OpenRA.Support;
|
||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
@@ -42,25 +43,48 @@ namespace OpenRA
|
|||||||
if (resolvedPath == null)
|
if (resolvedPath == null)
|
||||||
throw new FileNotFoundException("Assembly `{0}` not found.".F(path));
|
throw new FileNotFoundException("Assembly `{0}` not found.".F(path));
|
||||||
|
|
||||||
// .NET doesn't provide any way of querying the metadata of an assembly without either:
|
LoadAssembly(assemblyList, resolvedPath);
|
||||||
// (a) loading duplicate data into the application domain, breaking the world.
|
|
||||||
// (b) crashing if the assembly has already been loaded.
|
|
||||||
// We can't check the internal name of the assembly, so we'll work off the data instead
|
|
||||||
var hash = CryptoUtil.SHA1Hash(File.ReadAllBytes(resolvedPath));
|
|
||||||
|
|
||||||
if (!ResolvedAssemblies.TryGetValue(hash, out var assembly))
|
|
||||||
{
|
|
||||||
assembly = Assembly.LoadFile(resolvedPath);
|
|
||||||
ResolvedAssemblies.Add(hash, assembly);
|
|
||||||
}
|
|
||||||
|
|
||||||
assemblyList.Add(assembly);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
|
AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
|
||||||
assemblies = assemblyList.SelectMany(asm => asm.GetNamespaces().Select(ns => (asm, ns))).ToArray();
|
assemblies = assemblyList.SelectMany(asm => asm.GetNamespaces().Select(ns => (asm, ns))).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LoadAssembly(List<Assembly> assemblyList, string resolvedPath)
|
||||||
|
{
|
||||||
|
// .NET doesn't provide any way of querying the metadata of an assembly without either:
|
||||||
|
// (a) loading duplicate data into the application domain, breaking the world.
|
||||||
|
// (b) crashing if the assembly has already been loaded.
|
||||||
|
// We can't check the internal name of the assembly, so we'll work off the data instead
|
||||||
|
var hash = CryptoUtil.SHA1Hash(File.ReadAllBytes(resolvedPath));
|
||||||
|
|
||||||
|
if (!ResolvedAssemblies.TryGetValue(hash, out var assembly))
|
||||||
|
{
|
||||||
|
#if MONO
|
||||||
|
assembly = Assembly.LoadFile(resolvedPath);
|
||||||
|
ResolvedAssemblies.Add(hash, assembly);
|
||||||
|
|
||||||
|
// Allow mods to use libraries.
|
||||||
|
var assemblyPath = Path.GetDirectoryName(resolvedPath);
|
||||||
|
if (assemblyPath != null)
|
||||||
|
{
|
||||||
|
foreach (var referencedAssembly in assembly.GetReferencedAssemblies())
|
||||||
|
{
|
||||||
|
var depedencyPath = Path.Combine(assemblyPath, referencedAssembly.Name + ".dll");
|
||||||
|
if (File.Exists(depedencyPath))
|
||||||
|
LoadAssembly(assemblyList, depedencyPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
var loader = new AssemblyLoader(resolvedPath);
|
||||||
|
assembly = loader.LoadDefaultAssembly();
|
||||||
|
ResolvedAssemblies.Add(hash, assembly);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
assemblyList.Add(assembly);
|
||||||
|
}
|
||||||
|
|
||||||
Assembly ResolveAssembly(object sender, ResolveEventArgs e)
|
Assembly ResolveAssembly(object sender, ResolveEventArgs e)
|
||||||
{
|
{
|
||||||
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
@@ -39,6 +39,11 @@
|
|||||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
|
||||||
<AdditionalFiles Include="../stylecop.json" />
|
<AdditionalFiles Include="../stylecop.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup Condition="'$(Mono)' == ''">
|
||||||
|
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="5.0.0-preview.3-runtime.20214.6" />
|
||||||
|
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
|
||||||
|
</ItemGroup>
|
||||||
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
|
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
|
||||||
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
|
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
|
||||||
<ItemGroup Condition="'$(Configuration)'=='Release'">
|
<ItemGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
|||||||
363
OpenRA.Game/Support/AssemblyLoader.cs
Normal file
363
OpenRA.Game/Support/AssemblyLoader.cs
Normal file
@@ -0,0 +1,363 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// Not used/usable on Mono. Only used for Dotnet Core.
|
||||||
|
// Based on https://github.com/natemcmaster/DotNetCorePlugins and used under the terms of the Apache 2.0 license
|
||||||
|
#if !MONO
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.Loader;
|
||||||
|
using Microsoft.Extensions.DependencyModel;
|
||||||
|
|
||||||
|
namespace OpenRA.Support
|
||||||
|
{
|
||||||
|
public class AssemblyLoader
|
||||||
|
{
|
||||||
|
readonly string mainAssembly;
|
||||||
|
readonly AssemblyLoadContext context;
|
||||||
|
|
||||||
|
public Assembly LoadDefaultAssembly() => context.LoadFromAssemblyPath(mainAssembly);
|
||||||
|
|
||||||
|
public AssemblyLoader(string assemblyFile)
|
||||||
|
{
|
||||||
|
mainAssembly = assemblyFile;
|
||||||
|
var baseDir = Path.GetDirectoryName(assemblyFile);
|
||||||
|
|
||||||
|
context = CreateLoadContext(baseDir, assemblyFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AssemblyLoadContext CreateLoadContext(string baseDir, string assemblyFile)
|
||||||
|
{
|
||||||
|
var depsJsonFile = Path.Combine(baseDir, Path.GetFileNameWithoutExtension(assemblyFile) + ".deps.json");
|
||||||
|
|
||||||
|
var builder = new AssemblyLoadContextBuilder();
|
||||||
|
|
||||||
|
builder.TryAddDependencyContext(depsJsonFile, out _);
|
||||||
|
builder.SetBaseDirectory(baseDir);
|
||||||
|
|
||||||
|
return builder.Build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AssemblyLoadContextBuilder
|
||||||
|
{
|
||||||
|
readonly Dictionary<string, ManagedLibrary> managedLibraries = new Dictionary<string, ManagedLibrary>(StringComparer.Ordinal);
|
||||||
|
readonly Dictionary<string, NativeLibrary> nativeLibraries = new Dictionary<string, NativeLibrary>(StringComparer.Ordinal);
|
||||||
|
string basePath;
|
||||||
|
|
||||||
|
public AssemblyLoadContext Build()
|
||||||
|
{
|
||||||
|
return new ManagedLoadContext(basePath, managedLibraries, nativeLibraries);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssemblyLoadContextBuilder SetBaseDirectory(string path)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(path))
|
||||||
|
throw new ArgumentException("Argument must not be null or empty.", nameof(path));
|
||||||
|
|
||||||
|
if (!Path.IsPathRooted(path))
|
||||||
|
throw new ArgumentException("Argument must be a full path.", nameof(path));
|
||||||
|
|
||||||
|
basePath = path;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssemblyLoadContextBuilder AddManagedLibrary(ManagedLibrary library)
|
||||||
|
{
|
||||||
|
managedLibraries.Add(library.Name.Name, library);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssemblyLoadContextBuilder AddNativeLibrary(NativeLibrary library)
|
||||||
|
{
|
||||||
|
ValidateRelativePath(library.AppLocalPath);
|
||||||
|
nativeLibraries.Add(library.Name, library);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ValidateRelativePath(string probingPath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(probingPath))
|
||||||
|
throw new ArgumentException("Value must not be null or empty.", nameof(probingPath));
|
||||||
|
|
||||||
|
if (Path.IsPathRooted(probingPath))
|
||||||
|
throw new ArgumentException("Argument must be a relative path.", nameof(probingPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ManagedLoadContext : AssemblyLoadContext
|
||||||
|
{
|
||||||
|
readonly string basePath;
|
||||||
|
readonly Dictionary<string, ManagedLibrary> managedAssemblies;
|
||||||
|
readonly Dictionary<string, NativeLibrary> nativeLibraries;
|
||||||
|
|
||||||
|
static readonly string[] NativeLibraryExtensions;
|
||||||
|
static readonly string[] NativeLibraryPrefixes;
|
||||||
|
|
||||||
|
static readonly string[] ManagedAssemblyExtensions =
|
||||||
|
{
|
||||||
|
".dll",
|
||||||
|
".ni.dll",
|
||||||
|
".exe",
|
||||||
|
".ni.exe"
|
||||||
|
};
|
||||||
|
|
||||||
|
static ManagedLoadContext()
|
||||||
|
{
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
{
|
||||||
|
NativeLibraryPrefixes = new[] { "" };
|
||||||
|
NativeLibraryExtensions = new[] { ".dll" };
|
||||||
|
}
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
|
{
|
||||||
|
NativeLibraryPrefixes = new[] { "", "lib", };
|
||||||
|
NativeLibraryExtensions = new[] { ".dylib" };
|
||||||
|
}
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
{
|
||||||
|
NativeLibraryPrefixes = new[] { "", "lib" };
|
||||||
|
NativeLibraryExtensions = new[] { ".so", ".so.1" };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NativeLibraryPrefixes = Array.Empty<string>();
|
||||||
|
NativeLibraryExtensions = Array.Empty<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ManagedLoadContext(string baseDirectory, Dictionary<string, ManagedLibrary> managedAssemblies, Dictionary<string, NativeLibrary> nativeLibraries)
|
||||||
|
{
|
||||||
|
basePath = baseDirectory ?? throw new ArgumentNullException(nameof(baseDirectory));
|
||||||
|
this.managedAssemblies = managedAssemblies ?? throw new ArgumentNullException(nameof(managedAssemblies));
|
||||||
|
this.nativeLibraries = nativeLibraries ?? throw new ArgumentNullException(nameof(nativeLibraries));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Assembly Load(AssemblyName assemblyName)
|
||||||
|
{
|
||||||
|
// If default context is preferred, check first for types in the default context unless the dependency has been declared as private
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var defaultAssembly = Default.LoadFromAssemblyName(assemblyName);
|
||||||
|
if (defaultAssembly != null)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Swallow errors in loading from the default context
|
||||||
|
}
|
||||||
|
|
||||||
|
if (managedAssemblies.TryGetValue(assemblyName.Name, out var library) && SearchForLibrary(library, out var path))
|
||||||
|
return LoadFromAssemblyPath(path);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
|
||||||
|
{
|
||||||
|
foreach (var prefix in NativeLibraryPrefixes)
|
||||||
|
if (nativeLibraries.TryGetValue(prefix + unmanagedDllName, out var library) && SearchForLibrary(library, prefix, out var path))
|
||||||
|
return LoadUnmanagedDllFromPath(path);
|
||||||
|
|
||||||
|
return base.LoadUnmanagedDll(unmanagedDllName);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SearchForLibrary(ManagedLibrary library, out string path)
|
||||||
|
{
|
||||||
|
// 1. Search in base path
|
||||||
|
foreach (var ext in ManagedAssemblyExtensions)
|
||||||
|
{
|
||||||
|
var local = Path.Combine(basePath, library.Name.Name + ext);
|
||||||
|
if (File.Exists(local))
|
||||||
|
{
|
||||||
|
path = local;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
path = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SearchForLibrary(NativeLibrary library, string prefix, out string path)
|
||||||
|
{
|
||||||
|
// 1. Search in base path
|
||||||
|
foreach (var ext in NativeLibraryExtensions)
|
||||||
|
{
|
||||||
|
var candidate = Path.Combine(basePath, $"{prefix}{library.Name}{ext}");
|
||||||
|
if (File.Exists(candidate))
|
||||||
|
{
|
||||||
|
path = candidate;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Search in base path + app local (for portable deployments of netcoreapp)
|
||||||
|
var local = Path.Combine(basePath, library.AppLocalPath);
|
||||||
|
if (File.Exists(local))
|
||||||
|
{
|
||||||
|
path = local;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
path = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ManagedLibrary
|
||||||
|
{
|
||||||
|
public AssemblyName Name { get; private set; }
|
||||||
|
|
||||||
|
public static ManagedLibrary CreateFromPackage(string assetPath)
|
||||||
|
{
|
||||||
|
return new ManagedLibrary
|
||||||
|
{
|
||||||
|
Name = new AssemblyName(Path.GetFileNameWithoutExtension(assetPath))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NativeLibrary
|
||||||
|
{
|
||||||
|
public string Name { get; private set; }
|
||||||
|
|
||||||
|
public string AppLocalPath { get; private set; }
|
||||||
|
|
||||||
|
public static NativeLibrary CreateFromPackage(string assetPath)
|
||||||
|
{
|
||||||
|
return new NativeLibrary
|
||||||
|
{
|
||||||
|
Name = Path.GetFileNameWithoutExtension(assetPath),
|
||||||
|
AppLocalPath = assetPath
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DependencyContextExtensions
|
||||||
|
{
|
||||||
|
public static AssemblyLoadContextBuilder TryAddDependencyContext(this AssemblyLoadContextBuilder builder, string depsFilePath, out Exception error)
|
||||||
|
{
|
||||||
|
error = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
builder.AddDependencyContext(depsFilePath);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
error = ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssemblyLoadContextBuilder AddDependencyContext(this AssemblyLoadContextBuilder builder, string depsFilePath)
|
||||||
|
{
|
||||||
|
var reader = new DependencyContextJsonReader();
|
||||||
|
using (var file = File.OpenRead(depsFilePath))
|
||||||
|
{
|
||||||
|
var deps = reader.Read(file);
|
||||||
|
builder.SetBaseDirectory(Path.GetDirectoryName(depsFilePath));
|
||||||
|
builder.AddDependencyContext(deps);
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
static string GetFallbackRid()
|
||||||
|
{
|
||||||
|
string ridBase;
|
||||||
|
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
ridBase = "win10";
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
ridBase = "linux";
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
|
ridBase = "osx.10.12";
|
||||||
|
else
|
||||||
|
return "any";
|
||||||
|
|
||||||
|
switch (RuntimeInformation.OSArchitecture)
|
||||||
|
{
|
||||||
|
case Architecture.X86:
|
||||||
|
return ridBase + "-x86";
|
||||||
|
case Architecture.X64:
|
||||||
|
return ridBase + "-x64";
|
||||||
|
case Architecture.Arm:
|
||||||
|
return ridBase + "-arm";
|
||||||
|
case Architecture.Arm64:
|
||||||
|
return ridBase + "-arm64";
|
||||||
|
}
|
||||||
|
|
||||||
|
return ridBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssemblyLoadContextBuilder AddDependencyContext(this AssemblyLoadContextBuilder builder, DependencyContext dependencyContext)
|
||||||
|
{
|
||||||
|
var ridGraph = dependencyContext.RuntimeGraph.Any()
|
||||||
|
? dependencyContext.RuntimeGraph
|
||||||
|
: DependencyContext.Default.RuntimeGraph;
|
||||||
|
|
||||||
|
var rid = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier();
|
||||||
|
var fallbackRid = GetFallbackRid();
|
||||||
|
var fallbackGraph = ridGraph.FirstOrDefault(g => g.Runtime == rid)
|
||||||
|
?? ridGraph.FirstOrDefault(g => g.Runtime == fallbackRid)
|
||||||
|
?? new RuntimeFallbacks("any");
|
||||||
|
|
||||||
|
foreach (var managed in dependencyContext.ResolveRuntimeAssemblies(fallbackGraph))
|
||||||
|
builder.AddManagedLibrary(managed);
|
||||||
|
|
||||||
|
foreach (var native in dependencyContext.ResolveNativeAssets(fallbackGraph))
|
||||||
|
builder.AddNativeLibrary(native);
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
static IEnumerable<ManagedLibrary> ResolveRuntimeAssemblies(this DependencyContext depContext, RuntimeFallbacks runtimeGraph)
|
||||||
|
{
|
||||||
|
var rids = GetRids(runtimeGraph);
|
||||||
|
return from library in depContext.RuntimeLibraries
|
||||||
|
from assetPath in SelectAssets(rids, library.RuntimeAssemblyGroups)
|
||||||
|
select ManagedLibrary.CreateFromPackage(assetPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
static IEnumerable<NativeLibrary> ResolveNativeAssets(this DependencyContext depContext, RuntimeFallbacks runtimeGraph)
|
||||||
|
{
|
||||||
|
var rids = GetRids(runtimeGraph);
|
||||||
|
return from library in depContext.RuntimeLibraries
|
||||||
|
from assetPath in SelectAssets(rids, library.NativeLibraryGroups)
|
||||||
|
where !assetPath.EndsWith(".a", StringComparison.Ordinal)
|
||||||
|
select NativeLibrary.CreateFromPackage(assetPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
static IEnumerable<string> GetRids(RuntimeFallbacks runtimeGraph)
|
||||||
|
{
|
||||||
|
return Enumerable.Concat(new[] { runtimeGraph.Runtime }, runtimeGraph?.Fallbacks ?? Enumerable.Empty<string>());
|
||||||
|
}
|
||||||
|
|
||||||
|
static IEnumerable<string> SelectAssets(IEnumerable<string> rids, IEnumerable<RuntimeAssetGroup> groups)
|
||||||
|
{
|
||||||
|
foreach (var rid in rids)
|
||||||
|
{
|
||||||
|
var group = groups.FirstOrDefault(g => g.Runtime == rid);
|
||||||
|
if (group != null)
|
||||||
|
return group.AssetPaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
return groups.GetDefaultAssets();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework Condition="'$(Mono)' == ''">net5.0</TargetFramework>
|
||||||
|
<TargetFramework Condition="'$(Mono)' != ''">netstandard2.1</TargetFramework>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
@@ -17,6 +18,8 @@
|
|||||||
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
||||||
<Configurations>Release;Debug</Configurations>
|
<Configurations>Release;Debug</Configurations>
|
||||||
<AssemblyName>OpenRA</AssemblyName>
|
<AssemblyName>OpenRA</AssemblyName>
|
||||||
|
<IsPublishable Condition="'$(CopyGenericLauncher)' == 'False'">false</IsPublishable>
|
||||||
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetPlatform Condition="$([MSBuild]::IsOsPlatform('Windows'))">win-x64</TargetPlatform>
|
<TargetPlatform Condition="$([MSBuild]::IsOsPlatform('Windows'))">win-x64</TargetPlatform>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<LangVersion>7.3</LangVersion>
|
<LangVersion>7.3</LangVersion>
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||||
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<IsPublishable Condition="'$(CopyCncDll)' == 'False'">false</IsPublishable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
|
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
|
||||||
@@ -37,4 +38,4 @@
|
|||||||
<Analyzer Remove="@(Analyzer)" />
|
<Analyzer Remove="@(Analyzer)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<LangVersion>7.3</LangVersion>
|
<LangVersion>7.3</LangVersion>
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||||
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
|
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
|
||||||
<PackageReference Include="OpenRA-FuzzyLogicLibrary" Version="1.0.1" />
|
<PackageReference Include="OpenRA-FuzzyLogicLibrary" Version="1.0.1" />
|
||||||
<PackageReference Include="DiscordRichPresence" Version="1.0.150" />
|
<PackageReference Include="DiscordRichPresence" Version="1.0.150" />
|
||||||
<PackageReference Include="rix0rrr.BeaconLib" Version="1.0.2" />
|
<PackageReference Include="rix0rrr.BeaconLib" Version="1.0.2" />
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<LangVersion>7.3</LangVersion>
|
<LangVersion>7.3</LangVersion>
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||||
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<IsPublishable Condition="'$(CopyD2kDll)' == 'False'">false</IsPublishable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
|
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
|
||||||
@@ -37,4 +38,4 @@
|
|||||||
<Analyzer Remove="@(Analyzer)" />
|
<Analyzer Remove="@(Analyzer)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<LangVersion>7.3</LangVersion>
|
<LangVersion>7.3</LangVersion>
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||||
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetPlatform Condition="$([MSBuild]::IsOsPlatform('Windows'))">win-x64</TargetPlatform>
|
<TargetPlatform Condition="$([MSBuild]::IsOsPlatform('Windows'))">win-x64</TargetPlatform>
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ namespace OpenRA.Platforms.Default
|
|||||||
Name = "ThreadedGraphicsContext RenderThread",
|
Name = "ThreadedGraphicsContext RenderThread",
|
||||||
IsBackground = true
|
IsBackground = true
|
||||||
};
|
};
|
||||||
renderThread.SetApartmentState(ApartmentState.STA);
|
|
||||||
lock (syncObject)
|
lock (syncObject)
|
||||||
{
|
{
|
||||||
// Start and wait for the rendering thread to have initialized before returning.
|
// Start and wait for the rendering thread to have initialized before returning.
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework Condition="'$(Mono)' == ''">net5.0</TargetFramework>
|
||||||
|
<TargetFramework Condition="'$(Mono)' != ''">netstandard2.1</TargetFramework>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<LangVersion>7.3</LangVersion>
|
<LangVersion>7.3</LangVersion>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||||
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<IsPublishable>false</IsPublishable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
|
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
|
||||||
@@ -22,14 +23,12 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj" />
|
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj" />
|
||||||
<ProjectReference Include="..\OpenRA.Mods.Common\OpenRA.Mods.Common.csproj">
|
<ProjectReference Include="..\OpenRA.Mods.Common\OpenRA.Mods.Common.csproj">
|
||||||
<Private>False</Private>
|
<Private>True</Private>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="NUnit.Console" Version="3.11.1" />
|
<PackageReference Include="NUnit.Console" Version="3.11.1" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
|
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0-beta.1" />
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
|
||||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
|
||||||
<AdditionalFiles Include="../stylecop.json" />
|
<AdditionalFiles Include="../stylecop.json" />
|
||||||
@@ -40,4 +39,4 @@
|
|||||||
<Analyzer Remove="@(Analyzer)" />
|
<Analyzer Remove="@(Analyzer)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework Condition="'$(Mono)' == ''">net5.0</TargetFramework>
|
||||||
|
<TargetFramework Condition="'$(Mono)' != ''">netstandard2.1</TargetFramework>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>winexe</OutputType>
|
<OutputType>winexe</OutputType>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
|
<ApplicationIcon>$(LauncherIcon)</ApplicationIcon>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
@@ -10,14 +12,12 @@
|
|||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
|
||||||
<OutputPath>../bin</OutputPath>
|
<OutputPath>../bin</OutputPath>
|
||||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<ExternalConsole>false</ExternalConsole>
|
<ExternalConsole>false</ExternalConsole>
|
||||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||||
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
|
||||||
<Configurations>Release;Debug</Configurations>
|
<Configurations>Release;Debug</Configurations>
|
||||||
<AssemblyName>$(LauncherName)</AssemblyName>
|
<AssemblyName>$(LauncherName)</AssemblyName>
|
||||||
<ApplicationIcon>$(LauncherIcon)</ApplicationIcon>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
|
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
|
||||||
|
|||||||
@@ -58,9 +58,7 @@ Global
|
|||||||
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Release|Any CPU.Build.0 = Release|Any CPU
|
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{6CB8E1B7-6B36-4D93-8633-7C573E194AC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{6CB8E1B7-6B36-4D93-8633-7C573E194AC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{6CB8E1B7-6B36-4D93-8633-7C573E194AC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{6CB8E1B7-6B36-4D93-8633-7C573E194AC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{6CB8E1B7-6B36-4D93-8633-7C573E194AC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{6CB8E1B7-6B36-4D93-8633-7C573E194AC4}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{54DAE0E0-3125-49D3-992E-A0E931EB5FC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{54DAE0E0-3125-49D3-992E-A0E931EB5FC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{54DAE0E0-3125-49D3-992E-A0E931EB5FC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{54DAE0E0-3125-49D3-992E-A0E931EB5FC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{54DAE0E0-3125-49D3-992E-A0E931EB5FC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{54DAE0E0-3125-49D3-992E-A0E931EB5FC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ ShareAnonymizedIPs="${ShareAnonymizedIPs:-"True"}"
|
|||||||
SupportDir="${SupportDir:-""}"
|
SupportDir="${SupportDir:-""}"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
mono --debug bin/OpenRA.Server.exe Engine.EngineDir=".." Game.Mod="$Mod" \
|
mono --debug bin/OpenRA.Server.dll Engine.EngineDir=".." Game.Mod="$Mod" \
|
||||||
Server.Name="$Name" \
|
Server.Name="$Name" \
|
||||||
Server.ListenPort="$ListenPort" \
|
Server.ListenPort="$ListenPort" \
|
||||||
Server.AdvertiseOnline="$AdvertiseOnline" \
|
Server.AdvertiseOnline="$AdvertiseOnline" \
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Launch the engine with the appropriate arguments
|
# Launch the engine with the appropriate arguments
|
||||||
mono --debug bin/OpenRA.exe Engine.EngineDir=".." Engine.LaunchPath="$MODLAUNCHER" $MODARG "$@"
|
mono --debug bin/OpenRA.dll Engine.EngineDir=".." Engine.LaunchPath="$MODLAUNCHER" $MODARG "$@"
|
||||||
|
|
||||||
# Show a crash dialog if something went wrong
|
# Show a crash dialog if something went wrong
|
||||||
if [ $? != 0 ] && [ $? != 1 ]; then
|
if [ $? != 0 ] && [ $? != 1 ]; then
|
||||||
|
|||||||
4
make.ps1
4
make.ps1
@@ -10,7 +10,7 @@ function All-Command
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
dotnet build /p:Configuration=Release /nologo
|
dotnet build -c Release --nologo -p:TargetPlatform=win-x64
|
||||||
if ($lastexitcode -ne 0)
|
if ($lastexitcode -ne 0)
|
||||||
{
|
{
|
||||||
Write-Host "Build failed. If just the development tools failed to build, try installing Visual Studio. You may also still be able to run the game." -ForegroundColor Red
|
Write-Host "Build failed. If just the development tools failed to build, try installing Visual Studio. You may also still be able to run the game." -ForegroundColor Red
|
||||||
@@ -111,7 +111,7 @@ function Test-Command
|
|||||||
function Check-Command
|
function Check-Command
|
||||||
{
|
{
|
||||||
Write-Host "Compiling in debug configuration..." -ForegroundColor Cyan
|
Write-Host "Compiling in debug configuration..." -ForegroundColor Cyan
|
||||||
dotnet build /p:Configuration=Debug /nologo
|
dotnet build -c Debug --nologo -p:TargetPlatform=win-x64
|
||||||
if ($lastexitcode -ne 0)
|
if ($lastexitcode -ne 0)
|
||||||
{
|
{
|
||||||
Write-Host "Build failed." -ForegroundColor Red
|
Write-Host "Build failed." -ForegroundColor Red
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
[[prereqs]]
|
|
||||||
name = "net-4.7.2"
|
|
||||||
|
|
||||||
[[actions]]
|
[[actions]]
|
||||||
os = "windows"
|
os = "windows"
|
||||||
name = "Red Alert"
|
name = "Red Alert"
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
# Makefile (install target for local installs and downstream packaging)
|
# Makefile (install target for local installs and downstream packaging)
|
||||||
# Linux AppImage packaging
|
# Linux AppImage packaging
|
||||||
# macOS packaging
|
# macOS packaging
|
||||||
# Windows packaging
|
|
||||||
# Mod SDK Linux AppImage packaging
|
# Mod SDK Linux AppImage packaging
|
||||||
# Mod SDK macOS packaging
|
# Mod SDK macOS packaging
|
||||||
# Mod SDK Windows packaging
|
# Mod SDK Windows packaging
|
||||||
@@ -33,26 +32,27 @@ install_assemblies_mono() {
|
|||||||
echo "Building assemblies"
|
echo "Building assemblies"
|
||||||
ORIG_PWD=$(pwd)
|
ORIG_PWD=$(pwd)
|
||||||
cd "${SRC_PATH}" || exit 1
|
cd "${SRC_PATH}" || exit 1
|
||||||
msbuild -verbosity:m -nologo -t:Clean
|
|
||||||
|
rm -rf "${SRC_PATH}/OpenRA."*/obj
|
||||||
rm -rf "${SRC_PATH:?}/bin"
|
rm -rf "${SRC_PATH:?}/bin"
|
||||||
msbuild -verbosity:m -nologo -t:Build -restore -p:Configuration=Release -p:TargetPlatform="${TARGETPLATFORM}"
|
|
||||||
|
msbuild -verbosity:m -nologo -t:Build -restore -p:Configuration=Release -p:TargetPlatform="${TARGETPLATFORM}" -p:Mono=true -p:DefineConstants="MONO"
|
||||||
if [ "${TARGETPLATFORM}" = "unix-generic" ]; then
|
if [ "${TARGETPLATFORM}" = "unix-generic" ]; then
|
||||||
./configure-system-libraries.sh
|
./configure-system-libraries.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
./fetch-geoip.sh
|
|
||||||
cd "${ORIG_PWD}" || exit 1
|
cd "${ORIG_PWD}" || exit 1
|
||||||
|
|
||||||
echo "Installing engine to ${DEST_PATH}"
|
echo "Installing engine to ${DEST_PATH}"
|
||||||
install -d "${DEST_PATH}"
|
install -d "${DEST_PATH}"
|
||||||
|
|
||||||
# Core engine
|
# Core engine
|
||||||
install -m755 "${SRC_PATH}/bin/OpenRA.Server.exe" "${DEST_PATH}"
|
install -m755 "${SRC_PATH}/bin/OpenRA.Server.dll" "${DEST_PATH}"
|
||||||
install -m755 "${SRC_PATH}/bin/OpenRA.Utility.exe" "${DEST_PATH}"
|
install -m755 "${SRC_PATH}/bin/OpenRA.Utility.dll" "${DEST_PATH}"
|
||||||
install -m644 "${SRC_PATH}/bin/OpenRA.Game.dll" "${DEST_PATH}"
|
install -m644 "${SRC_PATH}/bin/OpenRA.Game.dll" "${DEST_PATH}"
|
||||||
install -m644 "${SRC_PATH}/bin/OpenRA.Platforms.Default.dll" "${DEST_PATH}"
|
install -m644 "${SRC_PATH}/bin/OpenRA.Platforms.Default.dll" "${DEST_PATH}"
|
||||||
if [ "${COPY_GENERIC_LAUNCHER}" = "True" ]; then
|
if [ "${COPY_GENERIC_LAUNCHER}" = "True" ]; then
|
||||||
install -m755 "${SRC_PATH}/bin/OpenRA.exe" "${DEST_PATH}"
|
install -m755 "${SRC_PATH}/bin/OpenRA.dll" "${DEST_PATH}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Mod dlls
|
# Mod dlls
|
||||||
@@ -97,6 +97,32 @@ install_assemblies_mono() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Compile and publish the core engine and specified mod assemblies to the target directory
|
||||||
|
# Arguments:
|
||||||
|
# SRC_PATH: Path to the root OpenRA directory
|
||||||
|
# DEST_PATH: Path to the root of the install destination (will be created if necessary)
|
||||||
|
# TARGETPLATFORM: Platform type (win-x86, win-x64, osx-x64, linux-x64, unix-generic)
|
||||||
|
# COPY_GENERIC_LAUNCHER: If set to True the OpenRA.exe will also be copied (True, False)
|
||||||
|
# COPY_CNC_DLL: If set to True the OpenRA.Mods.Cnc.dll will also be copied (True, False)
|
||||||
|
# COPY_D2K_DLL: If set to True the OpenRA.Mods.D2k.dll will also be copied (True, False)
|
||||||
|
# Used by:
|
||||||
|
# Windows packaging
|
||||||
|
install_assemblies() {
|
||||||
|
SRC_PATH="${1}"
|
||||||
|
DEST_PATH="${2}"
|
||||||
|
TARGETPLATFORM="${3}"
|
||||||
|
COPY_GENERIC_LAUNCHER="${4}"
|
||||||
|
COPY_CNC_DLL="${5}"
|
||||||
|
COPY_D2K_DLL="${6}"
|
||||||
|
|
||||||
|
ORIG_PWD=$(pwd)
|
||||||
|
cd "${SRC_PATH}" || exit 1
|
||||||
|
|
||||||
|
dotnet publish -c Release -p:TargetPlatform="${TARGETPLATFORM}" -p:CopyGenericLauncher="${COPY_GENERIC_LAUNCHER}" -p:CopyCncDll="${COPY_CNC_DLL}" -p:CopyD2kDll="${COPY_D2K_DLL}" -r "${TARGETPLATFORM}" -o "${DEST_PATH}"
|
||||||
|
|
||||||
|
cd "${ORIG_PWD}" || exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# Copy the core engine and specified mod data to the target directory
|
# Copy the core engine and specified mod data to the target directory
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# SRC_PATH: Path to the root OpenRA directory
|
# SRC_PATH: Path to the root OpenRA directory
|
||||||
@@ -115,6 +141,8 @@ install_data() {
|
|||||||
DEST_PATH="${2}"
|
DEST_PATH="${2}"
|
||||||
shift 2
|
shift 2
|
||||||
|
|
||||||
|
"${SRC_PATH}"/fetch-geoip.sh
|
||||||
|
|
||||||
echo "Installing engine files to ${DEST_PATH}"
|
echo "Installing engine files to ${DEST_PATH}"
|
||||||
for FILE in VERSION AUTHORS COPYING IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP "global mix database.dat"; do
|
for FILE in VERSION AUTHORS COPYING IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP "global mix database.dat"; do
|
||||||
install -m644 "${SRC_PATH}/${FILE}" "${DEST_PATH}"
|
install -m644 "${SRC_PATH}/${FILE}" "${DEST_PATH}"
|
||||||
@@ -160,20 +188,15 @@ install_windows_launcher()
|
|||||||
MOD_ID="${4}"
|
MOD_ID="${4}"
|
||||||
LAUNCHER_NAME="${5}"
|
LAUNCHER_NAME="${5}"
|
||||||
MOD_NAME="${6}"
|
MOD_NAME="${6}"
|
||||||
ICON_PATH="${7}"
|
FAQ_URL="${7}"
|
||||||
FAQ_URL="${8}"
|
|
||||||
|
|
||||||
msbuild -verbosity:m -nologo -t:Clean "${SRC_PATH}/OpenRA.WindowsLauncher/OpenRA.WindowsLauncher.csproj"
|
rm -rf "${SRC_PATH}/OpenRA.WindowsLauncher/obj"
|
||||||
rm -rf "${SRC_PATH:?}/bin"
|
dotnet publish "${SRC_PATH}/OpenRA.WindowsLauncher/OpenRA.WindowsLauncher.csproj" -c Release -r "${TARGETPLATFORM}" -p:LauncherName="${LAUNCHER_NAME}" -p:TargetPlatform="${TARGETPLATFORM}" -p:ModID="${MOD_ID}" -p:DisplayName="${MOD_NAME}" -p:FaqUrl="${FAQ_URL}" -o "${DEST_PATH}"
|
||||||
msbuild -t:Build "${SRC_PATH}/OpenRA.WindowsLauncher/OpenRA.WindowsLauncher.csproj" -restore -p:Configuration=Release -p:TargetPlatform="${TARGETPLATFORM}" -p:LauncherName="${LAUNCHER_NAME}" -p:LauncherIcon="${ICON_PATH}" -p:ModID="${MOD_ID}" -p:DisplayName="${MOD_NAME}" -p:FaqUrl="${FAQ_URL}"
|
|
||||||
install -m755 "${SRC_PATH}/bin/${LAUNCHER_NAME}.exe" "${DEST_PATH}"
|
|
||||||
install -m644 "${SRC_PATH}/bin/${LAUNCHER_NAME}.exe.config" "${DEST_PATH}"
|
|
||||||
|
|
||||||
# Enable the full 4GB address space for the 32 bit game executable
|
# NET 5 is unable to customize the application host for windows when compiling from Linux,
|
||||||
# The server and utility do not use enough memory to need this
|
# so we must patch the properties we need in the PE header.
|
||||||
if [ "${TARGETPLATFORM}" = "win-x86" ]; then
|
# Setting the application icon requires an external tool, so is left to the calling code
|
||||||
python3 "${SRC_PATH}/packaging/windows/MakeLAA.py" "${DEST_PATH}/${LAUNCHER_NAME}.exe"
|
python3 "${SRC_PATH}/packaging/windows/fixlauncher.py" "${DEST_PATH}/${LAUNCHER_NAME}.exe"
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Write a version string to the engine VERSION file
|
# Write a version string to the engine VERSION file
|
||||||
|
|||||||
@@ -2,11 +2,10 @@
|
|||||||
# OpenRA packaging script for Linux (AppImage)
|
# OpenRA packaging script for Linux (AppImage)
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
command -v make >/dev/null 2>&1 || { echo >&2 "Linux packaging requires make."; exit 1; }
|
|
||||||
command -v tar >/dev/null 2>&1 || { echo >&2 "Linux packaging requires tar."; exit 1; }
|
command -v tar >/dev/null 2>&1 || { echo >&2 "Linux packaging requires tar."; exit 1; }
|
||||||
command -v curl >/dev/null 2>&1 || command -v wget > /dev/null 2>&1 || { echo >&2 "Linux packaging requires curl or wget."; exit 1; }
|
command -v curl >/dev/null 2>&1 || command -v wget > /dev/null 2>&1 || { echo >&2 "Linux packaging requires curl or wget."; exit 1; }
|
||||||
|
|
||||||
DEPENDENCIES_TAG="20200328"
|
DEPENDENCIES_TAG="20201222"
|
||||||
|
|
||||||
if [ $# -eq "0" ]; then
|
if [ $# -eq "0" ]; then
|
||||||
echo "Usage: $(basename "$0") version [outputdir]"
|
echo "Usage: $(basename "$0") version [outputdir]"
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
HERE="$(dirname "$(readlink -f "${0}")")"
|
HERE="$(dirname "$(readlink -f "${0}")")"
|
||||||
cd "${HERE}/../lib/openra" || exit 1
|
cd "${HERE}/../lib/openra" || exit 1
|
||||||
|
|
||||||
mono --debug OpenRA.Server.exe Game.Mod="{MODID}" "$@"
|
mono --debug OpenRA.Server.dll Game.Mod="{MODID}" "$@"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd "{GAME_INSTALL_DIR}"
|
cd "{GAME_INSTALL_DIR}"
|
||||||
|
|
||||||
mono {DEBUG} OpenRA.Server.exe Game.Mod={MODID} "$@"
|
mono {DEBUG} OpenRA.Server.dll Game.Mod={MODID} "$@"
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
# OpenRA.Utility relies on keeping the original working directory, so don't change directory
|
# OpenRA.Utility relies on keeping the original working directory, so don't change directory
|
||||||
HERE="$(dirname "$(readlink -f "${0}")")"
|
HERE="$(dirname "$(readlink -f "${0}")")"
|
||||||
mono --debug "${HERE}/../lib/openra/OpenRA.Utility.exe" {MODID} "$@"
|
mono --debug "${HERE}/../lib/openra/OpenRA.Utility.dll" {MODID} "$@"
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ fi
|
|||||||
|
|
||||||
# Run the game
|
# Run the game
|
||||||
export SDL_VIDEO_X11_WMCLASS="openra-{MODID}-{TAG}"
|
export SDL_VIDEO_X11_WMCLASS="openra-{MODID}-{TAG}"
|
||||||
mono --debug OpenRA.exe Game.Mod={MODID} Engine.LaunchPath="${LAUNCHER}" Engine.LaunchWrapper="${HERE}/restore-environment.sh" "${JOIN_SERVER}" "$@"
|
mono --debug OpenRA.dll Game.Mod={MODID} Engine.LaunchPath="${LAUNCHER}" Engine.LaunchWrapper="${HERE}/restore-environment.sh" "${JOIN_SERVER}" "$@"
|
||||||
|
|
||||||
# Show a crash dialog if something went wrong
|
# Show a crash dialog if something went wrong
|
||||||
if [ $? != 0 ] && [ $? != 1 ]; then
|
if [ $? != 0 ] && [ $? != 1 ]; then
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ if [ "${1#${PROTOCOL_PREFIX}}" != "${1}" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run the game
|
# Run the game
|
||||||
mono {DEBUG} OpenRA.exe Game.Mod={MODID} Engine.LaunchPath="{BIN_DIR}/openra-{MODID}" "${JOIN_SERVER}" "$@"
|
mono {DEBUG} OpenRA.dll Game.Mod={MODID} Engine.LaunchPath="{BIN_DIR}/openra-{MODID}" "${JOIN_SERVER}" "$@"
|
||||||
|
|
||||||
# Show a crash dialog if something went wrong
|
# Show a crash dialog if something went wrong
|
||||||
if [ $? != 0 ] && [ $? != 1 ]; then
|
if [ $? != 0 ] && [ $? != 1 ]; then
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#
|
#
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
MONO_TAG="osx-launcher-20200830"
|
MONO_TAG="osx-launcher-20201222"
|
||||||
|
|
||||||
if [ $# -ne "2" ]; then
|
if [ $# -ne "2" ]; then
|
||||||
echo "Usage: $(basename "$0") tag outputdir"
|
echo "Usage: $(basename "$0") tag outputdir"
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ static int check_mono_version(const char *version, const char *req_version)
|
|||||||
[self exitWithMonoPrompt];
|
[self exitWithMonoPrompt];
|
||||||
|
|
||||||
// Default values - can be overriden by setting certain keys Info.plist
|
// Default values - can be overriden by setting certain keys Info.plist
|
||||||
NSString *gameName = @"OpenRA.exe";
|
NSString *gameName = @"OpenRA.dll";
|
||||||
NSString *modId = nil;
|
NSString *modId = nil;
|
||||||
|
|
||||||
NSDictionary *plist = [[NSBundle mainBundle] infoDictionary];
|
NSDictionary *plist = [[NSBundle mainBundle] infoDictionary];
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ NSTask *gameTask;
|
|||||||
launched = YES;
|
launched = YES;
|
||||||
|
|
||||||
// Default values - can be overriden by setting certain keys Info.plist
|
// Default values - can be overriden by setting certain keys Info.plist
|
||||||
NSString *gameName = @"OpenRA.exe";
|
NSString *gameName = @"OpenRA.dll";
|
||||||
NSString *modId = nil;
|
NSString *modId = nil;
|
||||||
|
|
||||||
NSDictionary *plist = [[NSBundle mainBundle] infoDictionary];
|
NSDictionary *plist = [[NSBundle mainBundle] infoDictionary];
|
||||||
|
|||||||
@@ -129,14 +129,16 @@ Section "Game" GAME
|
|||||||
|
|
||||||
SetOutPath "$INSTDIR"
|
SetOutPath "$INSTDIR"
|
||||||
File "${SRCDIR}\*.exe"
|
File "${SRCDIR}\*.exe"
|
||||||
File "${SRCDIR}\*.exe.config"
|
File "${SRCDIR}\*.dll.config"
|
||||||
File "${SRCDIR}\*.dll"
|
File "${SRCDIR}\*.dll"
|
||||||
File "${SRCDIR}\*.ico"
|
File "${SRCDIR}\*.ico"
|
||||||
|
File "${SRCDIR}\*.deps.json"
|
||||||
|
File "${SRCDIR}\*.runtimeconfig.json"
|
||||||
|
File "${SRCDIR}\global mix database.dat"
|
||||||
|
File "${SRCDIR}\IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP"
|
||||||
File "${SRCDIR}\VERSION"
|
File "${SRCDIR}\VERSION"
|
||||||
File "${SRCDIR}\AUTHORS"
|
File "${SRCDIR}\AUTHORS"
|
||||||
File "${SRCDIR}\COPYING"
|
File "${SRCDIR}\COPYING"
|
||||||
File "${SRCDIR}\global mix database.dat"
|
|
||||||
File "${SRCDIR}\IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP"
|
|
||||||
|
|
||||||
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
||||||
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
|
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
|
||||||
@@ -162,6 +164,7 @@ Section "Game" GAME
|
|||||||
|
|
||||||
SetShellVarContext all
|
SetShellVarContext all
|
||||||
CreateDirectory "$APPDATA\OpenRA\ModMetadata"
|
CreateDirectory "$APPDATA\OpenRA\ModMetadata"
|
||||||
|
SetOutPath "$INSTDIR"
|
||||||
nsExec::ExecToLog '"$INSTDIR\OpenRA.Utility.exe" ra --register-mod "$INSTDIR\RedAlert.exe" system'
|
nsExec::ExecToLog '"$INSTDIR\OpenRA.Utility.exe" ra --register-mod "$INSTDIR\RedAlert.exe" system'
|
||||||
nsExec::ExecToLog '"$INSTDIR\OpenRA.Utility.exe" ra --clear-invalid-mod-registrations system'
|
nsExec::ExecToLog '"$INSTDIR\OpenRA.Utility.exe" ra --clear-invalid-mod-registrations system'
|
||||||
nsExec::ExecToLog '"$INSTDIR\OpenRA.Utility.exe" cnc --register-mod "$INSTDIR\TiberianDawn.exe" system'
|
nsExec::ExecToLog '"$INSTDIR\OpenRA.Utility.exe" cnc --register-mod "$INSTDIR\TiberianDawn.exe" system'
|
||||||
@@ -182,21 +185,6 @@ Section "Desktop Shortcut" DESKTOPSHORTCUT
|
|||||||
"$INSTDIR\Dune2000.exe" "" "" "" ""
|
"$INSTDIR\Dune2000.exe" "" "" "" ""
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
;***************************
|
|
||||||
;Dependency Sections
|
|
||||||
;***************************
|
|
||||||
Section "-DotNet" DotNet
|
|
||||||
ClearErrors
|
|
||||||
; https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed
|
|
||||||
ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" "Release"
|
|
||||||
IfErrors error 0
|
|
||||||
IntCmp $0 461808 done error done
|
|
||||||
error:
|
|
||||||
MessageBox MB_OK ".NET Framework v4.7.2 or later is required to run OpenRA."
|
|
||||||
Abort
|
|
||||||
done:
|
|
||||||
SectionEnd
|
|
||||||
|
|
||||||
;***************************
|
;***************************
|
||||||
;Uninstaller Sections
|
;Uninstaller Sections
|
||||||
;***************************
|
;***************************
|
||||||
@@ -225,14 +213,17 @@ Function ${UN}Clean
|
|||||||
RMDir /r $INSTDIR\glsl
|
RMDir /r $INSTDIR\glsl
|
||||||
RMDir /r $INSTDIR\lua
|
RMDir /r $INSTDIR\lua
|
||||||
Delete $INSTDIR\*.exe
|
Delete $INSTDIR\*.exe
|
||||||
Delete $INSTDIR\*.exe.config
|
|
||||||
Delete $INSTDIR\*.dll
|
Delete $INSTDIR\*.dll
|
||||||
Delete $INSTDIR\*.ico
|
Delete $INSTDIR\*.ico
|
||||||
|
Delete $INSTDIR\*.dll.config
|
||||||
|
Delete $INSTDIR\*.deps.json
|
||||||
|
Delete $INSTDIR\*.runtimeconfig.json
|
||||||
Delete $INSTDIR\VERSION
|
Delete $INSTDIR\VERSION
|
||||||
Delete $INSTDIR\AUTHORS
|
Delete $INSTDIR\AUTHORS
|
||||||
Delete $INSTDIR\COPYING
|
Delete $INSTDIR\COPYING
|
||||||
Delete "$INSTDIR\global mix database.dat"
|
Delete "$INSTDIR\global mix database.dat"
|
||||||
Delete $INSTDIR\IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP
|
Delete $INSTDIR\IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP
|
||||||
|
|
||||||
RMDir /r $INSTDIR\Support
|
RMDir /r $INSTDIR\Support
|
||||||
|
|
||||||
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenRA${SUFFIX}"
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenRA${SUFFIX}"
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ elif [[ ${TAG} == playtest* ]]; then
|
|||||||
SUFFIX=" (playtest)"
|
SUFFIX=" (playtest)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if command -v curl >/dev/null 2>&1; then
|
||||||
|
curl -s -L -O https://github.com/electron/rcedit/releases/download/v1.1.1/rcedit-x64.exe || exit 3
|
||||||
|
else
|
||||||
|
wget -cq https://github.com/electron/rcedit/releases/download/v1.1.1/rcedit-x64.exe || exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
function makelauncher()
|
function makelauncher()
|
||||||
{
|
{
|
||||||
LAUNCHER_NAME="${1}"
|
LAUNCHER_NAME="${1}"
|
||||||
@@ -40,7 +46,9 @@ function makelauncher()
|
|||||||
PLATFORM="${4}"
|
PLATFORM="${4}"
|
||||||
|
|
||||||
convert "${ARTWORK_DIR}/${MOD_ID}_16x16.png" "${ARTWORK_DIR}/${MOD_ID}_24x24.png" "${ARTWORK_DIR}/${MOD_ID}_32x32.png" "${ARTWORK_DIR}/${MOD_ID}_48x48.png" "${ARTWORK_DIR}/${MOD_ID}_256x256.png" "${BUILTDIR}/${MOD_ID}.ico"
|
convert "${ARTWORK_DIR}/${MOD_ID}_16x16.png" "${ARTWORK_DIR}/${MOD_ID}_24x24.png" "${ARTWORK_DIR}/${MOD_ID}_32x32.png" "${ARTWORK_DIR}/${MOD_ID}_48x48.png" "${ARTWORK_DIR}/${MOD_ID}_256x256.png" "${BUILTDIR}/${MOD_ID}.ico"
|
||||||
install_windows_launcher "${SRCDIR}" "${BUILTDIR}" "win-${PLATFORM}" "${MOD_ID}" "${LAUNCHER_NAME}" "${DISPLAY_NAME}" "${BUILTDIR}/${MOD_ID}.ico" "${FAQ_URL}"
|
install_windows_launcher "${SRCDIR}" "${BUILTDIR}" "win-${PLATFORM}" "${MOD_ID}" "${LAUNCHER_NAME}" "${DISPLAY_NAME}" "${FAQ_URL}"
|
||||||
|
|
||||||
|
wine64 rcedit-x64.exe "${BUILTDIR}/${LAUNCHER_NAME}.exe" --set-icon "${BUILTDIR}/${MOD_ID}.ico"
|
||||||
}
|
}
|
||||||
|
|
||||||
function build_platform()
|
function build_platform()
|
||||||
@@ -54,7 +62,7 @@ function build_platform()
|
|||||||
USE_PROGRAMFILES32=""
|
USE_PROGRAMFILES32=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install_assemblies_mono "${SRCDIR}" "${BUILTDIR}" "win-${PLATFORM}" "False" "True" "True"
|
install_assemblies "${SRCDIR}" "${BUILTDIR}" "win-${PLATFORM}" "False" "True" "True"
|
||||||
install_data "${SRCDIR}" "${BUILTDIR}" "cnc" "d2k" "ra"
|
install_data "${SRCDIR}" "${BUILTDIR}" "cnc" "d2k" "ra"
|
||||||
set_engine_version "${TAG}" "${BUILTDIR}"
|
set_engine_version "${TAG}" "${BUILTDIR}"
|
||||||
set_mod_version "${TAG}" "${BUILTDIR}/mods/cnc/mod.yaml" "${BUILTDIR}/mods/d2k/mod.yaml" "${BUILTDIR}/mods/ra/mod.yaml" "${BUILTDIR}/mods/modcontent/mod.yaml"
|
set_mod_version "${TAG}" "${BUILTDIR}/mods/cnc/mod.yaml" "${BUILTDIR}/mods/d2k/mod.yaml" "${BUILTDIR}/mods/ra/mod.yaml" "${BUILTDIR}/mods/modcontent/mod.yaml"
|
||||||
|
|||||||
@@ -9,11 +9,21 @@ import struct
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print(sys.argv[1] + ': Enabling /LARGEADDRESSAWARE')
|
print('Patching ' + sys.argv[1] + ':')
|
||||||
with open(sys.argv[1], 'r+b') as assembly:
|
with open(sys.argv[1], 'r+b') as assembly:
|
||||||
assembly.seek(0x3c)
|
assembly.seek(0x3c)
|
||||||
peOffset = struct.unpack('i', assembly.read(4))[0]
|
peOffset = struct.unpack('H', assembly.read(2))[0]
|
||||||
|
|
||||||
|
assembly.seek(peOffset)
|
||||||
|
peSignature = struct.unpack('I', assembly.read(4))[0]
|
||||||
|
if peSignature != 0x4550:
|
||||||
|
print(" ERROR: Invalid PE signature")
|
||||||
|
|
||||||
|
print(' - Setting /LARGEADDRESSAWARE')
|
||||||
assembly.seek(peOffset + 4 + 18)
|
assembly.seek(peOffset + 4 + 18)
|
||||||
flags = struct.unpack('B', assembly.read(1))[0] | 0x20
|
flags = struct.unpack('B', assembly.read(1))[0] | 0x20
|
||||||
assembly.seek(peOffset + 4 + 18)
|
assembly.seek(peOffset + 4 + 18)
|
||||||
assembly.write(struct.pack('B', flags))
|
assembly.write(struct.pack('B', flags))
|
||||||
|
print(' - Setting /subsystem:windows')
|
||||||
|
assembly.seek(peOffset + 0x5C)
|
||||||
|
assembly.write(struct.pack("H", 0x02))
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
ENGINE_DIR=.. mono --debug bin/OpenRA.Utility.exe $@
|
ENGINE_DIR=.. mono --debug bin/OpenRA.Utility.dll $@
|
||||||
|
|||||||
Reference in New Issue
Block a user