forked from PowerShell/PSReadLine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeRelease.ps1
88 lines (67 loc) · 2.33 KB
/
MakeRelease.ps1
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
param([switch]$Install, [switch]$BuildChocolatey)
add-type -AssemblyName System.IO.Compression.FileSystem
if (-not(Get-Command -Name msbuild -ErrorAction Ignore))
{
$env:path += ";${env:SystemRoot}\Microsoft.Net\Framework\v4.0.30319"
}
msbuild $PSScriptRoot\PSReadline\PSReadLine.sln /t:Rebuild /p:Configuration=Release
$targetDir = "${env:Temp}\PSReadline"
if (Test-Path -Path $targetDir)
{
rmdir -Recurse $targetDir
}
$null = mkdir $targetDir
$null = mkdir $targetDir\en-US
$files = @('PSReadline\Changes.txt',
'PSReadline\License.txt',
'PSReadline\SamplePSReadlineProfile.ps1',
'PSReadline\PSReadline.psd1',
'PSReadline\PSReadline.psm1',
'PSReadline\PSReadline.format.ps1xml',
'PSReadline\bin\Release\Microsoft.PowerShell.PSReadline.dll')
foreach ($file in $files)
{
copy $PSScriptRoot\$file $targetDir
}
$files = @('PSReadline\en-US\about_PSReadline.help.txt',
'PSReadline\en-US\PSReadline.dll-help.xml')
foreach ($file in $files)
{
copy $PSScriptRoot\$file $targetDir\en-us
}
$version = (Get-ChildItem -Path $targetDir\Microsoft.PowerShell.PSReadline.dll).VersionInfo.FileVersion
& $PSScriptRoot\Update-ModuleManifest.ps1 $targetDir\PSReadline.psd1 $version
#make sure chocolatey is installed and in the path
if ($BuildChocolatey -and (Get-Command -Name cpack -ErrorAction Ignore))
{
$chocolateyDir = "$PSScriptRoot\ChocolateyPackage"
if (Test-Path -Path $chocolateyDir\PSReadline)
{
rmdir -Recurse $chocolateyDir\PSReadline
}
& $PSScriptRoot\Update-NuspecVersion.ps1 "$chocolateyDir\PSReadline.nuspec" $version
copy -Recurse $targetDir $chocolateyDir\PSReadline
cpack "$chocolateyDir\PSReadline.nuspec"
}
del $PSScriptRoot\PSReadline.zip -ErrorAction Ignore
[System.IO.Compression.ZipFile]::CreateFromDirectory($targetDir, "$PSScriptRoot\PSReadline.zip")
if ($Install)
{
$InstallDir = "$HOME\Documents\WindowsPowerShell\Modules"
if (-not(Test-Path -Path $InstallDir))
{
mkdir -force $InstallDir
}
try
{
if (Test-Path -Path $InstallDir\PSReadline)
{
rmdir -Recurse -force $InstallDir\PSReadline -ErrorAction Stop
}
copy -Recurse $targetDir $InstallDir
}
catch
{
Write-Error -Message "Can't install, module is probably in use."
}
}