-
Notifications
You must be signed in to change notification settings - Fork 1
/
package.ps1
47 lines (36 loc) · 1.4 KB
/
package.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
$root = (split-path -parent $MyInvocation.MyCommand.Definition)
$packageRoot = "$root"
$versionFile = "$packageRoot\.version"
$artifactsPath = "$packageRoot\Artifacts"
$targetNugetExe = "$packageRoot\nuget.exe"
If (Test-Path $artifactsPath)
{
# Delete any existing output.
Remove-Item $artifactsPath\*.nupkg
}
If (!(Test-Path $targetNugetExe))
{
$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
Write-Host "NuGet.exe not found - downloading latest from $sourceNugetExe"
$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
}
$VERSION = (Get-Content $versionFile)
Write-Host "Setting .nuspec version tag to $VERSION"
$compiledNuspec = "$packageRoot\compiled.nuspec"
# Create new packages for any nuspec files that exist in this directory.
Foreach ($nuspec in $(Get-Item "$packageRoot\*.nuspec"))
{
$content = (Get-Content $nuspec)
$content = $content -replace '\$version\$',$VERSION
$content = $content -replace '\$configuration\$',$CONFIGURATION
$content = $content -replace '\$framework\$',$FRAMEWORK
$content = $content -replace '\$root\$',$root
$content | Out-File $compiledNuspec
& $targetNugetExe pack $compiledNuspec -outputdirectory $artifactsPath
}
# Delete compiled temporary nuspec.
If (Test-Path $compiledNuspec)
{
Remove-Item $compiledNuspec
}