forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.proj
526 lines (443 loc) · 30.8 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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
<?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
/t:Publish
Creates local nuget packages and MSI
/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
/p:SkipHelp=True
Skips help generation, mainly for local builds to save time.
-->
<!-- 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>
<SignedOutputRootDir>$(LibraryRoot)signed</SignedOutputRootDir>
<BuildOutputDirectory>$(PublishDirectory)\Build</BuildOutputDirectory>
<TestOutputDirectory>$(PublishDirectory)\TestResults</TestOutputDirectory>
<BuildInParallel Condition="'$(BuildInParallel)' == ''">true</BuildInParallel>
<NuGetPublishingSource Condition=" '$(NuGetPublishingSource)' == '' ">http://psget/PSGallery/api/v2/</NuGetPublishingSource>
<StackPublishingSource Condition=" '$(StackPublishingSource)' == '' ">$(LibrarySourceFolder)</StackPublishingSource>
<Scope Condition=" $(Scope) == '' " >all</Scope>
<NetCore Condition=" $(NetCore) == '' " >false</NetCore>
<SkipHelp Condition =" '$(SkipHelp)' == '' ">false</SkipHelp>
<BuildTasksPath>$(LibraryToolsFolder)\BuildPackagesTask\Microsoft.Azure.Build.Tasks\bin\$(Configuration)</BuildTasksPath>
<Stack Condition = "(('$(Scope)' == '' or '$(Scope)' == 'all') and '$(NetCore)' == 'false') or '$(Scope)' == 'Stack' ">true</Stack>
<Latest Condition = "'$(Scope)' == '' or '$(Scope)' != 'Stack'">true</Latest>
</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' and '$(Scope)' != 'Stack' "/>
<CmdletSolutionsToBuild Include=".\src\ServiceManagement\ServiceManagement.sln"
Condition=" '$(Scope)' == 'ServiceManagement'"/>
<CmdletSolutionsToBuild Include=".\src\Storage\Storage.sln"
Condition=" '$(Scope)' == 'AzureStorage' "/>
<CmdletSolutionsToBuild Include=".\src\Stack.sln"
Condition=" '$(Stack)' == 'true' "/>
<StaticAnalysis Include=".\tools\StaticAnalysis\StaticAnalysis.sln" />
<LocalBuildTasks Include="$(LibraryToolsFolder)\BuildPackagesTask\Microsoft.Azure.Build.Tasks.sln" />
<LocalBuildTasks Include="$(LibraryToolsFolder)\RepoTasks\RepoTasks.sln" Condition="'$(NetCore)' == 'false'"/>
</ItemGroup>
<!-- Tasks -->
<UsingTask TaskName="ValidateStrongNameSignatureTask" AssemblyFile="$(BuildTasksPath)\Microsoft.Azure.Build.Tasks.dll" />
<UsingTask TaskName="FilterOutAutoRestLibraries" AssemblyFile="$(BuildTasksPath)\Microsoft.Azure.Build.Tasks.dll" />
<UsingTask TaskName="DebugTask" AssemblyFile="$(BuildTasksPath)\Microsoft.Azure.Build.Tasks.dll" />
<UsingTask TaskName="VerifyAuthenticodeSignatureTask" AssemblyFile="$(BuildTasksPath)\Microsoft.Azure.Build.Tasks.dll" />
<UsingTask TaskName="SmartTestingTask" AssemblyFile="$(BuildTasksPath)\Microsoft.Azure.Build.Tasks.dll" />
<UsingTask TaskName="SetEnvVar" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
<ParameterGroup>
<EnvName ParameterType="System.String" Required="true" />
<EnvValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System"/>
<Code Type="Fragment" Language="cs">
<![CDATA[System.Environment.SetEnvironmentVariable(EnvName, EnvValue);]]>
</Code>
</Task>
</UsingTask> <!--
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>
<NuGetLocalBuildTaskPackages>-PackagesDirectory $(LibraryToolsFolder)\BuildPackagesTask\packages</NuGetLocalBuildTaskPackages>
<NuGetRepoTasksPackages>-PackagesDirectory $(LibraryToolsFolder)\RepoTasks\packages</NuGetRepoTasksPackages>
<PowerShellCommand Condition=" '$(PowerShellCommand)' == '' ">C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</PowerShellCommand>
<PowerShellCoreCommand Condition=" '$(PowerShellCoreCommand)' == '' ">pwsh</PowerShellCoreCommand>
</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 packages for local build tasks-->
<Exec Command="$(NuGetCommand) restore %(LocalBuildTasks.FullPath) $(NuGetRestoreConfigSwitch) $(NuGetLocalBuildTaskPackages)"
ContinueOnError="false" />
<!-- Restore packages for repo tasks tasks-->
<Exec Command="$(NuGetCommand) restore %(LocalBuildTasks.FullPath) $(NuGetRestoreConfigSwitch) $(NuGetRepoTasksPackages)"
ContinueOnError="false" />
<Exec Command="$(NuGetCommand) restore %(SetupSln.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..." />
<MakeDir Directories="$(PackageDirectory)" />
<MSBuild
Projects="@(CmdletSolutionsToBuild)"
Targets="Build"
Properties="Configuration=$(Configuration);Platform=Any CPU"
BuildInParallel="$(BuildInParallel)"
ContinueOnError="false" />
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command "$ProgressPreference = 'SilentlyContinue';. $(LibraryToolsFolder)\GenerateHelp.ps1 -ValidateMarkdownHelp -GenerateMamlHelp -BuildConfig $(Configuration) ""
ContinueOnError="false"
Condition=" '$(SkipHelp)' == 'false' and '$(Latest)' == 'true'"/>
<!-- moved copy tasks -->
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\UpdateModules.ps1 $(Configuration) $(Scope) -Profile Latest " " Condition="'$(Latest)' == 'true' and '$(CodeSign)' == 'false'"/>
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\UpdateModules.ps1 $(Configuration) $(Scope) -Profile Stack " " Condition="'$(Stack)' == 'true' and '$(CodeSign)' == 'false'"/>
<Exec ContinueOnError="false"
Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command " . $(LibraryToolsFolder)\NewHelpIndex.ps1 -OutputFile $(PackageDirectory)\index.json -BuildConfig $(Configuration) "" Condition="'$(Latest)' == 'true'"/>
<!-- Copying shortcut to be signed -->
<Copy SourceFiles="$(LibraryRoot)tools\AzureRM\AzureRM.psd1"
DestinationFolder="$(LibrarySourceFolder)\Package\$(Configuration)" Condition= " '$(NetCore)' == 'false' and '$(Latest)' == 'true'"/>
<Copy SourceFiles="$(LibraryRoot)tools\AzureRM\AzureRM.psm1"
DestinationFolder="$(LibrarySourceFolder)\Package\$(Configuration)" Condition= " '$(NetCore)' == 'false' and '$(Latest)' == 'true' and '$(CodeSign)' == 'false'"/>
<Copy SourceFiles="$(LibrarySourceFolder)\StackAdmin\AzureRM\AzureRM.psd1"
DestinationFolder="$(LibrarySourceFolder)\Stack\$(Configuration)" Condition= " '$(NetCore)' == 'false' and '$(Stack)' == 'true' "/>
<Copy SourceFiles="$(LibrarySourceFolder)\StackAdmin\AzureRM\AzureRM.psm1"
DestinationFolder="$(LibrarySourceFolder)\Stack\$(Configuration)" Condition= " '$(NetCore)' == 'false' and '$(Stack)' == 'true' and '$(CodeSign)' == 'false'"/>
<Copy SourceFiles="$(LibrarySourceFolder)\StackAdmin\AzureStack\AzureStack.psd1"
DestinationFolder="$(LibrarySourceFolder)\Stack\$(Configuration)" Condition= " '$(NetCore)' == 'false' and '$(Stack)' == 'true' "/>
<Copy SourceFiles="$(LibrarySourceFolder)\StackAdmin\AzureStack\AzureStack.psm1"
DestinationFolder="$(LibrarySourceFolder)\Stack\$(Configuration)" Condition= " '$(NetCore)' == 'false' and '$(Stack)' == 'true' and '$(CodeSign)' == 'false'"/>
<CallTarget Targets="CodeSignBinaries" Condition=" '$(CodeSign)' == 'true' " />
<Copy SourceFiles="$(LibrarySourceFolder)\Package\$(Configuration)\AzureRM.psd1"
DestinationFolder="$(LibraryRoot)tools\AzureRM" Condition= " '$(NetCore)' == 'false' and '$(Latest)' == 'true' "/>
<Copy SourceFiles="$(LibrarySourceFolder)\Package\$(Configuration)\AzureRM.psm1"
DestinationFolder="$(LibraryRoot)tools\AzureRM" Condition= " '$(NetCore)' == 'false' and '$(Latest)' == 'true' "/>
<Copy SourceFiles="$(LibrarySourceFolder)\Stack\$(Configuration)\AzureRM.psd1"
DestinationFolder="$(LibrarySourceFolder)\StackAdmin\AzureRM" Condition= " '$(NetCore)' == 'false' and '$(Stack)' == 'true' "/>
<Copy SourceFiles="$(LibrarySourceFolder)\Stack\$(Configuration)\AzureRM.psm1"
DestinationFolder="$(LibrarySourceFolder)\StackAdmin\AzureRM" Condition= " '$(NetCore)' == 'false' and '$(Stack)' == 'true' "/>
<Copy SourceFiles="$(LibrarySourceFolder)\Stack\$(Configuration)\AzureStack.psd1"
DestinationFolder="$(LibrarySourceFolder)\StackAdmin\AzureStack" Condition= " '$(NetCore)' == 'false' and '$(Stack)' == 'true' "/>
<Copy SourceFiles="$(LibrarySourceFolder)\Stack\$(Configuration)\AzureStack.psm1"
DestinationFolder="$(LibrarySourceFolder)\StackAdmin\AzureStack" Condition= " '$(NetCore)' == 'false' and '$(Stack)' == 'true' "/>
<!-- moved copy tasks -->
<Message Importance="high" Text="Running Static Analyser" />
<CallTarget targets="DependencyAnalysis" ContinueOnError="ErrorAndContinue" />
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\CheckAssemblies.ps1 -BuildConfig $(Configuration) "" />
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\CleanupBuild.ps1 -BuildConfig $(Configuration) "" />
</Target>
<!-- Build .Net Core Cmdlets -->
<Target Name="BuildNetcore">
<Message Importance="high" Text="Building Cmdlets..." />
<!-- Build and create package content -->
<Exec Command="dotnet --version"/>
<Exec Command="dotnet publish Azure.PowerShell.Netcore.sln -c $(Configuration)"/>
<!-- Delete powershell runtime files -->
<ItemGroup>
<RedundantDlls Include="$(PackageDirectory)\**\publish\Microsoft.Powershell.*.dll" />
<RedundantDlls Include="$(PackageDirectory)\**\publish\System*.dll"
Exclude="$(PackageDirectory)\**\publish\System.Security.Cryptography.ProtectedData.dll" />
<RedundantDlls Include="$(PackageDirectory)\**\publish\Microsoft.VisualBasic.dll" />
<RedundantDlls Include="$(PackageDirectory)\**\publish\Microsoft.CSharp.dll" />
<RedundantDlls Include="$(PackageDirectory)\**\publish\Microsoft.CodeAnalysis.dll" />
<RedundantDlls Include="$(PackageDirectory)\**\publish\Microsoft.CodeAnalysis.CSharp.dll" />
</ItemGroup>
<Delete Files="@(RedundantDlls->'%(FullPath)')"/>
<!-- Copy content of the publish folder one folder up. -->
<ItemGroup>
<PackageContent Include="$(PackageDirectory)\**\publish\*.*" />
<SourceFile Include="@(PackageContent)">
<DestinationFolder>$([System.IO.Path]::Combine('%(RelativeDir)', '..', '%(FileName)%(Extension)'))</DestinationFolder>
</SourceFile>
</ItemGroup>
<Copy SourceFiles="@(SourceFile->'%(FullPath)')" DestinationFiles="@(SourceFile->'%(DestinationFolder)')" SkipUnchangedFiles="true"/>
<!-- Delete build artifacts -->
<ItemGroup>
<GetAllFiles Include="$(PackageDirectory)\**\publish\*.*" />
<Artifacts Include="@(GetAllFiles->'%(RootDir)%(Directory)'->Distinct())" />
</ItemGroup>
<RemoveDir Directories="%(Artifacts.Identity)" ContinueOnError="true" />
<ItemGroup>
<ExtraPsdFiles Include="$(PackageDirectory)\$(Configuration)\ResourceManager\AzureResourceManager\AzureRM.Resources.Netcore\AzureRM.Tags.Netcore.psd1" />
<ExtraPsdFiles Include="$(PackageDirectory)\$(Configuration)\ResourceManager\AzureResourceManager\AzureRM.Websites.Netcore\AzureRM.Resources.Netcore.psd1" />
<ExtraPsdFiles Include="$(PackageDirectory)\$(Configuration)\ResourceManager\AzureResourceManager\AzureRM.Websites.Netcore\AzureRM.Tags.Netcore.psd1" />
<ExtraPsdFiles Include="$(PackageDirectory)\$(Configuration)\ResourceManager\AzureResourceManager\AzureRM.Network.Netcore\AzureRM.Resources.Netcore.psd1" />
<ExtraPsdFiles Include="$(PackageDirectory)\$(Configuration)\ResourceManager\AzureResourceManager\AzureRM.Network.Netcore\AzureRM.Tags.Netcore.psd1" />
</ItemGroup>
<Delete Files="@(ExtraPsdFiles->'%(FullPath)')"/>
<!-- Update module manifests. -->
<Exec Command=""$(PowerShellCoreCommand)" -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\UpdateModules.ps1 $(Configuration) AzureRM.Netcore -Profile Latest " " Condition="'$(Latest)' == 'true'" ContinueOnError="false" />
<!-- Generate the help. -->
<Exec Command=""$(PowerShellCoreCommand)" -NonInteractive -NoLogo -NoProfile -Command "Set-Variable -Name ProgressPreference -Value 'SilentlyContinue';. $(LibraryToolsFolder)\GenerateHelp.ps1 -GenerateMamlHelp -BuildConfig $(Configuration) "" ContinueOnError="true" Condition=" '$(SkipHelp)' == 'false' and '$(Latest)' == 'true'"/>
<!-- Cleanup extraneous files. -->
<Exec Command=""$(PowerShellCoreCommand)" -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\CleanupBuild.ps1 -BuildConfig $(Configuration) "" />
<CallTarget Targets="CodeSignBinaries" Condition=" '$(CodeSign)' == 'true' " />
</Target>
<!-- Do everything possible -->
<Target
Name="Full"
DependsOnTargets="Clean;Build;Test" />
<Target Name="BuildMsBuildTask" DependsOnTargets="RestoreNugetPackages">
<MSBuild Projects="@(LocalBuildTasks)"
Targets="Build"
Properties="Configuration=$(Configuration);Platform=Any CPU" />
</Target>
<Target Name="CodeSignBinaries" DependsOnTargets="RestoreNugetPackages;BuildMsBuildTask">
<PropertyGroup>
<!--public token associated with MSSharedLibKey.snk-->
<StrongNameToken Condition=" '$(StrongNameToken)' == '' ">31bf3856ad364e35</StrongNameToken>
</PropertyGroup>
<GetFrameworkSdkPath>
<Output TaskParameter="Path" PropertyName="WindowsSdkPath"/>
</GetFrameworkSdkPath>
<Copy SourceFiles="$(LibraryRoot)tools\AzureRM.Netcore\AzureRM.Netcore.psd1"
DestinationFolder="$(LibrarySourceFolder)\Package\$(Configuration)" Condition= " '$(NetCore)' == 'true' "/>
<ItemGroup>
<DelaySignedAssembliesToSign Include="$(LibrarySourceFolder)\Package\$(Configuration)\**\Microsoft*Azure*Commands*.dll" Condition="'$(Latest)' == 'true' " />
<DelaySignedAssembliesToSign Include="$(LibrarySourceFolder)\Package\$(Configuration)\**\Microsoft.Azure.Common.Extensions.dll" Condition="'$(Latest)' == 'true' " />
<DelaySignedAssembliesToSign Include="$(LibrarySourceFolder)\Package\$(Configuration)\**\Microsoft.Azure.Management.Sql.Legacy.dll" Condition="'$(Latest)' == 'true' " />
<DelaySignedAssembliesToSign Include="$(LibrarySourceFolder)\Stack\$(Configuration)\**\Microsoft*Azure*Commands*.dll" Condition="'$(Stack)' == 'true' " />
<DelaySignedAssembliesToSign Include="$(LibrarySourceFolder)\Stack\$(Configuration)\**\Microsoft.Azure.Common.Extensions.dll" Condition="'$(Stack)' == 'true' " />
<DelaySignedAssembliesToSign Include="$(LibrarySourceFolder)\Stack\$(Configuration)\**\Microsoft.Azure.Management.Sql.Legacy.dll" Condition="'$(Stack)' == 'true' " />
</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)"
BasePath="$(LibrarySourceFolder)"
Certificates="72, 401"
SigningLogPath="$(LibraryRoot)\signing.log"
ToolsPath="$(CIToolsPath)"
Condition="!$(DelaySign) and '@(DelaySignedAssembliesToSign)' != ''"/>
<ValidateStrongNameSignatureTask
WindowsSdkPath="$(WindowsSdkPath)"
Assembly="%(DelaySignedAssembliesToSign.Identity)"
ExpectedTokenSignature="$(StrongNameToken)"
ExpectedDelaySigned="false"
ContinueOnError="false"
Condition="!$(DelaySign) and '@(DelaySignedAssembliesToSign)' != ''"/>
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\UpdateModules.ps1 $(Configuration) $(Scope) -Profile Latest " " Condition="'$(Latest)' == 'true' and '$(NetCore)' == 'false' "/>
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\UpdateModules.ps1 $(Configuration) $(Scope) -Profile Stack " " Condition="'$(Stack)' == 'true' and '$(NetCore)' == 'false' "/>
<!-- Copying shortcut to be signed -->
<Copy SourceFiles="$(LibraryRoot)tools\AzureRM\AzureRM.psm1"
DestinationFolder="$(LibrarySourceFolder)\Package\$(Configuration)" Condition= " '$(NetCore)' == 'false' and '$(Latest)' == 'true' "/>
<Copy SourceFiles="$(LibrarySourceFolder)\StackAdmin\AzureRM\AzureRM.psm1"
DestinationFolder="$(LibrarySourceFolder)\Stack\$(Configuration)" Condition= " '$(NetCore)' == 'false' and '$(Stack)' == 'true' "/>
<Copy SourceFiles="$(LibrarySourceFolder)\StackAdmin\AzureStack\AzureStack.psm1"
DestinationFolder="$(LibrarySourceFolder)\Stack\$(Configuration)" Condition= " '$(NetCore)' == 'false' and '$(Stack)' == 'true' "/>
<ItemGroup>
<ScriptsToSign Include="$(LibrarySourceFolder)\Package\$(Configuration)\**\*.ps1" Condition="'$(Latest)' == 'true' " />
<ScriptsToSign Include="$(LibrarySourceFolder)\Package\$(Configuration)\**\*.psm1" Condition="'$(Latest)' == 'true' " />
<ScriptsToSign Include="$(LibrarySourceFolder)\Package\$(Configuration)\**\*.ps1xml" Condition="'$(Latest)' == 'true' " />
<ScriptsToSign Include="$(LibrarySourceFolder)\Package\$(Configuration)\**\*.js" Condition="'$(Latest)' == 'true' " />
<ScriptsToSign Include="$(LibrarySourceFolder)\Stack\$(Configuration)\**\*.ps1" Condition="'$(Stack)' == 'true' "/>
<ScriptsToSign Include="$(LibrarySourceFolder)\Stack\$(Configuration)\**\*.psm1" Condition="'$(Stack)' == 'true' " />
<ScriptsToSign Include="$(LibrarySourceFolder)\Stack\$(Configuration)\**\*.ps1xml" Condition="'$(Stack)' == 'true' " />
<ScriptsToSign Include="$(LibrarySourceFolder)\Stack\$(Configuration)\**\*.js" Condition="'$(Stack)' == 'true' " />
</ItemGroup>
<CodeSigningTask
Description="Microsoft Azure PowerShell"
Keywords="Microsoft Azure PowerShell"
UnsignedFiles="@(ScriptsToSign)"
DestinationPath="$(LibrarySourceFolder)"
BasePath="$(LibrarySourceFolder)"
Certificates="400"
SigningLogPath="$(LibraryRoot)\signing-scripts.log"
ToolsPath="$(CIToolsPath)"
Condition="!$(DelaySign) and '@(ScriptsToSign)' != ''"/>
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\CheckSignature.ps1 -CustomPath $(LibrarySourceFolder)\Package\$(Configuration) ""
ContinueOnError="ErrorAndContinue" Condition="'$(NetCore)' == 'false'"/>
<!-- Copying signed shortcut back -->
<Copy SourceFiles="$(LibrarySourceFolder)\Package\$(Configuration)\AzureRM.Netcore.psd1"
DestinationFolder="$(LibraryRoot)tools\AzureRM.NetCore" Condition= " '$(NetCore)' == 'true' "/>
</Target>
<Target Name="BuildInstaller">
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command ". Register-PSRepository -Name MSIcreationrepository -SourceLocation $(PackageDirectory) -InstallationPolicy Trusted " " Condition=" '$(Scope)' == 'all'"/>
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryRoot)\setup\generate.ps1 -repository MSIcreationrepository " " Condition=" '$(Scope)' == 'all'"/>
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command ". Unregister-PSRepository -Name MSIcreationrepository " " Condition=" '$(Scope)' == 'all'"/>
<CallTarget Targets="CodeSignInstaller"
Condition=" '$(CodeSign)' == 'true' and '$(Scope)' == 'all'" />
</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\*.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="$(SignedOutputRootDir)"
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)" />
<SetEnvVar EnvName="SignedMsiDir" EnvValue="$(SignedOutputRootDir)" />
</Target>
<!-- Run Dependecy Analyzer -->
<Target Name="DependencyAnalysis">
<MSBuild
Projects="@(StaticAnalysis)"
Targets="Build"
Properties="Configuration=Debug;Platform=Any CPU"
ContinueOnError="false" />
<Message Importance="high" Text="Running Dependency Analysis..." />
<Exec Command="$(MSBuildProjectDirectory)\src\Package\StaticAnalysis.exe $(MSBuildProjectDirectory)\src\Package\$(Configuration) $(MSBuildProjectDirectory)\src\Package true $(SkipHelp)" Condition="'$(Latest)' == 'true'"/>
<Exec Command="$(MSBuildProjectDirectory)\src\Package\StaticAnalysis.exe $(MSBuildProjectDirectory)\src\Stack\$(Configuration) $(MSBuildProjectDirectory)\src\Stack" Condition="'$(Stack)' == 'true'" ContinueOnError="True"/>
<OnError ExecuteTargets="StaticAnalysisErrorMessage"/>
</Target>
<Target Name="StaticAnalysisErrorMessage">
<Error Text="StaticAnalysis has failed. Please follow the instructions on this doc: https://github.com/Azure/azure-powershell/blob/preview/documentation/Debugging-StaticAnalysis-Errors.md"/>
</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 using Latest profile" Condition="'$(Latest)' == 'true' "/>
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\PublishModules.ps1 $(NetCore) $(Configuration) $(Scope) $(NuGetKey) \"$(NuGetPublishingSource)\" -Profile Latest " $(NuGetCommand)" Condition="'$(Latest)' == 'true' "/>
<Message Importance="high" Text="Publishing Cmdlets using Stack profile" Condition="'$(Stack)' == 'true' "/>
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\PublishModules.ps1 $(NetCore) $(Configuration) $(Scope) $(NuGetKey) \"$(StackPublishingSource)\" -Profile Stack " $(NuGetCommand)" Condition="'$(Stack)' == 'true' " />
<CallTarget Targets="BuildInstaller" />
</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..." />
<!-- Run Pester tests -->
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command "$(MSBuildProjectDirectory)\tools\Modules\Run-UnitTests.ps1""
ContinueOnError="ErrorAndContinue"/>
<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>