diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
new file mode 100644
index 0000000..7bd5f9f
--- /dev/null
+++ b/.config/dotnet-tools.json
@@ -0,0 +1,12 @@
+{
+ "version": 1,
+ "isRoot": true,
+ "tools": {
+ "cake.tool": {
+ "version": "2.2.0",
+ "commands": [
+ "dotnet-cake"
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index 1b74953..ef7bbc9 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -12,8 +12,7 @@ jobs:
with:
# TODO install all targeted .NET versions then test against all of them
dotnet-version: 6.0.104
- - name: Build
- # MSBuildCommunityTasks doesn't play well with .NET 6 so skip all that
- run: dotnet build --configuration Pro -p:DRBuildMode=coreonly -p:SkipCopyToBuild=true
+ - name: Restore
+ run: dotnet tool restore
- name: Test
- run: dotnet test -p:DRBuildMode=coreonly -p:SkipCopyToBuild=true
+ run: dotnet cake --target Test --configuration Pro --core-only
diff --git a/.github/workflows/pack.yml b/.github/workflows/pack.yml
index 9eb45c4..ac5b46b 100644
--- a/.github/workflows/pack.yml
+++ b/.github/workflows/pack.yml
@@ -13,9 +13,9 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.104
- - name: Build
- run: dotnet build --configuration Pro -p:DRBuildMode=coreonly -p:SkipCopyToBuild=true
+ - name: Restore
+ run: dotnet tool restore
- name: Test
- run: dotnet test -p:DRBuildMode=coreonly -p:SkipCopyToBuild=true
- # TODO create GitHub release, this might require moving away from MSBuildTasks due to no .NET Core support
+ run: dotnet cake --target Test --configuration Pro --core-only
+ # TODO create GitHub release
# TODO pack unitypackage using somehting like https://github.com/FatihBAKIR/UnityPacker
diff --git a/.props b/.props
deleted file mode 100644
index 6241879..0000000
--- a/.props
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- 2.10.1
-
-
\ No newline at end of file
diff --git a/.targets b/.targets
deleted file mode 100644
index b625248..0000000
--- a/.targets
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
- $(SolutionDir)Build/
- $(BuildArea)$(Configuration)/$(TargetFramework)/
-
-
-
-
-
-
-
-
- $(USERPROFILE)/.nuget/packages/msbuildtasks/1.5.0.235/tools
-
-
- $(HOME)/.nuget/packages/msbuildtasks/1.5.0.235/tools
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(Configuration.ToLower())
- pro
-
- core
- framework
-
-
-
-
-
-
diff --git a/.version b/.version
new file mode 100644
index 0000000..b714ae9
--- /dev/null
+++ b/.version
@@ -0,0 +1 @@
+2.12.0-prerelease
diff --git a/BUILDING.md b/BUILDING.md
index 1634766..96f2826 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -1,4 +1,30 @@
-To build the DarkRift 2 solution *you must have Microsoft Visual Studio 2022* installed. The Community edition is fine for open source projects, and is easily attained from https://visualstudio.microsoft.com/vs/community/
+DarkRift is build using [Cake](https://cakebuild.net/). To create a full build of DarkRift run `dotnet cake` (you will need to run `dotnet tool restore` the first time).
+
+This command will:
+- Build DarkRift
+- Create neatly organized packages in `./Build`
+- Test DR
+
+You will need the .NET 6 SDK to build DarkRift.
+
+For editing DarkRift we recommend using Microsoft Visual Studio 2022 although other editors will work.
+
+## Cake Tasks
+The following tasks are defined in `build.cake`:
+- `Clean` - Cleans the `./Build` directory
+- `Build` - Builds DarkRift
+- `Test` (default) - Builds and tests DarkRift
+- `InstallInCLITool` - Builds and installs a dev version of DarkRift into the DarkRift CLI tool as version `dev`. This is useful for easy local testing
+
+The following arguments can be passed to the build script:
+- `--target ` - choose the task to run (see list above)
+- `--configuration ` - the configuration of DR to build (see below section)
+- `--core-only` - only build for .NET Core, this can get around issues building .NET Framework applications such as on Linux
+
+For example:
+```bash
+dotnet cake --target InstallInCLITool --configuration Pro
+```
## Configurations
@@ -25,4 +51,4 @@ If you're looking to manually copy assemblies into your Unity assets, you should
If you're an existing DarkRift 2 user, there's a decent chance you will want to reproduce the Free or Pro .unitypackage DarkRift 2 used to ship with in order to stick with the way DR2 in your Assets folder is organized. Even as a new user, a .unitypackage can be a practical way install the typical DarkRift version into your Unity project if you don't intend to make changes.
-*TODO: Fix package building in post_release.sh and write guide for how to export packages*
\ No newline at end of file
+*TODO: Fix package building in post_release.sh and write guide for how to export packages*
diff --git a/DarkRift.Client/DarkRift.Client.csproj b/DarkRift.Client/DarkRift.Client.csproj
index e6c0607..5169a62 100644
--- a/DarkRift.Client/DarkRift.Client.csproj
+++ b/DarkRift.Client/DarkRift.Client.csproj
@@ -1,7 +1,4 @@
-
-
-
net3.5;netstandard2.0
netstandard2.0
@@ -26,4 +23,4 @@
-
\ No newline at end of file
+
diff --git a/DarkRift.Server.Console/DarkRift.Server.Console.csproj b/DarkRift.Server.Console/DarkRift.Server.Console.csproj
index a48bb2f..8ad77fc 100644
--- a/DarkRift.Server.Console/DarkRift.Server.Console.csproj
+++ b/DarkRift.Server.Console/DarkRift.Server.Console.csproj
@@ -1,7 +1,4 @@
-
-
-
net4.0;netcoreapp2.0;netcoreapp3.1;net5.0;net6.0
netcoreapp2.0;netcoreapp3.1;net5.0;net6.0
@@ -39,7 +36,4 @@
-
-
-
diff --git a/DarkRift.Server.Testing/DarkRift.Server.Testing.csproj b/DarkRift.Server.Testing/DarkRift.Server.Testing.csproj
index ff0f490..455cc4f 100644
--- a/DarkRift.Server.Testing/DarkRift.Server.Testing.csproj
+++ b/DarkRift.Server.Testing/DarkRift.Server.Testing.csproj
@@ -1,7 +1,4 @@
-
-
-
net4.5;net6.0
net6.0
diff --git a/DarkRift.Server/DarkRift.Server.csproj b/DarkRift.Server/DarkRift.Server.csproj
index f138018..fac3e85 100644
--- a/DarkRift.Server/DarkRift.Server.csproj
+++ b/DarkRift.Server/DarkRift.Server.csproj
@@ -1,7 +1,4 @@
-
-
-
net3.5;netstandard2.0
netstandard2.0
@@ -26,4 +23,4 @@
-
\ No newline at end of file
+
diff --git a/DarkRift.SystemTesting/DarkRift.SystemTesting.csproj b/DarkRift.SystemTesting/DarkRift.SystemTesting.csproj
index f626eb8..44bc694 100644
--- a/DarkRift.SystemTesting/DarkRift.SystemTesting.csproj
+++ b/DarkRift.SystemTesting/DarkRift.SystemTesting.csproj
@@ -1,7 +1,4 @@
-
-
-
net6.0
Debug;Free;Pro
diff --git a/DarkRift.Testing/DarkRift.Testing.csproj b/DarkRift.Testing/DarkRift.Testing.csproj
index fb38d61..2142f7e 100644
--- a/DarkRift.Testing/DarkRift.Testing.csproj
+++ b/DarkRift.Testing/DarkRift.Testing.csproj
@@ -1,7 +1,4 @@
-
-
-
net4.5;net6.0
net6.0
diff --git a/DarkRift/DarkRift.csproj b/DarkRift/DarkRift.csproj
index 1648947..7c9a093 100644
--- a/DarkRift/DarkRift.csproj
+++ b/DarkRift/DarkRift.csproj
@@ -1,7 +1,4 @@
-
-
-
net3.5;netstandard2.0
netstandard2.0
@@ -22,4 +19,4 @@
DEBUG;TRACE;PRO
-
\ No newline at end of file
+
diff --git a/build.cake b/build.cake
new file mode 100644
index 0000000..c43abe5
--- /dev/null
+++ b/build.cake
@@ -0,0 +1,154 @@
+var target = Argument("target", "Test");
+var configuration = Argument("configuration", "Debug");
+var coreOnly = HasArgument("core-only");
+
+var version = System.IO.File.ReadAllText(".version").Trim();
+
+Task("Clean")
+ .Does(() =>
+{
+ Information($"Cleaning ./Build/{configuration}");
+ CleanDirectory($"./Build/{configuration}");
+});
+
+Task("Build")
+ .IsDependentOn("Clean")
+ .Does(() =>
+{
+ DotNetBuild("./DarkRift2.sln", new DotNetBuildSettings
+ {
+ Configuration = configuration,
+ MSBuildSettings = new DotNetMSBuildSettings
+ {
+ Properties =
+ {
+ { "Version", new List {version} },
+ { "DRBuildMode", new List {coreOnly ? "coreonly" : "all"} }
+ }
+ }
+ });
+
+ var targetFrameworks = GetSubDirectories($"./DarkRift.Server.Console/bin/{configuration}")
+ .Select(d => MakeRelative(d, MakeAbsolute(Directory($"./DarkRift.Server.Console/bin/{configuration}"))));
+ foreach (var targetFramework in targetFrameworks)
+ {
+ var sourceDir = $"./DarkRift.Server.Console/bin/{configuration}/{targetFramework}";
+ var buildDir = $"./Build/{configuration}/{targetFramework}";
+
+ Information($"Constructing {buildDir}");
+
+ CreateDirectory(buildDir);
+
+ // Copy files into Build folder
+ CopyFiles($"{sourceDir}/*.*", buildDir);
+
+ // .NET Framework needs a slightly different structure
+ if (targetFramework == "net4.0")
+ {
+ // Move library files into the Libs folder (except DarkRift.Server.Console.pdb)
+ CreateDirectory($"{buildDir}/Lib");
+ MoveFiles($"{buildDir}/*.dll", $"{buildDir}/Lib");
+ MoveFiles($"{buildDir}/*.pdb", $"{buildDir}/Lib");
+ MoveFiles($"{buildDir}/Lib/DarkRift.Server.Console.pdb", $"{buildDir}");
+ MoveFiles($"{buildDir}/*.xml", $"{buildDir}/Lib");
+ }
+ else
+ {
+ // Move library files into the Libs folder
+ CreateDirectory($"{buildDir}/Lib");
+ MoveFiles($"{buildDir}/*.dll", $"{buildDir}/Lib");
+ MoveFiles($"{buildDir}/*.pdb", $"{buildDir}/Lib");
+ MoveFiles($"{buildDir}/*.xml", $"{buildDir}/Lib");
+ MoveFiles($"{buildDir}/*.deps.json", $"{buildDir}/Lib");
+ MoveFiles($"{buildDir}/*.dll.config", $"{buildDir}/Lib");
+ MoveFiles($"{buildDir}/*.runtimeconfig.dev.json", $"{buildDir}/Lib");
+ MoveFiles($"{buildDir}/*.runtimeconfig.json", $"{buildDir}/Lib");
+ }
+
+ // Create zip of server build
+ Zip(buildDir, $"{buildDir}/DarkRift Server.zip");
+ }
+});
+
+Task("Test")
+ .IsDependentOn("Build")
+ .Does(() =>
+{
+ DotNetTest("./DarkRift2.sln", new DotNetTestSettings
+ {
+ Configuration = configuration,
+ NoBuild = true,
+ });
+});
+
+Task("InstallInCLITool")
+ .IsDependentOn("Build")
+ .Does(() =>
+{
+ var homeDir = IsRunningOnWindows() ? EnvironmentVariable("HOMEDRIVE") + EnvironmentVariable("HOMEPATH") : EnvironmentVariable("HOME");
+ var tier = configuration == "Debug" ? "pro" : configuration.ToLower(); // CLI doesn't support a 'debug' tier so remap to pro
+
+ var targetFrameworks = GetSubDirectories($"./DarkRift.Server.Console/bin/{configuration}")
+ .Select(d => MakeRelative(d, MakeAbsolute(Directory($"./DarkRift.Server.Console/bin/{configuration}"))));
+ foreach (var targetFramework in targetFrameworks)
+ {
+ var buildDir = $"./Build/{configuration}/{targetFramework}";
+ var cliDir = $"/{configuration}/{targetFramework}";
+ var platform = targetFramework == "net4.0" ? "net40" : targetFramework; // TODO for some reason .NET 4.0 is under net40 in DR CLI
+
+ Information($"Installing into ~/.darkrift/installed/{tier}/{platform}/dev");
+
+ EnsureDirectoryExists($"{homeDir}/.darkrift/installed/{tier}/{platform}/dev");
+ CleanDirectory($"{homeDir}/.darkrift/installed/{tier}/{platform}/dev");
+ CopyFiles($"{buildDir}/**/*.*", $"{homeDir}/.darkrift/installed/{tier}/{platform}/dev");
+ }
+});
+
+// Task("Release")
+// .Does(() =>
+// {
+// #addin nuget:?package=Cake.Prompt&version=1.2.1
+// var versionRegex = "^[0-9]+.[0-9]+.[0-9]+$";
+// var releaseVersion = version;
+// do
+// releaseVersion = Prompt("Enter version for this release", version.Replace("-prerelease", "")).Trim();
+// while (!Regex.IsMatch(releaseVersion, versionRegex));
+// version = releaseVersion;
+//
+// if (StartProcess("git", new ProcessSettings { Arguments = "diff-index --quiet HEAD --" }) != 0)
+// throw new Exception("You have uncommitted changes in your project. Commit the changes or reset them to release.");
+//
+// // TODO Port to C#
+// // Information("DarkRift $version - $(date -I)");
+// // git log $(git describe --tags --abbrev=0)..HEAD --format='- %s' | grep -vF "[changelog.skip]" | grep -v "^Merge"
+//
+// RunTarget("Build");
+//
+// do
+// version = Prompt($"Enter prerelease version (previous was {version}) (-prerelease will be appended)") + "-prerelease";
+// while (!Regex.IsMatch(version, versionRegex));
+//
+// System.IO.File.WriteAllText(".version", version);
+//
+// StartProcess("git", new ProcessSettings { Arguments = $"commit -a \"Update version number to {version}\"" });
+// StartProcess("git", new ProcessSettings { Arguments = $"tag V{version}" });
+//
+// StartProcess("git", new ProcessSettings { Arguments = "push origin master --tags" });
+//
+// RunTarget("CopyToUnity"); // TODO port editor script in Unity to cake
+//
+// #addin nuget:?package=Cake.Unity&version=0.9.0
+// UnityEditor(
+// new UnityEditorArguments
+// {
+// ProjectPath = "./DarkRift.Unity",
+// ExportPackage = new ExportPackage { AssetPaths = { "Assets/DarkRift" }, PackageName = "DarkRift.unitypackage"}
+// }
+// );
+//
+// #addin nuget:?package=Cake.DocFx&version=1.0.0
+// DocFxBuild("./DarkRift.Documentation/docfx.json");
+// });
+
+// Run a target when script is run
+RunTarget(target);