-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
62 lines (52 loc) · 2.22 KB
/
Copy pathbuild.ps1
File metadata and controls
62 lines (52 loc) · 2.22 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
57
58
59
60
61
62
#Requires -Version 7.4
<#
.SYNOPSIS
Build and deploy GitDrive to PowerShell Modules directory.
.PARAMETER Configuration
Build configuration: Debug or Release (default: Release)
.PARAMETER ModulePath
Deployment target directory (default: $env:ProgramFiles\PowerShell\7\Modules\GitDrive)
#>
param(
[ValidateSet('Debug', 'Release')]
[string]$Configuration = 'Release',
[string]$ModulePath = "$env:ProgramFiles\PowerShell\7\Modules\GitDrive"
)
$ErrorActionPreference = 'Stop'
$projectDir = $PSScriptRoot
$srcProject = Join-Path $projectDir 'src\GitDrive\GitDrive.csproj'
$moduleSource = Join-Path $projectDir 'module'
# 1. Build C# project
Write-Host "Building GitDrive ($Configuration)..." -ForegroundColor Cyan
dotnet build $srcProject -c $Configuration --nologo -v q
if ($LASTEXITCODE -ne 0) { throw 'Build failed.' }
# 2. Clean output directory
if (Test-Path $ModulePath) {
Remove-Item "$ModulePath\*" -Recurse -Force
} else {
New-Item -Path $ModulePath -ItemType Directory -Force | Out-Null
}
# 3. Copy module files
Copy-Item (Join-Path $moduleSource 'GitDrive.psd1') $ModulePath
Copy-Item (Join-Path $moduleSource 'GitDrive.Format.ps1xml') $ModulePath
# 4. Copy GitDrive.dll and LibGit2Sharp.dll only (not all SDK DLLs)
$buildOutput = Join-Path $projectDir "src\GitDrive\bin\$Configuration\net8.0"
Copy-Item (Join-Path $buildOutput 'GitDrive.dll') $ModulePath
Copy-Item (Join-Path $buildOutput 'LibGit2Sharp.dll') $ModulePath
# 5. Copy LibGit2Sharp native binary to module root
$arch = if ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq 'Arm64') { 'win-arm64' } else { 'win-x64' }
$nativeSrc = Join-Path $buildOutput "runtimes\$arch\native"
if (Test-Path $nativeSrc) {
Get-ChildItem $nativeSrc -Filter 'git2-*' | Copy-Item -Destination $ModulePath
}
# 6. Copy help files
$helpSource = Join-Path $moduleSource 'en-US'
if (Test-Path $helpSource) {
$helpDest = Join-Path $ModulePath 'en-US'
if (-not (Test-Path $helpDest)) {
New-Item $helpDest -ItemType Directory -Force | Out-Null
}
Copy-Item "$helpSource\*" $helpDest -Recurse -Force
}
Write-Host "Deployed to $ModulePath" -ForegroundColor Green
Get-ChildItem $ModulePath -File | Format-Table Name, Length -AutoSize