-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
56 lines (46 loc) · 1.63 KB
/
Copy pathbuild.ps1
File metadata and controls
56 lines (46 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
param(
[string]$ValheimDir = "C:\Program Files (x86)\Steam\steamapps\common\Valheim"
)
$ErrorActionPreference = "Stop"
$pluginRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$srcDir = Join-Path $pluginRoot "src"
$project = Join-Path $srcDir "PlaytimeTimers.csproj"
$infoFile = Join-Path $srcDir "info"
if (-not (Test-Path $project)) {
throw "Project file not found: $project"
}
$buildDirectory = $pluginRoot
if (Test-Path $infoFile) {
$infoContent = Get-Content $infoFile -Raw
$buildMatch = [System.Text.RegularExpressions.Regex]::Match($infoContent, '(?im)^BuildDirectory=(.*)$')
if ($buildMatch.Success) {
$buildFromInfo = $buildMatch.Groups[1].Value.Trim()
if (-not [string]::IsNullOrWhiteSpace($buildFromInfo)) {
$buildDirectory = $buildFromInfo
}
}
}
$managedDir = Join-Path $ValheimDir "valheim_Data\Managed"
if (-not (Test-Path $managedDir)) {
throw "Could not find Valheim managed assemblies at: $managedDir"
}
Push-Location $srcDir
try {
dotnet build .\PlaytimeTimers.csproj -c Release /p:ValheimDir="$ValheimDir"
if ($LASTEXITCODE -ne 0) {
throw "dotnet build failed with exit code $LASTEXITCODE"
}
}
finally {
Pop-Location
}
$dllSource = Join-Path $srcDir "bin\Release\net472\PlaytimeTimers.dll"
$dllTarget = Join-Path $buildDirectory "PlaytimeTimers.dll"
if (-not (Test-Path $dllSource)) {
throw "Build completed but DLL not found at: $dllSource"
}
if (-not (Test-Path $buildDirectory)) {
New-Item -ItemType Directory -Path $buildDirectory -Force | Out-Null
}
Copy-Item $dllSource $dllTarget -Force
Write-Host "Built and copied: $dllTarget"