1+ # Configuration
2+ $packageDir = ' .\Package'
3+ $artifactDir = ' .\bin\Package'
4+
5+ # Make sure our CWD is where the script lives
6+ Set-Location $PSScriptRoot
7+
8+ # Fetch the plugin info
9+ $assemblyInfoPath = ' Properties\AssemblyInfo.cs'
10+ $versionPattern = ' ^\[assembly: AssemblyVersion\("(.*)"\)\]'
11+ $namePattern = ' <AssemblyName>(.*)</AssemblyName>'
12+ (Get-Content $assemblyInfoPath ) | ForEach-Object {
13+ if ($_ -match $versionPattern ) {
14+ $assemblyVersion = [version ]$matches [1 ]
15+ }
16+ }
17+ $csprojPath = Get-ChildItem ' .' - filter ' *.csproj'
18+ (Get-Content $csprojPath ) | ForEach-Object {
19+ if ($_ -match $namePattern ) {
20+ $modName = $matches [1 ]
21+ }
22+ }
23+
24+ # Format the version number for our archive
25+ $modVersion = ' {0}.{1}.{2}' -f $assemblyVersion.Major , $assemblyVersion.Minor , $assemblyVersion.Build
26+ if ($assemblyVersion.Revision -ne 0 )
27+ {
28+ $modVersion = ' {0}.{1}' -f $modVersion , $assemblyVersion.Revision
29+ }
30+
31+ Write-Host (' Packaging {0} v{1}' -f $modName , $modVersion )
32+
33+ # Create the package structure
34+ $bepInExDir = ' {0}\BepInEx' -f $packageDir
35+ $pluginsDir = ' {0}\plugins\{1}' -f $bepInExDir , $modName
36+ $null = mkdir $pluginsDir - ea 0
37+
38+ # Copy required files to the package structure
39+ $artifactPath = (' {0}\{1}.dll' -f $artifactDir , $modName )
40+ Copy-Item $artifactPath - Destination $pluginsDir
41+
42+ # Create the archive
43+ $archivePath = ' {0}\{1}-{2}.7z' -f $packageDir , $modName , $modVersion
44+ if (Test-Path $archivePath )
45+ {
46+ Remove-Item $archivePath
47+ }
48+ 7z a $archivePath $bepInExDir
49+
50+ Write-Host (' Mod packaging complete' )
0 commit comments