forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.proj
658 lines (542 loc) · 34 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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
<?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
'Stack': Azure Stack cmdlets
'Subfolder under src\ResourceManager': An individual cmdlet module
By default, it builds everything
/p:SkipHelp=True
Skips help generation, mainly for local builds to save time.
/p:SkipNugetRestore=True
Skips nuget restore, mainly for local builds to save time when you have already restored nugets.
/p:SkipDependencyAnalysis=True
Skips build validation, mainly for local builds to save time.
/p:QuickBuild=true
Same thing as doing SkipHelp, SkipNugetRestore, and SkipDependencyAnalysis
-->
<!-- Define default build properties -->
<PropertyGroup>
<LibraryRoot>$(MSBuildThisFileDirectory)</LibraryRoot>
<LibrarySourceFolder>$(LibraryRoot)src</LibrarySourceFolder>
<LibraryToolsFolder>$(LibraryRoot)tools</LibraryToolsFolder>
<LocalFeedFolder>$(LibraryToolsFolder)\LocalFeed</LocalFeedFolder>
<PublishDirectory>$(LibrarySourceFolder)\Publish</PublishDirectory>
<Configuration Condition=" '$(Configuration)' != 'Release'">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)' == '' ">$(LibrarySourceFolder)</NuGetPublishingSource>
<Scope Condition="$(Scope) == ''" >All</Scope>
<BuildTasksPath>$(LibraryToolsFolder)\BuildPackagesTask\Microsoft.Azure.Build.Tasks\bin\$(Configuration)</BuildTasksPath>
<PackageDirectory>$(LibrarySourceFolder)\Package</PackageDirectory>
<StackPackageFolder>$(LibrarySourceFolder)\Stack</StackPackageFolder>
<NetCore Condition="'$(NetCore)' != 'true'">false</NetCore>
</PropertyGroup>
<PropertyGroup Condition="$(NetCore) == 'true' ">
<Scope>Netcore</Scope>
</PropertyGroup>
<!-- Set Skips -->
<PropertyGroup>
<SkipHelp Condition =" '$(SkipHelp)' != 'true' ">false</SkipHelp>
<SkipNugetRestore Condition="'$(SkipNugetRestore)' != 'true' ">false</SkipNugetRestore>
<SkipDependencyAnalysis Condition="'$(SkipDependencyAnalysis)' != 'true' ">false</SkipDependencyAnalysis>
</PropertyGroup>
<!-- Skip everything that is not build/test/publish/etc -->
<PropertyGroup Condition="'$(QuickBuild)' == 'true'">
<SkipHelp>true</SkipHelp>
<SkipNugetRestore>true</SkipNugetRestore>
<SkipDependencyAnalysis>true</SkipDependencyAnalysis>
</PropertyGroup>
<ItemGroup>
<LocalBuildTasks Include="$(LibraryToolsFolder)\RepoTasks\RepoTasks.sln" Condition="'$(NetCore)' == 'false'" />
<StackSolution Include="$(LibrarySourceFolder)\StackAdmin\Stack.sln" Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'" />
<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="FilesChangedTask" AssemblyFile="$(BuildTasksPath)\Microsoft.Azure.Build.Tasks.dll" />
<UsingTask TaskName="FilterTask" 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" />
<!-- Clean out the NuGet cache -->
<Exec ContinueOnError="false"
Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command " $Path = Join-Path $env:USERPROFILE .nuget; if (Test-Path $Path) { Remove-Item $Path -Recurse } ""/>
<!-- Clean each project -->
<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)\NuGet.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>
<!-- All PowerShell commands have this prefix -->
<PowerShellCommandPrefix>"$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command</PowerShellCommandPrefix>
<PowerShellCoreCommandPrefix>"$(PowerShellCoreCommand)" -NonInteractive -NoLogo -NoProfile -Command</PowerShellCoreCommandPrefix>
</PropertyGroup>
<!--
Force nuget package restore so that packages that include .targets files
don't need to be checked into source control.
-->
<Target Name="RestoreNugetPackages" Condition="$(SkipNugetRestore) == 'false'">
<Message Importance="high" Text="Restore Nuget packages..." />
<!-- Restore packages -->
<Exec Command="$(NuGetCommand) restore %(StackSolution.FullPath) $(NuGetRestoreConfigSwitch) $(NuGetRestorePackageSetting)"
Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'"
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) $(NuGetRestorePackageSetting)"
ContinueOnError="false" />
<!--Restore the xunit runner needed to run unit tests-->
<Exec Command="$(NuGetCommand) restore $(MSBuildProjectDirectory)\packages.config -PackagesDirectory $(MSBuildProjectDirectory)\packages" />
</Target>
<Target Name="FilterBuild">
<Exec ContinueOnError="false"
Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command " . $(LibraryToolsFolder)\CreateFilterMappings.ps1 ""/>
<!-- Get all of the files changed in the given pull request -->
<FilesChangedTask RepositoryOwner="Azure" RepositoryName="azure-powershell" PullRequestNumber="$(PullRequestNumber)">
<Output TaskParameter="FilesChanged" ItemName="FilesChanged" />
</FilesChangedTask>
<!-- Get the list of modules changed -->
<FilterTask FilesChanged="@(FilesChanged)" MapFilePath=".\ModuleMappings.json">
<Output TaskParameter="Output" ItemName="ModulesChanged"/>
</FilterTask>
<Message Text="Filtering help generation and StaticAnalysis by the following modules:"/>
<Message Text="%(ModulesChanged.Identity)"/>
<Message Text="Total: @(ModulesChanged->Count())"/>
<Message Text=""/>
<!-- Get the list of solutions to build -->
<FilterTask FilesChanged="@(FilesChanged)" MapFilePath=".\SolutionMappings.json">
<Output TaskParameter="Output" ItemName="CmdletSolutionsToBuild"/>
</FilterTask>
<Message Text="Filtering solutions to build by the following:"/>
<Message Text="%(CmdletSolutionsToBuild.Identity)"/>
<Message Text="Total: @(CmdletSolutionsToBuild->Count())"/>
<Message Text=""/>
<!--Get the list of tests to be run based on files changed from a specified PullRequestNumber. Mapping between paths and test DLLs is used to produce the list.-->
<FilterTask FilesChanged="@(FilesChanged)" MapFilePath=".\TestMappings.json">
<Output TaskParameter="Output" ItemName="XUnitTests"/>
</FilterTask>
<Message Text="Using these test assemblies:"/>
<Message Text="%(XUnitTests.Identity)"/>
<Message Text="Total: @(XunitTests->Count())"/>
<Message Text=""/>
<!-- Restore packages -->
<Exec Command="$(NuGetCommand) restore %(CmdletSolutionsToBuild.FullPath) $(NuGetRestoreConfigSwitch) $(NuGetRestorePackageSetting)" ContinueOnError="false" />
</Target>
<!-- Build all flavors of the Cmdlets -->
<Target Name="Build" DependsOnTargets="RestoreNugetPackages;BuildMsBuildTask;FilterBuild">
<Message Importance="high" Text="Building Cmdlets for scope $(Scope)..." />
<!-- Investigate why the ChangeLogCheck target removes the 8080th character -->
<!-- <CallTarget targets="ChangeLogCheck" ContinueOnError="false" /> -->
<MakeDir Directories="$(PackageDirectory)"
Condition="'$(Scope)' != 'Stack'" />
<MakeDir Directories="$(StackPackageFolder)"
Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'" />
<MSBuild Projects="@(CmdletSolutionsToBuild)"
Targets="Build"
Properties="Configuration=$(Configuration);Platform=Any CPU"
BuildInParallel="$(BuildInParallel)"
ContinueOnError="false" />
<MSBuild Projects="@(StackSolution)"
Targets="Build"
Properties="Configuration=$(Configuration);Platform=Any CPU"
BuildInParallel="$(BuildInParallel)"
Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'"
ContinueOnError="false" />
<Exec Command="$(PowerShellCommandPrefix) "$ProgressPreference = 'SilentlyContinue';. $(LibraryToolsFolder)\GenerateHelp.ps1 -ValidateMarkdownHelp -GenerateMamlHelp -BuildConfig $(Configuration) -FilteredModules '@(ModulesChanged)' ""
Condition="'$(SkipHelp)' == 'false'"
ContinueOnError="false"/>
<Exec Command="$(PowerShellCommandPrefix) ". $(LibraryToolsFolder)\UpdateModules.ps1 -BuildConfig $(Configuration) -Scope $(Scope) ""
Condition="'$(CodeSign)' == 'false'"/>
<CallTarget Targets="CodeSignBinaries" Condition="'$(CodeSign)' == 'true'" />
<Exec ContinueOnError="false"
Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command " . $(LibraryToolsFolder)\NewOutputTypeIndex.ps1 -OutputFile $(PackageDirectory)\outputtypes.json -BuildConfig $(Configuration) ""
Condition="('$(Scope)' == 'All' or '$(Scope)' == 'Latest') and $(CodeSign) == 'true'" />
<Message Importance="high" Text="Running Static Analyser" />
<CallTarget targets="DependencyAnalysis" ContinueOnError="ErrorAndContinue" />
<Exec Command="$(PowerShellCommandPrefix) ". $(LibraryToolsFolder)\CheckAssemblies.ps1 -BuildConfig $(Configuration) "" />
<Exec Command="$(PowerShellCommandPrefix) ". $(LibraryToolsFolder)\CleanupBuild.ps1 -BuildConfig $(Configuration) "" />
<Exec ContinueOnError="false"
Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command " . $(LibraryToolsFolder)\NewHelpIndex.ps1 -OutputFile $(PackageDirectory)\index.json -BuildConfig $(Configuration) ""
Condition="('$(Scope)' == 'All' or '$(Scope)' == 'Latest') and $(CodeSign) == 'true'" />
</Target>
<!--
Build .Net Core Cmdlets
Fully self contained
-->
<Target Name="BuildNetCore">
<Message Importance="high" Text="Building Cmdlets..." />
<PropertyGroup>
<Scope>Netcore</Scope>
</PropertyGroup>
<Exec Command="$(PowerShellCoreCommandPrefix) "$ProgressPreference = 'SilentlyContinue';. $(LibraryToolsFolder)\CreateAliasMapping.ps1 ""/>
<!-- 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 folders 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\Az.Resources\Az.Tags.psd1" />
<ExtraPsdFiles Include="$(PackageDirectory)\$(Configuration)\ResourceManager\AzureResourceManager\Az.Websites\Az.Resources.psd1" />
<ExtraPsdFiles Include="$(PackageDirectory)\$(Configuration)\ResourceManager\AzureResourceManager\Az.Websites\Az.Tags.psd1" />
<ExtraPsdFiles Include="$(PackageDirectory)\$(Configuration)\ResourceManager\AzureResourceManager\Az.Network\Az.Resources.psd1" />
<ExtraPsdFiles Include="$(PackageDirectory)\$(Configuration)\ResourceManager\AzureResourceManager\Az.Network\Az.Tags.psd1" />
</ItemGroup>
<Delete Files="@(ExtraPsdFiles->'%(FullPath)')"/>
<!-- Update module manifests. -->
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(LibraryToolsFolder)\UpdateModules.ps1 -BuildConfig $(Configuration) -Scope $(Scope) " "
Condition="'$(CodeSign)' == 'false'"
ContinueOnError="false" />
<!-- Generate the Help -->
<Exec Command="$(PowerShellCoreCommandPrefix) "Set-Variable -Name ProgressPreference -Value 'SilentlyContinue';. $(LibraryToolsFolder)\GenerateHelp.ps1 -ValidateMarkdownHelp -GenerateMamlHelp -BuildConfig $(Configuration) ""
Condition="'$(SkipHelp)' == 'false'"
ContinueOnError="false"/>
<CallTarget Targets="CodeSignBinaries" Condition="'$(CodeSign)' == 'true'" />
<!-- Cleanup extraneous files. -->
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(LibraryToolsFolder)\CleanupBuild.ps1 -BuildConfig $(Configuration) "" />
</Target>
<!-- Do everything possible except Publish -->
<Target Name="Full" DependsOnTargets="Clean;Build;Test" />
<Target Name="BuildMsBuildTask" DependsOnTargets="RestoreNugetPackages">
<Message Importance="high" Text="Building RepoTasks" />
<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>
<!-- Azure -->
<ItemGroup Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Latest' or '$(Scope)' == 'Netcore'">
<DelaySignedAssembliesToSign Include="$(PackageDirectory)\$(Configuration)\**\Microsoft*Azure*Commands*.dll" Exclude="$(PackageDirectory)\$(Configuration)\**\Microsoft*Azure*Commands*Common*.dll" />
<DelaySignedAssembliesToSign Include="$(PackageDirectory)\$(Configuration)\**\Microsoft.Azure.Common.Extensions.dll" />
<DelaySignedAssembliesToSign Include="$(PackageDirectory)\$(Configuration)\**\Microsoft.Azure.Management.Sql.Legacy.dll" />
</ItemGroup>
<!-- Stack -->
<ItemGroup Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'">
<DelaySignedAssembliesToSign Include="$(StackPackageFolder)\$(Configuration)\**\Microsoft*Azure*Commands*.dll" Exclude="$(StackPackageFolder)\$(Configuration)\**\Microsoft*Azure*Commands*Common*.dll" />
<DelaySignedAssembliesToSign Include="$(StackPackageFolder)\$(Configuration)\**\Microsoft.Azure.Management.Storage.dll" />
<DelaySignedAssembliesToSign Include="$(StackPackageFolder)\$(Configuration)\**\Microsoft.Azure.Common.Extensions.dll" />
<DelaySignedAssembliesToSign Include="$(StackPackageFolder)\$(Configuration)\**\Microsoft.Azure.Management.Sql.Legacy.dll" />
</ItemGroup>
<Message Importance="high" Text="$(PackageDirectory)\$(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, 400"
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="$(PowerShellCommandPrefix) ". $(LibraryToolsFolder)\UpdateModules.ps1 -BuildConfig $(Configuration) -Scope $(Scope) ""/>
<!-- Copying shortcut to be signed -->
<Copy SourceFiles="$(LibraryRoot)tools\Az\Az.psm1"
DestinationFolder="$(PackageDirectory)\$(Configuration)" Condition="'$(Scope)' == 'Netcore'" />
<Copy SourceFiles="$(LibraryRoot)tools\AzureRM\AzureRM.psm1"
DestinationFolder="$(PackageDirectory)\$(Configuration)" Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Latest'" />
<Copy SourceFiles="$(LibrarySourceFolder)\StackAdmin\AzureRM\AzureRM.psm1"
DestinationFolder="$(StackPackageFolder)\$(Configuration)" Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'" />
<Copy SourceFiles="$(LibrarySourceFolder)\StackAdmin\AzureStack\AzureStack.psm1"
DestinationFolder="$(StackPackageFolder)\$(Configuration)" Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'" />
<!-- Azure -->
<ItemGroup Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Latest' or '$(Scope)' == 'Netcore'">
<ScriptsToSign Include="$(PackageDirectory)\$(Configuration)\**\*.ps1"/>
<ScriptsToSign Include="$(PackageDirectory)\$(Configuration)\**\*.psm1"/>
<ScriptsToSign Include="$(PackageDirectory)\$(Configuration)\**\*.ps1xml"/>
<ScriptsToSign Include="$(PackageDirectory)\$(Configuration)\**\*.js"/>
</ItemGroup>
<!-- Stack -->
<ItemGroup Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'">
<ScriptsToSign Include="$(StackPackageFolder)\$(Configuration)\**\*.ps1"/>
<ScriptsToSign Include="$(StackPackageFolder)\$(Configuration)\**\*.psm1"/>
<ScriptsToSign Include="$(StackPackageFolder)\$(Configuration)\**\*.ps1xml"/>
<ScriptsToSign Include="$(StackPackageFolder)\$(Configuration)\**\*.js"/>
</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="$(PowerShellCommandPrefix) ". $(LibraryToolsFolder)\CheckSignature.ps1 -CustomPath $(PackageDirectory)\$(Configuration) ""
Condition="'$(Scope)' != 'Stack'"
ContinueOnError="ErrorAndContinue" />
<Exec Command="$(PowerShellCommandPrefix) ". $(LibraryToolsFolder)\CheckSignature.ps1 -CustomPath $(StackPackageFolder)\$(Configuration) ""
Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'"
ContinueOnError="ErrorAndContinue" />
<!-- Copy files back after signing -->
<Copy SourceFiles="$(PackageDirectory)\$(Configuration)\Az.psm1"
DestinationFolder="$(LibraryRoot)tools\Az" Condition="'$(Scope)' == 'Netcore'" />
<Copy SourceFiles="$(PackageDirectory)\$(Configuration)\AzureRM.psm1"
DestinationFolder="$(LibraryRoot)tools\AzureRM" Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Latest'" />
<Copy SourceFiles="$(StackPackageFolder)\$(Configuration)\AzureRM.psm1"
DestinationFolder="$(LibrarySourceFolder)\StackAdmin\AzureRM" Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'" />
<Copy SourceFiles="$(StackPackageFolder)\$(Configuration)\AzureStack.psm1"
DestinationFolder="$(LibrarySourceFolder)\StackAdmin\AzureStack" Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'" />
</Target>
<Target Name="BuildInstaller" Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Latest'">
<Exec Command="$(PowerShellCommandPrefix) ". Register-PSRepository -Name MSIcreationrepository -SourceLocation $(PackageDirectory) -InstallationPolicy Trusted " "/>
<Exec Command="$(PowerShellCommandPrefix) ". $(LibraryRoot)\setup\generate.ps1 -repository MSIcreationrepository " "/>
<Exec Command="$(PowerShellCommandPrefix) ". Unregister-PSRepository -Name MSIcreationrepository " "/>
<CallTarget Targets="CodeSignInstaller" Condition=" '$(CodeSign)' == 'true'" />
</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 contain 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 Validation -->
<Target Name="DependencyAnalysis"
Condition="'$(SkipDependencyAnalysis)' == 'false'">
<MSBuild Projects="@(StaticAnalysis)"
Targets="Build"
Properties="Configuration=Debug;Platform=Any CPU"
ContinueOnError="false" />
<Message Importance="high" Text="Running dependency analysis..." />
<PropertyGroup>
<SkipHelpValue Condition=" '$(SkipHelp)' == 'true' ">-s</SkipHelpValue>
</PropertyGroup>
<Exec Command="$(MSBuildProjectDirectory)\src\Package\StaticAnalysis.exe -p $(MSBuildProjectDirectory)\src\Package\$(Configuration) -r $(MSBuildProjectDirectory)\src\Package $(SkipHelpValue) -m @(ModulesChanged)"
Condition="'$(Scope)' != 'Stack'"/>
<Exec Command="$(PackageDirectory)\StaticAnalysis.exe -p $(StackPackageFolder)\$(Configuration) -r $(StackPackageFolder)"
Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'"
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>
<Target Name="ChangeLogCheck">
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command ". $(LibraryToolsFolder)\CheckChangeLog.ps1 -FilesChanged '@(FilesChanged)' ""
ContinueOnError="false"
Condition=" '$(Scope)' == 'All' or '$(Scope)' == 'Latest' "/>
<OnError ExecuteTargets="ChangeLogErrorMessage"/>
</Target>
<Target Name="ChangeLogErrorMessage">
<Error Text="Modified files were found with no update to their change log. Please add a snippet to the affected modules' change log."/>
</Target>
<!-- Publish all packages -->
<Target Name="Publish">
<Message Importance="high" Text="Publishing Cmdlets using $(Scope) scope"/>
<Error Condition=" '$(NuGetKey)' == '' " Text="You must provide the NuGetKey parameter to the build: /p:NuGetKey=YOUR_PUBLISHING_KEY" />
<Exec Command="$(PowerShellCommandPrefix) ". $(LibraryToolsFolder)\PublishModules.ps1 -IsNetCore:$$(NetCore) -BuildConfig $(Configuration) -Scope $(Scope) -ApiKey $(NuGetKey) -RepositoryLocation \"$(NuGetPublishingSource)\" " -NugetExe $(NuGetCommand)"
Condition="'$(Scope)' != 'Stack'"
ContinueOnError="false"/>
<Exec Command="$(PowerShellCommandPrefix) ". $(LibraryToolsFolder)\PublishModules.ps1 -IsNetCore:$$(NetCore) -BuildConfig $(Configuration) -Scope Stack -ApiKey $(NuGetKey) -RepositoryLocation \"$(NuGetPublishingSource)\" " -NugetExe $(NuGetCommand)"
Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'"
ContinueOnError="false"/>
<CallTarget Targets="BuildInstaller" Condition="'$(Scope)' =='All'" />
</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="BinScopeCheck" Condition="'$(OnPremiseBuild)'" />
<CallTarget Targets="RunPoliCheck" Condition="'$(OnPremiseBuild)'" />
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command "$(MSBuildProjectDirectory)\tools\Modules\Run-UnitTests.ps1 -BuildConfig $(Configuration) -Scope $(Scope) ""
ContinueOnError="ErrorAndContinue"/>
<!-- Azure / Stack -->
<MakeDir Directories="$(TestOutputDirectory)" ContinueOnError="false" />
<MakeDir Directories="$(TestOutputDirectory)/PassingTests" ContinueOnError="false" />
<MakeDir Directories="$(TestOutputDirectory)/FailingTests" ContinueOnError="false" />
<MSBuild Projects="build.proj"
Targets="InvokeXUnit"
Properties="XUnitTests=%(XUnitTests.Identity);TestOutputDirectory=$(TestOutputDirectory)"
Condition="'@(XunitTests->Count())' != '0'"
ContinueOnError="false" />
<CallTarget Targets="TestFailureCheck" />
</Target>
<Target Name="BinScopeCheck">
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command "$(MSBuildProjectDirectory)\tools\CheckBinScope.ps1 -BuildConfig $(Configuration) -CIToolsPath $(CIToolsPath) -Scope $(Scope) ""
ContinueOnError="False"/>
<OnError ExecuteTargets="BinScopeErrorMessage"/>
</Target>
<Target Name="BinScopeErrorMessage">
<Error Text="Binscope failed, please check the files in src/Package/BinScope"/>
</Target>
<Target Name="TestFailureCheck">
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command "if ((Get-ChildItem $(TestOutputDirectory)/FailingTests).Count -ge 1) { throw "Failing tests, please check files in src/TestResults/FailingTests" } ""
ContinueOnError="False"/>
<OnError ExecuteTargets="TestFailureErrorMessage"/>
</Target>
<Target Name="TestFailureErrorMessage">
<Error Text="Test failures occured, check the files in src/Publish/TestResults/FailingTests."/>
</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>
<Target Name="RunPoliCheck">
<Exec Command=""$(PowerShellCommand)" -NonInteractive -NoLogo -NoProfile -Command "$(MSBuildProjectDirectory)\tools\CheckPoliCheck.ps1 -BuildConfig $(Configuration) -CIToolsPath $(CIToolsPath) ""
ContinueOnError="False"/>
<OnError ExecuteTargets="PoliCheckErrorMessage"/>
</Target>
<Target Name="PoliCheckErrorMessage">
<Error Text="PoliCheck failed with a Severity 1 issue, please check the report at in src/Package/PoliCheck-Scan.html"/>
</Target>
</Project>