Skip to content

Commit b54e5ad

Browse files
author
Staffan Gustafsson
committed
Making install.ps1 build with msbuild
1 parent 8fbc617 commit b54e5ad

1 file changed

Lines changed: 35 additions & 4 deletions

File tree

install.ps1

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,41 @@
1+
param(
2+
[ValidateSet('Debug', 'Release')]
3+
[string]$Configuration = 'Release'
4+
,
5+
[switch] $Rebuild
6+
)
7+
Set-StrictMode -Version Latest
8+
$man = Test-ModuleManifest $PSScriptRoot/PSEverything/PSEverything.psd1
9+
10+
$msbuild = Resolve-Path ${env:ProgramFiles(x86)}\msbuild\*\bin\msbuild.exe | Select-Object -last 1
11+
[string] $sln = Resolve-Path "$PSScriptRoot\$($man.Name).sln"
12+
13+
if($msbuild -eq $Null){
14+
throw "Cannot find msbuild.exe"
15+
}
16+
17+
$msbuildArgs = @("/p:Configuration=$Configuration")
18+
if ($Rebuild){
19+
$msbuildArgs += '/target:rebuild'
20+
}
21+
else{
22+
$msbuildArgs += '/target:build'
23+
}
24+
$msbuildArgs += $sln
25+
"$msbuildArgs"
26+
& $msbuild.ProviderPath $msbuildArgs
27+
128
$man = Test-ModuleManifest $PSScriptRoot/PSEverything/PSEverything.psd1
229

330
$name = $man.Name
431
[string]$version = $man.Version
5-
$moduleSourceDir = "$PSScriptRoot/PSEverything/bin/release/PSEverything"
32+
$moduleSourceDir = "$PSScriptRoot/PSEverything/bin/$Configuration/PSEverything"
633
$moduleDir = "~/documents/WindowsPowerShell/Modules/$name/$version/"
734

835
$newLine = [Environment]::NewLine
36+
937
$ofs = $newLine
10-
[string]$about_content = Get-Content $PSScriptRoot/README.md | foreach {
38+
[string]$about_content = Get-Content $PSScriptRoot/README.md | ForEach-Object {
1139
$_ -replace '```.*', ''
1240
}
1341

@@ -16,8 +44,11 @@ if (-not (Test-Path $moduleDir))
1644
$null = mkdir $moduleDir
1745
}
1846

19-
Get-ChildItem $moduleSourceDir | copy -Destination $moduleDir
47+
Get-ChildItem $moduleSourceDir | Copy-Item -Destination $moduleDir -ErrorAction:Continue
2048
Set-Content -Path $moduleDir/about_${name}.help.txt -value $about_content
2149

2250
$cert =Get-ChildItem cert:\CurrentUser\My -CodeSigningCert
23-
Get-ChildItem $moduleDir/*.ps?1,$moduleDir/*.dll | Set-AuthenticodeSignature -Certificate $cert -TimestampServer http://timestamp.verisign.com/scripts/timstamp.dll
51+
if($cert)
52+
{
53+
Get-ChildItem $moduleDir/*.ps?1,$moduleDir/*.dll | Set-AuthenticodeSignature -Certificate $cert -TimestampServer http://timestamp.verisign.com/scripts/timstamp.dll
54+
}

0 commit comments

Comments
 (0)