-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathAfterBuild.ps1
More file actions
53 lines (43 loc) · 1.14 KB
/
AfterBuild.ps1
File metadata and controls
53 lines (43 loc) · 1.14 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
param (
[string]$ProjectDir = (Get-Location).Path
)
Write-Host "Select build output path:"
Write-Host " 1) bin\Debug"
Write-Host " 2) bin\Release"
Write-Host ""
$choice = Read-Host "Enter choice (1 or 2)"
switch ($choice) {
"1" { $OutputPath = Join-Path $ProjectDir "bin\Debug" }
"2" { $OutputPath = Join-Path $ProjectDir "bin\Release" }
default {
Write-Error "Invalid choice. Aborting."
exit 1
}
}
if (-not (Test-Path $OutputPath)) {
Write-Error "Output path does not exist: $OutputPath"
exit 1
}
$LibPath = Join-Path $OutputPath "lib"
if (-not (Test-Path $LibPath)) {
New-Item -ItemType Directory -Path $LibPath | Out-Null
}
$Patterns = @(
"*.dll",
"*.pdb",
"*.xml",
"*.dll.config"
)
foreach ($pattern in $Patterns) {
Get-ChildItem -Path $OutputPath -Filter $pattern -File -ErrorAction SilentlyContinue |
ForEach-Object {
if ($_.IsReadOnly) {
$_.IsReadOnly = $false
}
Move-Item `
-Path $_.FullName `
-Destination $LibPath `
-Force
}
}
Write-Host "Files moved to $LibPath"