-
Notifications
You must be signed in to change notification settings - Fork 7
/
Build-NugetPackage.ps1
45 lines (31 loc) · 1.23 KB
/
Build-NugetPackage.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
function Install-Nuget {
# Path to Latest nuget.exe on nuget.org
$source = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
# Save file to top level directory in repo
$destination = "$scriptPath\nuget.exe"
#Download the file
if (-Not [System.IO.File]::Exists($destination)) {
Invoke-WebRequest -Uri $source -OutFile $destination
}
}
function Build-Nuget {
param (
[string]
$packageId,
[string]
$basePath
)
[string] $nugetSpecTemplate = [System.IO.File]::ReadAllText([System.IO.Path]::Combine($scriptPath, "Guan.nuspec.template"))
[string] $nugetSpecPath = "$scriptPath\Guan\bin\release\netstandard2.0\$($packageId).nuspec"
[System.IO.File]::WriteAllText($nugetSpecPath, $nugetSpecTemplate.Replace("%PACKAGE_ID%", $packageId).Replace("%ROOT_PATH%", $scriptPath))
.\nuget.exe pack $nugetSpecPath -basepath $basePath -OutputDirectory bin\release\Guan\Nugets -properties NoWarn=NU5100,NU5128
}
[string] $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
try {
Push-Location $scriptPath
Install-Nuget
Build-Nuget "Microsoft.Logic.Guan" "$scriptPath\Guan\bin\release\netstandard2.0"
}
finally {
Pop-Location
}