forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.proj
351 lines (299 loc) · 16.1 KB
/
build.proj
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Available Targets:
/t:Clean
Removes temporary build outputs.
/t:Build
Builds assemblies.
/t:Test
Runs tests
/p:CodeSign=True
Code sign binaries, mainly for official release. Default is false.
/p:CodeSign=True;DelaySign=True
Test the code sign workflow locally.
/p:Scope
'ServiceManagement': service management
'AzureStorage': storage data plane cmdlets
'Subfolder under src\ResourceManager': An individual cmdlet module
By default, it builds all
-->
<!-- Define build properties -->
<PropertyGroup>
<LibraryRoot>$(MSBuildThisFileDirectory)</LibraryRoot>
<LibrarySourceFolder>$(LibraryRoot)src</LibrarySourceFolder>
<LibraryToolsFolder>$(LibraryRoot)tools</LibraryToolsFolder>
<PublishDirectory>$(LibrarySourceFolder)\Publish</PublishDirectory>
<PackageDirectory>$(LibrarySourceFolder)\Package</PackageDirectory>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<CodeSign Condition=" '$(CodeSign)' == '' ">false</CodeSign>
<!--Set this true only if you want to test the code sign workflow locally-->
<DelaySign Condition =" '$(DelaySign)' == '' ">false</DelaySign>
<BuildOutputDirectory>$(PublishDirectory)\Build</BuildOutputDirectory>
<SetupOutputDirectory>$(PublishDirectory)\Setup</SetupOutputDirectory>
<TestOutputDirectory>$(PublishDirectory)\TestResults</TestOutputDirectory>
<BuildInParallel Condition="'$(BuildInParallel)' == ''">true</BuildInParallel>
<NuGetPublishingSource Condition=" '$(NuGetPublishingSource)' == '' ">http://psget/PSGallery/api/v2/</NuGetPublishingSource>
<Scope Condition=" $(Scope) == '' " >all</Scope>
</PropertyGroup>
<ItemGroup>
<CmdletSolutionsToBuild Include=".\src\Storage\Storage.sln;.\src\ResourceManager\**\*.sln;.\src\ServiceManagement\ServiceManagement.sln;"
Exclude=".\src\ResourceManager\Intune\*.sln"
Condition=" '$(Scope)' == 'all' "/>
<CmdletSolutionsToBuild Include=".\src\ResourceManager\$(Scope)\*.sln"
Condition=" '$(Scope)' != 'all' and '$(Scope)' != 'ServiceManagement' and '$(Scope)' != 'AzureStorage' "/>
<CmdletSolutionsToBuild Include=".\src\ServiceManagement\ServiceManagement.sln"
Condition=" '$(Scope)' == 'ServiceManagement'"/>
<CmdletSolutionsToBuild Include=".\src\Storage\Storage.sln"
Condition=" '$(Scope)' == 'AzureStorage' "/>
<SetupSln Include=".\setup\azurepowershell.sln" />
<StaticAnalysis Include=".\tools\StaticAnalysis\StaticAnalysis.sln" />
</ItemGroup>
<!-- Tasks -->
<UsingTask TaskName="ValidateStrongNameSignatureTask" AssemblyFile="$(LibraryToolsFolder)\Microsoft.Azure.Build.Tasks.dll" />
<UsingTask TaskName="FilterOutAutoRestLibraries" AssemblyFile="$(LibraryToolsFolder)\Microsoft.Azure.Build.Tasks.dll" />
<UsingTask TaskName="DebugTask" AssemblyFile="$(LibraryToolsFolder)\Microsoft.Azure.Build.Tasks.dll" />
<UsingTask TaskName="VerifyAuthenticodeSignatureTask" AssemblyFile="$(LibraryToolsFolder)\Microsoft.Azure.Build.Tasks.dll" />
<!--
CI build related
-->
<PropertyGroup>
<!--OnPremiseBuildTasks is not a good name, but CI server is using that, will update across soon-->
<CIToolsPath>$(OnPremiseBuildTasks)</CIToolsPath>
<OnPremiseBuild Condition=" Exists($(OnPremiseBuildTasks)) ">true</OnPremiseBuild>
<OnPremiseBuild Condition=" ! Exists($(OnPremiseBuildTasks)) ">false</OnPremiseBuild>
</PropertyGroup>
<UsingTask Condition=" $(OnPremiseBuild) " TaskName="CodeSigningTask" AssemblyFile="$(CIToolsPath)\Microsoft.WindowsAzure.Tools.Build.Tasks.OnPremise.dll" />
<UsingTask Condition=" $(OnPremiseBuild) " TaskName="CorporateValidation" AssemblyFile="$(CIToolsPath)\Microsoft.WindowsAzure.Tools.Build.Tasks.OnPremise.dll" />
<Import Condition=" $(OnPremiseBuild) " Project="$(CIToolsPath)\Microsoft.WindowsAzure.Build.OnPremise.msbuild" />
<UsingTask
AssemblyFile="$(MSBuildProjectDirectory)\packages\xunit.runner.msbuild.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.runner.msbuild.dll"
TaskName="Xunit.Runner.MSBuild.xunit" />
<!-- Clean the build in all configurations -->
<Target Name="Clean">
<Message Importance="high" Text="Cleaning Cmdlets..." ContinueOnError="false" />
<MSBuild
Projects="@(CmdletSolutionsToBuild)"
Targets="Clean"
Properties="Configuration=$(Configuration);Platform=Any CPU"
ContinueOnError="false" />
<!-- Delete the publish files -->
<Message Importance="high" Text="Cleaning publish files..." ContinueOnError="false" />
<ItemGroup>
<PublishFiles Include="$(PublishDirectory)\**\*.*" />
</ItemGroup>
<Delete
Files="@(PublishFiles)"
ContinueOnError="false" />
<RemoveDir
Directories="$(PublishDirectory)"
ContinueOnError="false" />
<!-- Delete the package files -->
<Message Importance="high" Text="Cleaning package files..." ContinueOnError="false" />
<ItemGroup>
<PackageFiles Include="$(PackageDirectory)\**\*.*" />
</ItemGroup>
<Delete
Files="@(PackageFiles)"
ContinueOnError="false" />
<RemoveDir
Directories="$(PackageDirectory)"
ContinueOnError="false" />
</Target>
<PropertyGroup>
<NuGetCommand>$(MSBuildProjectDirectory)\tools\NuGet.exe</NuGetCommand>
<LibraryNugetPackageFolder>$(LibrarySourceFolder)\packages</LibraryNugetPackageFolder>
<NuGetRestoreConfigFile>$(MSBuildProjectDirectory)\restore.config</NuGetRestoreConfigFile>
<NuGetRestoreConfigSwitch>-ConfigFile "$(NuGetRestoreConfigFile)"</NuGetRestoreConfigSwitch>
<NuGetRestorePackageSetting>-PackagesDirectory $(LibraryNugetPackageFolder)</NuGetRestorePackageSetting>
<PowerShellCommand>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</PowerShellCommand>
</PropertyGroup>
<!--
Force nuget package restore so that packages that include .targets files
don't need to be checked into source control.
-->
<Target Name="RestoreNugetPackages">
<!-- Delete NuGet cache-->
<!--<ItemGroup>
<NuGetCache Include="$(LOCALAPPDATA)\NuGet\Cache\*.nupkg"/>
</ItemGroup>
<Delete Files="@(NuGetCache)" />-->
<Delete Files="$(NuGetRestoreConfigFile)" />
<WriteLinesToFile
File="$(NuGetRestoreConfigFile)"
Lines="<configuration></configuration>"
Overwrite="true"
Encoding="Unicode"/>
<Exec Command="$(NuGetCommand) sources add -Name LocalFeed -Source "$(MSBuildProjectDirectory)\tools\LocalFeed" $(NuGetRestoreConfigSwitch)"/>
<Exec Command="$(NuGetCommand) sources add -Name nugetRemote -Source "https://api.nuget.org/v3/index.json" $(NuGetRestoreConfigSwitch)"/>
<!-- Restore packages -->
<Exec Command="$(NuGetCommand) restore %(CmdletSolutionsToBuild.FullPath) $(NuGetRestoreConfigSwitch) $(NuGetRestorePackageSetting)"
ContinueOnError="false" />
<!-- Restore packages for static analysis-->
<Exec Command="$(NuGetCommand) restore %(StaticAnalysis.FullPath) $(NuGetRestoreConfigSwitch) $(NuGetRestorePackageSetting)"
ContinueOnError="false" />
<!--Restore the xunit runner needed to run unit tests-->
<Exec Command="$(NuGetCommand) restore $(MSBuildProjectDirectory)\packages.config -PackagesDirectory $(MSBuildProjectDirectory)\packages" />
<Delete Files="$(NuGetRestoreConfigFile)" />
</Target>
<!-- Build all flavors of the Cmdlets -->
<Target Name="Build" DependsOnTargets="RestoreNugetPackages;BuildMsBuildTask">
<Message Importance="high" Text="Building Cmdlets..." />
<MSBuild
Projects="@(CmdletSolutionsToBuild)"
Targets="Build"
Properties="Configuration=$(Configuration);Platform=Any CPU"
BuildInParallel="$(BuildInParallel)"
ContinueOnError="false" />
<CallTarget Targets="CodeSignBinaries" Condition=" '$(CodeSign)' == 'true' " />
<MSBuild
Projects="@(SetupSln)"
Targets="Build"
Properties="Configuration=$(Configuration);Platform=Any CPU"
ContinueOnError="false"
Condition=" '$(Scope)' == 'all' "/>
<MSBuild
Projects="@(StaticAnalysis)"
Targets="Build"
Properties="Configuration=Debug;Platform=Any CPU"
ContinueOnError="false" />
<CallTarget Targets="DependencyAnalysis" />
<CallTarget Targets="CodeSignInstaller"
Condition=" '$(CodeSign)' == 'true' and '$(Scope)' == 'all'" />
</Target>
<!-- Do everything possible -->
<Target
Name="Full"
DependsOnTargets="Clean;Build;Test" />
<Target Name="BuildMsBuildTask" DependsOnTargets="RestoreNugetPackages">
<MSBuild Projects="$(LibraryToolsFolder)\BuildPackagesTask\Microsoft.Azure.Build.Tasks.csproj"
Targets="Build" Properties="Configuration=Debug;Platform=AnyCPU" />
</Target>
<Target Name="CodeSignBinaries">
<PropertyGroup>
<!--public token associated with MSSharedLibKey.snk-->
<StrongNameToken Condition=" '$(StrongNameToken)' == '' ">31bf3856ad364e35</StrongNameToken>
</PropertyGroup>
<GetFrameworkSdkPath>
<Output TaskParameter="Path" PropertyName="WindowsSdkPath"/>
</GetFrameworkSdkPath>
<Exec Command="$(PowerShellCommand) -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\UpdateModules.ps1 $(Configuration) $(Scope) ""/>
<!-- Copying shortcut to be signed -->
<Copy SourceFiles="$(LibraryRoot)tools\AzureRM\AzureRM.psd1"
DestinationFolder="$(LibrarySourceFolder)\Package\$(Configuration)" />
<Copy SourceFiles="$(LibraryRoot)tools\AzureRM\AzureRM.psm1"
DestinationFolder="$(LibrarySourceFolder)\Package\$(Configuration)" />
<ItemGroup>
<DelaySignedAssembliesToSign Include="$(LibrarySourceFolder)\Package\$(Configuration)\**\Microsoft*Azure*Commands*.dll" />
<DelaySignedAssembliesToSign Include="$(LibrarySourceFolder)\Package\$(Configuration)\**\Microsoft.Azure.Common.Extensions.dll" />
<ScriptsToSign Include="$(LibrarySourceFolder)\Package\$(Configuration)\**\*.ps1" />
<ScriptsToSign Include="$(LibrarySourceFolder)\Package\$(Configuration)\**\*.psm1" />
<ScriptsToSign Include="$(LibrarySourceFolder)\Package\$(Configuration)\**\*.ps1xml" />
</ItemGroup>
<Message Importance="high" Text="$(LibrarySourceFolder)\Package\$(Configuration) does not contains any files to sign. Code sign will skip."
Condition="'@(DelaySignedAssembliesToSign)' == ''" />
<ValidateStrongNameSignatureTask
WindowsSdkPath="$(WindowsSdkPath)"
Assembly="%(DelaySignedAssembliesToSign.Identity)"
ExpectedTokenSignature="$(StrongNameToken)"
ExpectedDelaySigned="true"
ContinueOnError="false"
Condition="'@(DelaySignedAssembliesToSign)' != ''"/>
<CodeSigningTask
Description="Microsoft Azure PowerShell"
Keywords="Microsoft Azure PowerShell"
UnsignedFiles="@(DelaySignedAssembliesToSign)"
DestinationPath="$(LibrarySourceFolder)\Package\$(Configuration)"
BasePath="$(LibrarySourceFolder)\Package\$(Configuration)"
Certificates="72, 401"
SigningLogPath="$(LibraryRoot)\signing.log"
ToolsPath="$(CIToolsPath)"
Condition="!$(DelaySign) and '@(DelaySignedAssembliesToSign)' != ''"/>
<CodeSigningTask
Description="Microsoft Azure PowerShell"
Keywords="Microsoft Azure PowerShell"
UnsignedFiles="@(ScriptsToSign)"
DestinationPath="$(LibrarySourceFolder)\Package\$(Configuration)"
BasePath="$(LibrarySourceFolder)\Package\$(Configuration)"
Certificates="402"
SigningLogPath="$(LibraryRoot)\signing-scripts.log"
ToolsPath="$(CIToolsPath)"
Condition="!$(DelaySign) and '@(ScriptsToSign)' != ''"/>
<ValidateStrongNameSignatureTask
WindowsSdkPath="$(WindowsSdkPath)"
Assembly="%(DelaySignedAssembliesToSign.Identity)"
ExpectedTokenSignature="$(StrongNameToken)"
ExpectedDelaySigned="false"
ContinueOnError="false"
Condition="!$(DelaySign) and '@(DelaySignedAssembliesToSign)' != ''"/>
<VerifyAuthenticodeSignatureTask ProbingDirectory="$(PackageDirectory)\$(Configuration)"
FileFilterPattern="microsoft.*.dll;system.*.dll;*.ps1;*.psm1">
<Output TaskParameter="AuthCodeSignTaskErrorsDetected" PropertyName="AuthTaskFailed" />
</VerifyAuthenticodeSignatureTask>
<Exec Command="$(PowerShellCommand) -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\CheckStrongNameSignature.ps1 ""/>
<!-- Copying signed shortcut back -->
<Copy SourceFiles="$(LibrarySourceFolder)\Package\$(Configuration)\AzureRM.psd1"
DestinationFolder="$(LibraryRoot)tools\AzureRM" />
<Copy SourceFiles="$(LibrarySourceFolder)\Package\$(Configuration)\AzureRM.psm1"
DestinationFolder="$(LibraryRoot)tools\AzureRM" />
</Target>
<Target Name="CodeSignInstaller">
<PropertyGroup>
<!--public token associated with MSSharedLibKey.snk-->
<StrongNameToken Condition=" '$(StrongNameToken)' == '' ">31bf3856ad364e35</StrongNameToken>
</PropertyGroup>
<GetFrameworkSdkPath>
<Output TaskParameter="Path" PropertyName="WindowsSdkPath"/>
</GetFrameworkSdkPath>
<ItemGroup>
<InstallersToSign Include="$(LibraryRoot)\setup*\build\**\*.msi" />
</ItemGroup>
<Message Importance="high" Text="$(LibraryRoot)\setup does not contains any installers to sign. Code sign will skip."
Condition="'@(InstallersToSign)' == ''" />
<CodeSigningTask
Description="Microsoft Azure PowerShell"
Keywords="Microsoft Azure PowerShell"
UnsignedFiles="@(InstallersToSign)"
DestinationPath="$(LibraryRoot)\signed"
SigningLogPath="$(LibraryRoot)\msi-signing.log"
Certificates="402"
ToolsPath="$(CIToolsPath)"
Condition="!$(DelaySign) and '@(InstallersToSign)' != ''"/>
<!--If we are testing locally then we copy the binaries and do not submit to the code sign server-->
<Copy SourceFiles="@(InstallersToSign)" DestinationFolder="signed" Condition="$(DelaySign)" />
</Target>
<!-- Run Dependecy Analyzer -->
<Target Name="DependencyAnalysis">
<Message Importance="high" Text="Running Dependency Analysis..." />
<Exec Command="$(MSBuildProjectDirectory)\src\Package\StaticAnalysis.exe $(MSBuildProjectDirectory)\src\Package\$(Configuration) $(MSBuildProjectDirectory)\src\Package"/>
</Target>
<!-- Publish all packages -->
<Target Name="Publish">
<Error Condition=" '$(NuGetKey)' == '' " Text="You must provide the NuGetKey parameter to the build: /p:NuGetKey=YOUR_PUBLISHING_KEY" />
<Message Importance="high" Text="Publishing Cmdlets..." />
<Exec Command="$(PowerShellCommand) -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\PublishModules.ps1 $(Configuration) $(Scope) $(NuGetKey) \"$(NuGetPublishingSource)\" ""/>
</Target>
<PropertyGroup>
<RunTestLive Condition="'$(RunTestLive)' == ''">false</RunTestLive>
<XUnitIncludedTrait Condition="!$(RunTestLive)">AcceptanceType=CheckIn</XUnitIncludedTrait>
</PropertyGroup>
<!-- Note: all testing related target should go to 'AzurePowershell.test.targets' file except the one used by CI run -->
<Import Project="$(MSBuildThisFileDirectory)AzurePowershell.test.targets"/>
<!-- Run checkin tests for each pull request -->
<Target Name="Test" DependsOnTargets="BeforeRunTests">
<Message Importance="high" Text="Running check in tests..." />
<CallTarget Targets="InvokeXUnit"/>
</Target>
<!-- Run Full switch with scenario tests -->
<Target
Name="FullWithScenarioTests"
DependsOnTargets="Clean;Build;Test;RunOneSDKCIT" />
<!-- Run live tests and record mocks -->
<Target
Name="RunLiveTests"
DependsOnTargets="Clean;Build;LiveTestsFilter" />
<Target Name="LiveTestsFilter" DependsOnTargets="Build;BeforeRunTests">
<Message Importance="high" Text="Running live tests..." />
<CallTarget Targets="LiveTests"/>
</Target>
</Project>