-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpack.ps1
50 lines (39 loc) · 1.61 KB
/
pack.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
[CmdletBinding()]
param (
[Parameter()]
[bool]
$install = $false
)
$location = Get-Location
Write-Host 'Compressing files...'
$filePahts = @('WebApp/css/app.css', 'WebApp/css/docs.css', 'WebApp/css/markdown.css', 'WebApp/css/keyboard_arrow_right.svg',
'WebApp/js/blogs.js', 'WebApp/js/docs.js', 'WebApp/js/index.js', 'WebApp/js/markdown.js',
'WebApp/favicon.ico'
)
$zipFilePath = Join-Path $location './src/Share/template/web.zip'
# delete old zip file
if (Test-Path $zipFilePath) {
Remove-Item $zipFilePath
}
$zip = [System.IO.Compression.ZipFile]::Open($zipFilePath, [System.IO.Compression.ZipArchiveMode]::Create)
foreach ($filePath in $filePahts) {
$destName = $filePath.Replace('WebApp/', '');
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip, $(Join-Path $location $filePath), $destName)
}
$zip.Dispose()
Write-host 'Compressing files done.'
Write-Host 'Packing new version...'
dotnet build ./src/BuildSite -c release
dotnet pack ./src/BuildSite -c release
if ($install) {
# get package name and version
$VersionNode = Select-Xml -Path ./src/BuildSite/BuildSite.csproj -XPath '/Project//PropertyGroup/Version'
$PackageNode = Select-Xml -Path ./src/BuildSite/BuildSite.csproj -XPath '/Project//PropertyGroup/PackageId'
$Version = $VersionNode.Node.InnerText
$PackageId = $PackageNode.Node.InnerText
# uninstall old version
Write-Host 'uninstall old version'
dotnet tool uninstall -g $PackageId
Write-Host 'install new version:'$PackageId $Version
dotnet tool install -g --add-source ./src/BuildSite/nupkg $PackageId --version $Version
}