-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpsmake.mod.packaging.ps1
More file actions
192 lines (159 loc) · 6.04 KB
/
Copy pathpsmake.mod.packaging.ps1
File metadata and controls
192 lines (159 loc) · 6.04 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<#
.SYNOPSIS
Packages Visual Studio projects (like .csproj etc.)
.DESCRIPTION
Packages Visual Studio projects to .nupkg package.
By default, all project references are packaged as nuget references (nuget.exe is called with .csproj file and -IncludeReferencedProjects flag).
.EXAMPLE
PS> Package-VSProject -Project "c:\solution\project.csproj"
#>
function Package-VSProject
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)]
# Visual Studio project path
[ValidateNotNullOrEmpty()]
[string]$Project,
[Parameter()]
# Project configuration. Default: Release
[ValidateNotNullOrEmpty()]
[string]$Configuration = "Release",
[Parameter()]
# Include referenced projects. Default: true
[ValidateNotNull()]
[bool]$IncludeReferencedProjects = $true,
[Parameter()]
# Generate symbol package. Default: false
[ValidateNotNull()]
[bool]$Symbols = $false,
[Parameter()]
# Overwrite package version with specified value. Default: null, which means no.
[string]$Version = $null,
[Parameter()]
# Output directory. Default: .
[ValidateNotNullOrEmpty()]
[string]$Output = '.',
[Parameter()]
# Project Platform. Default: AnyCPU
[ValidateNotNullOrEmpty()]
[string]$Platform = "AnyCPU"
)
process {
$arguments = @("pack",$Project,"-Prop","Configuration=$Configuration","-Prop","Platform=$Platform","-NonInteractive","-OutputDirectory",$Output)
if ($IncludeReferencedProjects) { $arguments += "-IncludeReferencedProjects"}
if ($Symbols) { $arguments += "-Symbols" }
if ($Version) { $arguments += "-Version"; $arguments += $Version; }
Write-ShortStatus "Packaging: $Project..."
call $Context.NuGetExe @arguments
}
}
<#
.SYNOPSIS
Packages .nuspec file.
.DESCRIPTION
Packages .nuspec to .nupkg package.
This method is dedicated for creation of deployable packages, so -NoPackageAnalysis is set by default and nuget.exe is called with .nuspec file.
.EXAMPLE
PS> Package-DeployableNuSpec -Package "c:\solution\project.nuspec"
#>
function Package-DeployableNuSpec
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)]
# NuSpec file path
[ValidateNotNullOrEmpty()]
[string]$Package,
[Parameter()]
# Overwrite package version with specified value. Default: null, which means no.
[string]$Version = $null,
[Parameter()]
# Output directory. Default: .
[ValidateNotNullOrEmpty()]
[string]$Output = '.',
[Parameter()]
# No package analysis. Default: true
[ValidateNotNull()]
[bool]$NoPackageAnalysis = $true,
[Parameter()]
# No default excluded. Default: false
[ValidateNotNull()]
[bool]$NoDefaultExcludes = $false
)
process {
$arguments = "pack",$Package,"-NonInteractive","-OutputDirectory",$Output
if ($NoPackageAnalysis) { $arguments += "-NoPackageAnalysis"}
if ($NoDefaultExcludes) { $arguments += "-NoDefaultExcludes"}
if ($Version) { $arguments += "-Version"; $arguments += $Version; }
Write-ShortStatus "Packaging: $Package..."
call $Context.NuGetExe @arguments
}
}
<#
.SYNOPSIS
Finds Visual Studio projects suitable for packaging.
.DESCRIPTION
Finds Visual Studio projects suitable for packaging.
This method scans a specified directory (see -Path parameter) and its sub-directories and returns paths to all projects that have corresponding .nuspec files of the same name and located in the same directory.
.EXAMPLE
PS> Find-VSProjectsForPackaging -Path 'c:\solution' | Package-VSProject
Scans 'c:\solution' directory and sub-directories and packages all .csproj projects that have corresponding .nuspec files.
.EXAMPLE
PS> Find-VSProjectsForPackaging -Path 'c:\solution' -Exclude '*Host.csproj' | Package-VSProject
Scans 'c:\solution' directory and sub-directories and packages all .csproj projects that have corresponding .nuspec files, excluding *Host projects.
#>
function Find-VSProjectsForPackaging
{
[CmdletBinding()]
param(
[Parameter()]
# A path to start search. Default: .
[ValidateNotNullOrEmpty()]
[string]$Path = '.',
[Parameter()]
# Projects to find. Default: *.csproj
[ValidateNotNullOrEmpty()]
[string]$Filter = '*.csproj',
[Parameter()]
# Projects to exclude. Default: @()
[ValidateNotNullOrEmpty()]
[string[]]$Exclude = @()
)
return Get-ChildItem -Path $Path -Filter $Filter -Recurse -Exclude $Exclude `
| Where-Object { Test-Path ($_.fullname -replace $_.Extension,'.nuspec')} `
| %{$_.fullname }
}
<#
.SYNOPSIS
Finds .nuspec files.
.DESCRIPTION
Finds .nuspec files.
This method scans a specified directory (see -Path parameter) and its sub-directories and returns paths to all matching .nuspec files.
.EXAMPLE
PS> Find-NuSpecFiles -Path 'c:\solution' | Package-DeployableNuSpec
Scans 'c:\solution' directory and sub-directories and packages all .nuspec files.
.EXAMPLE
PS> Find-NuSpecFiles -Path 'c:\solution' -Filter '*-deploy.nuspec' | Package-DeployableNuSpec
Scans 'c:\solution' directory and sub-directories and packages all .nuspec files that have -deploy suffix.
#>
function Find-NuSpecFiles
{
[CmdletBinding()]
param(
[Parameter()]
# A path to start search. Default: .
[ValidateNotNullOrEmpty()]
[string]$Path = '.',
[Parameter()]
# NuSpec files to find. Default: *.nuspec
[ValidateNotNullOrEmpty()]
[string]$Filter = '*.nuspec',
[Parameter()]
# NuSpec to exclude. Default: @()
[ValidateNotNullOrEmpty()]
[string[]]$Exclude = @()
)
return Get-ChildItem -Path $Path -Filter $Filter -Recurse -Exclude $Exclude `
| %{$_.fullname }
}