From 344ff7bb42e25b335cf84b09a9115aad5af8bd30 Mon Sep 17 00:00:00 2001 From: dvize Date: Mon, 8 Jul 2024 10:48:45 -0700 Subject: [PATCH] Update for SPT 3.9.0 --- ASS.csproj | 26 ++++----- PackageMods.ps1 | 117 +++++++++++++++++++++++++++++++++++++ Plugin.cs | 4 +- Properties/AssemblyInfo.cs | 4 +- 4 files changed, 133 insertions(+), 18 deletions(-) create mode 100644 PackageMods.ps1 diff --git a/ASS.csproj b/ASS.csproj index 2f3c33e..95f6bab 100644 --- a/ASS.csproj +++ b/ASS.csproj @@ -9,7 +9,7 @@ Properties dvize.ASS dvize.ASS - v4.8.1 + v4.7.1 512 true @@ -39,17 +39,6 @@ False BepInEx\core\0Harmony.dll - - F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\Aki.Build.dll - - - False - F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\Aki.Common.dll - - - False - F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\Aki.Reflection.dll - False F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll @@ -77,6 +66,12 @@ False F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\ItemTemplate.Types.dll + + F:\SPT-AKI-DEV\BepInEx\plugins\spt\spt-common.dll + + + F:\SPT-AKI-DEV\BepInEx\plugins\spt\spt-reflection.dll + @@ -110,11 +105,14 @@ copy "$(TargetPath)" "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).dll" -if $(ConfigurationName) == Debug ( +if "$(ConfigurationName)" == "Debug" ( copy "$(TargetDir)$(TargetName).pdb" "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).pdb" ) else ( del "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).pdb" ) - + +if "$(ConfigurationName)" == "Release" ( + powershell -ExecutionPolicy Bypass -NoProfile -NonInteractive -File "$(ProjectDir)PackageMods.ps1" -ConfigurationName "$(ConfigurationName)" -TargetPath "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).dll" -TargetName "$(TargetName)" -TargetDir "F:\SPT-AKI-DEV\BepInEx\plugins" +) \ No newline at end of file diff --git a/PackageMods.ps1 b/PackageMods.ps1 new file mode 100644 index 0000000..0203c1d --- /dev/null +++ b/PackageMods.ps1 @@ -0,0 +1,117 @@ +param ( + [string]$ConfigurationName, + [string]$TargetPath, + [string]$TargetName, + [string]$TargetDir +) + +# Define the base directory +$baseDir = "F:\SPT-AKI-DEV\BepInEx\plugins" + +# Function to log messages to the console +function Log { + param ( + [string]$message + ) + $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" + Write-Host "$timestamp - $message" +} + +Log "Script started" +Log "ConfigurationName: $ConfigurationName" +Log "TargetPath: $TargetPath" +Log "TargetName: $TargetName" +Log "TargetDir: $TargetDir" + +# Get the assembly version +$assembly = [System.Reflection.Assembly]::LoadFile($TargetPath) +$version = $assembly.GetName().Version.ToString() +Log "Assembly version: $version" + +# Determine the directory of the deployed DLL +$deployDir = Split-Path -Parent $TargetPath +Log "DeployDir: $deployDir" + +# Check if the deploy directory is the base directory or one level further +if ($deployDir -ne $baseDir) { + $relativePath = $deployDir.Substring($baseDir.Length + 1) # Get the relative path beyond the base directory + Log "RelativePath: $relativePath" + if (($relativePath -split '\\').Count -eq 1) { # Check if it's exactly one directory level further + $directoryName = (Get-Item $deployDir).Name + $zipPath = "F:\SPT-AKI-DEV\BepInEx\plugins\$directoryName-v$version.zip" + Log "DirectoryName: $directoryName" + Log "ZipPath: $zipPath" + + # Remove existing zip file if it exists + if (Test-Path $zipPath) { + Log "ZipPath exists, removing" + Remove-Item $zipPath -Force + } + + # Create the temp directory structure + $tempZipDir = "F:\SPT-AKI-DEV\tempZip" + if (Test-Path $tempZipDir) { + Log "TempZipDir exists, removing" + Remove-Item $tempZipDir -Recurse -Force + } + New-Item -ItemType Directory -Path $tempZipDir + Log "TempZipDir created: $tempZipDir" + + $newZipStructure = Join-Path $tempZipDir "Bepinex\plugins\$directoryName" + New-Item -ItemType Directory -Path $newZipStructure -Force + Log "New zip structure directory created: $newZipStructure" + + # Copy files to the new zip structure + Copy-Item -Path "$TargetDir\*" -Destination $newZipStructure -Recurse -Force + Log "Files copied to new zip structure" + + # Create the final zip file + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::CreateFromDirectory($tempZipDir, $zipPath) + Log "Final zip file created: $zipPath" + + # Clean up temp directory + Remove-Item $tempZipDir -Recurse -Force + Log "TempZipDir removed" + } else { + Log "RelativePath is not one directory level further" + } +} else { + $zipPath = "F:\SPT-AKI-DEV\BepInEx\plugins\$TargetName-v$version.zip" + Log "ZipPath: $zipPath" + + # Remove existing zip file if it exists + if (Test-Path $zipPath) { + Log "ZipPath exists, removing" + Remove-Item $zipPath -Force + } + + # Create the temp directory structure + $tempZipDir = "F:\SPT-AKI-DEV\tempZip" + if (Test-Path $tempZipDir) { + Log "TempZipDir exists, removing" + Remove-Item $tempZipDir -Recurse -Force + } + New-Item -ItemType Directory -Path $tempZipDir + Log "TempZipDir created: $tempZipDir" + + # Create the required folder structure within the temp directory + $bepinexPluginsDir = Join-Path $tempZipDir "Bepinex\plugins" + New-Item -ItemType Directory -Path $bepinexPluginsDir -Force + Log "Bepinex\plugins directory created: $bepinexPluginsDir" + + # Copy the single DLL to the new structure + Copy-Item -Path $TargetPath -Destination $bepinexPluginsDir -Force + Log "DLL copied to Bepinex\plugins directory" + + # Create the final zip file + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::CreateFromDirectory($tempZipDir, $zipPath) + Log "Final zip file created: $zipPath" + + # Clean up temp directory + Remove-Item $tempZipDir -Recurse -Force + Log "TempZipDir removed" +} + +Log "Script finished" diff --git a/Plugin.cs b/Plugin.cs index bb5ed61..8a0fb81 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -1,13 +1,13 @@ using System; using System.Reflection; -using Aki.Reflection.Patching; +using SPT.Reflection.Patching; using BepInEx; using BepInEx.Configuration; using EFT; namespace armorMod { - [BepInPlugin("com.dvize.ASS", "dvize.ASS", "1.6.0")] + [BepInPlugin("com.dvize.ASS", "dvize.ASS", "1.7.0")] public class AssPlugin : BaseUnityPlugin { internal static ConfigEntry ArmorServiceMode diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 4c73065..c090053 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.0.0")] -[assembly: AssemblyFileVersion("1.6.0.0")] +[assembly: AssemblyVersion("1.7.0.0")] +[assembly: AssemblyFileVersion("1.7.0.0")]