-
Notifications
You must be signed in to change notification settings - Fork 0
/
postbuild.ps1
43 lines (34 loc) · 1.59 KB
/
postbuild.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
param (
[string]$solutionDir = $null,
[string]$targetPath = $null,
[string]$platformName = $null,
[string]$targetName = $null,
[string]$targetFileName = $null
)
$targetName = $targetName.Split('.')[0]
$targetVersion = (Get-Item $targetPath).VersionInfo.ProductVersion.Split('.')
$version = [string]::Format("{0}.{1}.{2}", $targetVersion[0], $targetVersion[1], $targetVersion[2])
$versionPath = $($solutionDir) + "release\" + $targetName + "_" + $version
$xmlPath = [System.IO.Path]::GetFileNameWithoutExtension($targetPath) + ".xml"
New-Item -ItemType Directory -Force -Path $versionPath
New-Item -ItemType Directory -Force -Path ($versionPath + "\" + $platformName)
Copy-Item $targetPath ($versionPath + "\" + $platformName + "\" + $targetName + [System.IO.Path]::GetExtension($targetFileName))
if(Test-Path $xmlPath)
{
Copy-Item $xmlPath ($versionPath + "\" + $platformName + "\" + $targetName + ".xml")
}
if($platformName -eq "x86" -and $targetFileName.EndsWith("dll"))
{
Copy-Item $targetPath ($($solutionDir) + "nuget\lib\net46\" + $targetFileName)
if(Test-Path $xmlPath)
{
Copy-Item $xmlPath ($($solutionDir) + "nuget\lib\net46\" + [System.IO.Path]::GetFileNameWithoutExtension($targetFileName) + ".xml")
}
}
Add-Type -Assembly System.IO.Compression.FileSystem
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
$zipPath = ($versionPath + ".zip")
If (Test-Path $zipPath){
Remove-Item $zipPath
}
[System.IO.Compression.ZipFile]::CreateFromDirectory($versionPath, $zipPath, $compressionLevel, $false)