-
Notifications
You must be signed in to change notification settings - Fork 12
/
pack.ps1
105 lines (86 loc) · 3.07 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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
param (
# the additional package source used to restore packages.
# if it's a directory, the generated packages are also copied there
[string]$PushTarget,
[ValidateSet("debug", "release")][string]$Configuration="release",
[switch]$SkipTests,
[string]$PFXPath,
[switch]$DelaySign,
[string]$MsbuildParameters = '',
[string]$PublicRelease,
[string]$BuildNumber
)
# build the specified project to create the nupkg
function Pack(
# the project from which the nupkg is created
[string]$ProjectFile,
# the id of the package
[string]$Id,
# true if -IncludeReferencedProjects is passed to nuget pack command
[Boolean]$IncludeReferencedProjects)
{
# assembly containing the release file version to use for the package
$workingDir = (Get-Item -Path ".\" -Verbose).FullName;
# build the csproj and dll full paths
$projectPath = Join-Path $workingDir $ProjectFile
# Getting the version
$versionInfo = Get-Item "src\NuGet.CommandLine\bin\$Configuration\nuget.exe" | Select-Object -ExpandProperty VersionInfo
$version = $versionInfo.ProductVersion;
Write-Host "Project to build: $projectPath" -ForegroundColor Cyan
Write-Host "Package version: $version" -ForegroundColor Cyan
# Pack
Write-Host "Project path is $ProjectPath"
if ($IncludeReferencedProjects) {
.\.nuget\nuget.exe pack $projectPath -Properties configuration=$Configuration -symbols -OutputDirectory nupkgs -version $version -IncludeReferencedProjects
}
else {
.\.nuget\nuget.exe pack $projectPath -Properties configuration=$Configuration -symbols -OutputDirectory nupkgs -version $version
}
}
function Build()
{
if ($SkipTests)
{
$env:DisableRunningUnitTests="true"
}
else
{
$env:DisableRunningUnitTests="false"
}
if ($PFXPath)
{
$env:NUGET_PFX_PATH=$PFXPath
if ($DelaySign)
{
$env:NUGET_DELAYSIGN="true"
}
}
$env:NUGET_PUSH_TARGET="$PushTarget"
Write-Host "Building! configuration: $Configuration" -ForegroundColor Cyan
$msbuildExe = "${env:ProgramFiles(x86)}\MSBuild\14.0\Bin\msbuild.exe"
& $msbuildExe "build\build.msbuild" /t:Clean /m
& $msbuildExe "build\build.msbuild" "/p:Configuration=$Configuration;PublicRelease=$PublicRelease;BuildNumber=$BuildNumber" /p:EnableCodeAnalysis=true /p:NUGET_BUILD_FEEDS=$PushTarget /m /v:M /fl /flp:v=D $msbuildParameters
if ($lastexitcode -ne 0)
{
throw "Build failed"
}
Write-Host "Build complete! configuration: $Configuration" -ForegroundColor Cyan
}
# create or clean the output folder
if ((Test-Path nupkgs) -eq 0)
{
New-Item -ItemType directory -Path nupkgs | Out-Null
}
else
{
Remove-Item -Path nupkgs\*.nupkg -Force | Out-Null
}
Build
Write-Host "Version=$version"
Pack "src\PackageManagement\PackageManagement.csproj" "NuGet.PackageManagement" $true
Pack "src\PackageManagement.UI\PackageManagement.UI.csproj" "NuGet.PackageManagement.UI" $false
# copy packages to $PushTarget if $PushTarget is a directory
if ($PushTarget -and (Test-Path $PushTarget))
{
Copy-Item "nupkgs\*.nupkg" $PushTarget
}