Skip to content
Snippets Groups Projects
Commit 7e0e4954 authored by XenoMorphie's avatar XenoMorphie :space_invader: Committed by Ed86
Browse files

Enable Cross-Platform Deployment (Linux, macOS & Windows 7+)

parent 4409676b
No related branches found
No related tags found
No related merge requests found
# Environment setup
## RimWorld dependencies
The `.csproj` file has been configured to automatically detect standard Windows, Linux, and macOS Steam install
locations, and should link dependencies regardless of the project's location on your hard drive. If that works for you,
......@@ -34,3 +35,8 @@ should look like this:
- `Assembly-CSharp.dll`
- ...
## Deployment Notice
Deployment scripts now make use of PowerShell 7+, instead of Windows PowerShell 5.1, allowing for cross platform execution.
Please see [this document](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.2) if you don't have the new PowerShell on your device.
@ECHO OFF
SET ThisScriptsDirectory=%~dp0
SET PSSctiptName=Deploy.ps1
SET PowerShellScriptPath=%ThisScriptsDirectory%%PSSctiptName%
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%PowerShellScriptPath%'";
\ No newline at end of file
SET scriptDir=%~dp0
SET psScript=Deploy.ps1
SET pwshScriptPath=%scriptDir%%psScript%
pwsh -NoProfile -ExecutionPolicy Bypass -Command "& '%pwshScriptPath%'";
# Configurable variables
$repo = '..'
$packing = 'rjw_packing'
$outputFormat = '..\..\RJW-{0}.7z'
$outputFormat = Join-Path -Path '..\..' -ChildPath 'RJW-{0}.7z'
$internalPath = 'RJW'
$pathsToRemove = '.git', '.gitattributes', '.gitignore', '1.1\Source', '1.2\Source', '1.3\Source', 'Deploy'
$pathsToRemove = '.git', '.gitattributes', '.gitignore', (Join-Path -Path '1.1' -ChildPath 'Source'), (Join-Path -Path '1.2' -ChildPath 'Source'), (Join-Path -Path '1.3' -ChildPath 'Source'), 'Deploy'
[Console]::ResetColor()
......@@ -23,8 +23,14 @@ $Step++
##Write-Progress -Id $Id -Activity $Activity -Status (& $StatusBlock) -CurrentOperation " " -PercentComplete ($Step / $TotalSteps * 100)
$startupPath = Get-Location
$7z = (GET-ItemProperty 'HKLM:\SOFTWARE\7-Zip').Path + '7z.exe'
$packingRjw = $packing + "\" + $internalPath
if ($IsWindows) {
$7z = (GET-ItemProperty 'HKLM:\SOFTWARE\7-Zip').Path + '7z.exe'
}
else {
$7z = &which 7z
}
$packingRjw = Join-Path -Path $packing -ChildPath $internalPath
Push-Location -Path $repo
......@@ -35,7 +41,7 @@ try {
}
if ($version -eq "") {
$manifest = "./About/Manifest.xml"
$manifest = Join-Path -Path '.\About' -ChildPath 'Manifest.xml'
[string]$version = (Select-Xml -Path $manifest -XPath '/Manifest/version' | Select-Object -ExpandProperty Node).innerText
}
......@@ -63,7 +69,7 @@ $items | Foreach-Object -Begin {
$i++
if (-Not ($pathsToRemove -contains $_.Name)) {
Copy-Item -Recurse $_.FullName -Destination ($packingRjw + "\" + $_.Name)
Copy-Item -Recurse $_.FullName -Destination (Join-Path -Path $packingRjw -ChildPath $_.Name)
}
$p = $i * 100 / $items.Count
......@@ -77,7 +83,7 @@ $Step++
Write-Progress -Id $Id -Activity $Activity -Status (& $StatusBlock) -CurrentOperation " " -PercentComplete ($Step / $TotalSteps * 100)
foreach ($path in $pathsToRemove) {
$p = $packingRjw + '\' + $path
$p = Join-Path -Path $packingRjw -ChildPath $path
if (Test-Path $p) { Remove-Item -Recurse -Force $p }
}
......@@ -87,7 +93,7 @@ $Step++
Write-Progress -Id $Id -Activity $Activity -Status (& $StatusBlock) -CurrentOperation " " -PercentComplete ($Step / $TotalSteps * 100)
Push-Location -Path $packing
& $7z a -r -bsp1 ($startupPath.Path+'\'+$output) + $internalPath | Foreach-Object -Begin {
& $7z a -r -bsp1 (Join-Path -Path $startupPath.Path -ChildPath $output) + $internalPath | Foreach-Object -Begin {
Write-Progress -Id ($Id+1) -ParentId $Id -Activity 'Archiving' -Status "Starting..." -PercentComplete 0
} -Process {
$line = $_.Trim()
......@@ -119,4 +125,4 @@ if ($Host.Name -eq "ConsoleHost")
Write-Host "Done"
Write-Host "Press any key to continue..."
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null
}
\ No newline at end of file
}
#!/usr/bin/env bash
set -e
scriptDir=$(pwd)
scriptName="Deploy.ps1"
scriptPath=$scriptDir/$scriptName
echo "Reminder: p7zip and PowerShell Core are required."
pwsh -NoProfile -ExecutionPolicy Bypass -Command "& '$scriptPath'"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment