forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.proj
401 lines (327 loc) · 25 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
<?xml version="1.0" encoding="utf-8"?>
<!--
# Targets
/t:Clean
Removes temporary build outputs.
/t:Build
Builds assemblies.
/t:Test
Runs tests
/t:Publish
Creates local nuget packages and MSI
# Properties
/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
'Subfolder under src': An individual cmdlet module
By default, it builds everything
/p:TargetModule
Just focus on one module and its dependency such as Az.Account. Module name doesn't need to lead with Az.
/p:SkipHelp=True
Skips help generation, mainly for local builds to save time.
-->
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)Repo.props" />
<PropertyGroup>
<!-- General -->
<Configuration Condition="'$(Configuration)' != 'Release'">Debug</Configuration>
<Scope Condition="$(Scope) == ''">All</Scope>
<TestFramework Condition="'$(TestFramework)' == ''">netcoreapp2.2</TestFramework>
<IsGenerateBased Condition="'$(IsGenerateBased)' != 'true'">false</IsGenerateBased>
<IsSecurityCheck Condition="'$(IsSecurityCheck)' != 'true'">false</IsSecurityCheck>
<!-- Flags -->
<CodeSign Condition ="'$(CodeSign)' == ''">false</CodeSign>
<SkipHelp Condition ="'$(SkipHelp)' != 'true'">false</SkipHelp>
<!-- Set this true only if you want to test the CodeSign workflow locally -->
<DelaySign Condition ="'$(DelaySign)' == ''">false</DelaySign>
<NetCore Condition="'$(NetCore)' != 'false'">true</NetCore>
<RunStaticAnalysis Condition="'$(RunStaticAnalysis)' != 'false'">true</RunStaticAnalysis>
<!-- Folders -->
<SignedOutputRootDir>$(RepoRoot)signed</SignedOutputRootDir>
<TestOutputDirectory>$(RepoArtifacts)/TestResults</TestOutputDirectory>
<StaticAnalysisOutputDirectory>$(RepoArtifacts)/StaticAnalysisResults</StaticAnalysisOutputDirectory>
<NuGetPublishingSource Condition="'$(NuGetPublishingSource)' == ''">$(RepoSrc)</NuGetPublishingSource>
<!-- Misc -->
<NuGetCommand>$(MSBuildProjectDirectory)/tools/NuGet.exe</NuGetCommand>
<Scope Condition="$(NetCore) == 'true'">Netcore</Scope>
<!-- PS command related -->
<PowerShellCoreCommandPrefix>pwsh -NonInteractive -NoLogo -NoProfile -Command</PowerShellCoreCommandPrefix>
<!-- Testing related -->
<TestsToRun Condition="$(TestsToRun) == ''" >All</TestsToRun>
<CoreTests Condition="'$(TestsToRun)' != 'All'">$(RepoRoot)src/Compute/Compute.Test/Compute.Test.csproj;$(RepoRoot)src/Network/Network.Test/Network.Test.csproj;$(RepoRoot)src/Resources/Resources.Test/Resources.Test.csproj;$(RepoRoot)src/Sql/Sql.Test/Sql.Test.csproj;$(RepoRoot)src/Websites/Websites.Test/Websites.Test.csproj;</CoreTests>
<Net472TestExclude Condition="'$(TestFramework)' == 'net472'">$(RepoRoot)src/**/Automation.Test.csproj;$(RepoRoot)src/**/Storage.Test.csproj;</Net472TestExclude>
<!-- CI build related -->
<CIToolsPath>$(OnPremiseBuildTasks)</CIToolsPath>
<OnPremiseBuild Condition="Exists($(OnPremiseBuildTasks))">true</OnPremiseBuild>
<OnPremiseBuild Condition="!Exists($(OnPremiseBuildTasks))">false</OnPremiseBuild>
<!-- CISignRepo is an environment variable that points to ci-signing repo clone -->
<CISignRepoPath>$(CISignRepo)</CISignRepoPath>
<!-- Docker related -->
<DockerRoot>$(RepoRoot)docker</DockerRoot>
<DockerTools>$(RepoTools)Docker</DockerTools>
<DockerImageName Condition="'$(DockerImageName)' == ''">azure-powershell</DockerImageName>
</PropertyGroup>
<!-- Tasks -->
<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>
<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 TaskName="ESRPSignTask" AssemblyFile="$(CISignRepoPath)/tools/sdkbuildtools/tasks/MS.Az.Sdk.OnPremise.Build.Tasks.dll" />
<UsingTask TaskName="FilesChangedTask" AssemblyFile="$(RepoArtifacts)Microsoft.Azure.Build.Tasks/Microsoft.Azure.Build.Tasks.dll" />
<UsingTask TaskName="CIFilterTask" AssemblyFile="$(RepoArtifacts)Microsoft.Azure.Build.Tasks/Microsoft.Azure.Build.Tasks.dll" />
<Target Name="Clean">
<Message Importance="high" Text="Cleaning Cmdlets..." />
<!-- Clean out the NuGet cache -->
<Exec Command="dotnet nuget locals global-packages --clear" ContinueOnError="WarnAndContinue" IgnoreExitCode="true" />
<!-- Remove Package, Publish, bin, obj, and TestResults directories -->
<Exec Command="$(PowerShellCoreCommandPrefix) "Remove-Item -Path $(RepoArtifacts) -Recurse -Force -ErrorAction Ignore"" IgnoreExitCode="true" />
<Exec Command="$(PowerShellCoreCommandPrefix) "Get-ChildItem -Path $(MSBuildThisFileDirectory) -Recurse -Include 'bin','obj','TestResults' | Remove-Item -Recurse -Force -ErrorAction Ignore"" IgnoreExitCode="true" />
</Target>
<Target Name="BuildTools">
<Exec Command="dotnet publish $(RepoTools)StaticAnalysis/StaticAnalysis.Netcore.csproj -c $(Configuration)" />
</Target>
<Target Name="FilterBuild" Condition="$(PullRequestNumber) != '' OR $(TargetModule) != ''" DependsOnTargets="BuildTools">
<Message Importance="high" Text="Filtering projects and modules..." />
<Message Text="$(IsGenerateBased)" />
<!-- Build the Microsoft.Azure.Build.Tasks project -->
<Exec Command="dotnet publish $(RepoTools)BuildPackagesTask/Microsoft.Azure.Build.Tasks/Microsoft.Azure.Build.Tasks.csproj -c $(Configuration)" />
<!-- Get all of the files changed in the given pull request -->
<FilesChangedTask RepositoryOwner="Azure" RepositoryName="azure-powershell" PullRequestNumber="$(PullRequestNumber)" TargetModule="$(TargetModule)">
<Output TaskParameter="FilesChanged" ItemName="FilesChanged" />
</FilesChangedTask>
<Exec Command="$(PowerShellCoreCommandPrefix) "$(RepoTools)PrepareAutorestModule.ps1"" Condition="'$(IsGenerateBased)' == 'true'"/>
<Exec Command="$(PowerShellCoreCommandPrefix) "$(RepoTools)/CreateFilterMappings.ps1"" />
<Exec Command="$(PowerShellCoreCommandPrefix) "$(RepoTools)/PrepareForSecurityCheck.ps1"" Condition="'$(IsSecurityCheck)' == 'true'"/>
<CIFilterTask FilesChanged="@(FilesChanged)" TargetModule="$(TargetModule)" Mode="$(Configuration)" CsprojMapFilePath="./CsprojMappings.json">
<Output TaskParameter="FilterTaskResult" ItemName="FilterTaskResult" />
</CIFilterTask>
<CreateProperty
Value="%(FilterTaskResult.build)">
<Output
TaskParameter="Value"
PropertyName="BuildCsprojList" />
</CreateProperty>
<CreateProperty
Value="%(FilterTaskResult.test)">
<Output
TaskParameter="Value"
PropertyName="TestCsprojList" />
</CreateProperty>
<CreateProperty
Value="%(FilterTaskResult.sub-task)">
<Output
TaskParameter="Value"
PropertyName="SubTasks" />
</CreateProperty>
</Target>
<!-- Build all flavors of the Cmdlets -->
<Target Name="Build" DependsOnTargets="FilterBuild">
<Message Importance="high" Text="Building Cmdlets..." />
<MakeDir Directories="$(RepoArtifacts)" />
<!-- Copy appropriate targets -->
<Copy SourceFiles="$(RepoTools)after.Azure.PowerShell.sln.targets" DestinationFolder="$(RepoArtifacts)" />
<!-- Build and create package content -->
<Exec Command="dotnet --version" />
<Exec Command="dotnet new sln -n Azure.PowerShell -o $(RepoArtifacts) --force" />
<CallTarget Targets="BuildNormalModules" />
<CallTarget Targets="AzToolsPredictor" Condition="$(SubTasks.Contains('predictor'))" />
<CallTarget Targets="AzToolsInstaller" Condition="$(SubTasks.Contains('installer'))" />
</Target>
<Target Name="BuildNormalModules">
<ItemGroup Condition="$(PullRequestNumber) == '' AND $(TargetModule) == ''">
<CsprojFiles Include="$(RepoRoot)src/**/*.csproj" Exclude="$(RepoRoot)src/**/*.Test.csproj;$(RepoRoot)src/**/Authenticators.csproj" />
<CsprojFiles Include="$(RepoRoot)src/**/*.Test.csproj" Exclude="$(Net472TestExclude)" Condition="'$(Configuration)' != 'Release' and '$(TestsToRun)' == 'All'" />
<CsprojFiles Include="$(RepoRoot)src/**/*.Test.csproj" Exclude="$(CoreTests)$(Net472TestExclude)" Condition="'$(Configuration)' != 'Release' and '$(TestsToRun)' == 'NonCore'" />
<CsprojFiles Include="$(CoreTests)" Exclude="$(Net472TestExclude)" Condition="'$(Configuration)' != 'Release' and '$(TestsToRun)' == 'Core'" />
<CsprojFiles Include="$(RepoRoot)src/**/Authenticators.csproj" Condition="'$([MSBuild]::IsOsPlatform("Windows"))' == 'true' and '$(TestFramework)' != 'net472'" />
</ItemGroup>
<ItemGroup Condition="$(PullRequestNumber) != ''">
<!-- Always build and test common code -->
<CsprojFiles Include="$(BuildCsprojList.Split(`;`))" />
<CsprojFiles Include="$(TestCsprojList.Split(`;`))" />
</ItemGroup>
<ItemGroup Condition="$(TargetModule) != ''">
<!-- Add test projects only if Configuration is not Release -->
<CsprojFiles Include="$(BuildCsprojList.Split(`;`))" />
<CsprojFiles Include="$(TestCsprojList.Split(`;`))" Condition="'$(Configuration)' != 'Release'" />
</ItemGroup>
<!-- https://github.com/dotnet/cli/issues/6295#issuecomment-346973582 -->
<Exec Command="dotnet sln $(RepoArtifacts)Azure.PowerShell.sln add "%(CsprojFiles.FullPath)""/>
<PropertyGroup>
<BuildAction Condition="'$(Configuration)' != 'Release'">build</BuildAction>
<BuildAction Condition="'$(Configuration)' == 'Release'">publish</BuildAction>
</PropertyGroup>
<Exec Command="dotnet $(BuildAction) $(RepoArtifacts)Azure.PowerShell.sln -c $(Configuration)" />
<!-- Build version controller -->
<Exec Command="dotnet build $(RepoTools)VersionController/VersionController.Netcore.csproj -c $(Configuration)" />
<!-- Delete powershell runtime files -->
<PropertyGroup>
<RuntimeDllsIncludeList>Microsoft.Powershell.*.dll,System*.dll,Microsoft.VisualBasic.dll,Microsoft.CSharp.dll,Microsoft.CodeAnalysis.dll,Microsoft.CodeAnalysis.CSharp.dll</RuntimeDllsIncludeList>
<RuntimeDllsExcludeList>System.Security.Cryptography.ProtectedData.dll,System.Configuration.ConfigurationManager.dll,System.Runtime.CompilerServices.Unsafe.dll,System.IO.FileSystem.AccessControl.dll,System.Buffers.dll,System.Text.Encodings.Web.dll,System.CodeDom.dll,System.Management.dll,System.Text.Json.dll,System.Threading.Tasks.Extensions.dll</RuntimeDllsExcludeList>
</PropertyGroup>
<Exec Command="$(PowerShellCoreCommandPrefix) "Get-ChildItem -Path $(RepoArtifacts)/$(Configuration) -Recurse -Include $(RuntimeDllsIncludeList) -Exclude $(RuntimeDllsExcludeList) | Where-Object {$_.FullName -notlike '*PreloadAssemblies*' -and $_.FullName -notlike '*NetCoreAssemblies*'} | Remove-Item -Force""/>
<Exec Command="$(PowerShellCoreCommandPrefix) "Get-ChildItem -Path $(RepoArtifacts)/$(Configuration) -Recurse -Include 'runtimes' | Remove-Item -Recurse -Force"" Condition="'$(CodeSign)' == 'true'" />
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(RepoTools)/UpdateModules.ps1 -BuildConfig $(Configuration) -Scope $(Scope)""/>
</Target>
<Target Name="OnPremChecks" Condition="'$(OnPremiseBuild)'">
<Exec Command="$(PowerShellCoreCommandPrefix) "$(RepoTools)CheckBinScope.ps1 -BuildConfig $(Configuration) -CIToolsPath $(CIToolsPath)"" />
<Exec Command="$(PowerShellCoreCommandPrefix) "$(RepoTools)CheckPoliCheck.ps1 -BuildConfig $(Configuration) -CIToolsPath $(CIToolsPath)"" />
<Exec Command="$(PowerShellCoreCommandPrefix) "$(RepoTools)CheckCredScan.ps1 -CIToolsPath $(CIToolsPath) -PullRequestNumber $(PullRequestNumber)"" />
<OnError ExecuteTargets="OnPremChecksErrorMessage" />
</Target>
<Target Name="OnPremChecksErrorMessage">
<Error Text="BinScope or PoliCheck failed. Please check the files in artifacts/BinScope, or Severity 1 issues in artifacts/PoliCheck-Scan.html" />
</Target>
<Target Name="GenerateHelp" Condition="'$(SkipHelp)' == 'false'">
<Message Importance="high" Text="Running help generation..." />
<MakeDir Directories="$(StaticAnalysisOutputDirectory)" />
<Exec Command="$(PowerShellCoreCommandPrefix) "Set-Variable -Name ProgressPreference -Value 'SilentlyContinue';. $(RepoTools)/GenerateHelp.ps1 -ValidateMarkdownHelp -GenerateMamlHelp -BuildConfig $(Configuration)"" />
<Exec Command="dotnet $(RepoArtifacts)StaticAnalysis/StaticAnalysis.Netcore.dll -p $(RepoArtifacts)$(Configuration) -r $(StaticAnalysisOutputDirectory) --analyzers help -h -u -m '@(ModulesChanged)'" Condition="'$(RunStaticAnalysis)' == 'true'" />
</Target>
<!-- Everything except Publish -->
<Target Name="Full" DependsOnTargets="Clean;Build;OnPremChecks;GenerateHelp;StaticAnalysis;Test" />
<Target Name="StaticAnalysisBreakingChange" Condition="'$(RunStaticAnalysis)' == 'true'" DependsOnTargets="Build">
<Message Importance="high" Text="Running static analysis for breaking change..." />
<MakeDir Directories="$(StaticAnalysisOutputDirectory)" />
<Exec Command="dotnet $(RepoArtifacts)StaticAnalysis/StaticAnalysis.Netcore.dll -p $(RepoArtifacts)$(Configuration) -r $(StaticAnalysisOutputDirectory) --analyzers breaking-change -u -m '%(FilterTaskResult.breaking-change)'" />
</Target>
<Target Name="StaticAnalysisDependency" Condition="'$(RunStaticAnalysis)' == 'true'" DependsOnTargets="Build">
<Message Importance="high" Text="Running static analysis for dependency..." />
<MakeDir Directories="$(StaticAnalysisOutputDirectory)" />
<Exec Command="dotnet $(RepoArtifacts)StaticAnalysis/StaticAnalysis.Netcore.dll -p $(RepoArtifacts)$(Configuration) -r $(StaticAnalysisOutputDirectory) --analyzers dependency -u -m '%(FilterTaskResult.breaking-change)'" />
</Target>
<Target Name="StaticAnalysisSignature" Condition="'$(RunStaticAnalysis)' == 'true'" DependsOnTargets="Build">
<Message Importance="high" Text="Running static analysis for signature..." />
<MakeDir Directories="$(StaticAnalysisOutputDirectory)" />
<Exec Command="dotnet $(RepoArtifacts)StaticAnalysis/StaticAnalysis.Netcore.dll -p $(RepoArtifacts)$(Configuration) -r $(StaticAnalysisOutputDirectory) --analyzers signature -u -m '%(FilterTaskResult.signature)'" />
</Target>
<Target Name="StaticAnalysisHelp" Condition="'$(RunStaticAnalysis)' == 'true'" DependsOnTargets="Build">
<Message Importance="high" Text="Running static analysis for help..." />
<MakeDir Directories="$(StaticAnalysisOutputDirectory)" />
<Exec Command="dotnet $(RepoArtifacts)StaticAnalysis/StaticAnalysis.Netcore.dll -p $(RepoArtifacts)$(Configuration) -r $(StaticAnalysisOutputDirectory) --analyzers help -u -m '%(FilterTaskResult.help)'" />
</Target>
<Target Name="StaticAnalysis" DependsOnTargets="StaticAnalysisBreakingChange;StaticAnalysisDependency;StaticAnalysisSignature;StaticAnalysisHelp">
<Message Importance="high" Text="Running static analysis..." />
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(RepoTools)/CheckAssemblies.ps1 -BuildConfig $(Configuration) "" />
<Exec Command="dotnet $(RepoArtifacts)StaticAnalysis/StaticAnalysis.Netcore.dll -p $(RepoArtifacts)$(Configuration) -r $(StaticAnalysisOutputDirectory) --analyzers check-error" />
<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/master/documentation/Debugging-StaticAnalysis-Errors.md" />
</Target>
<Target Name="ChangeLogCheck">
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(RepoTools)/CheckChangeLog.ps1 -FilesChanged '@(FilesChanged)'"" Condition=" '$(Scope)' == 'All' or '$(Scope)' == 'Latest' " />
<OnError ExecuteTargets="ChangeLogErrorMessage" />
</Target>
<Target Name="AzToolsInstaller">
<Exec Command='dotnet msbuild $(RepoTools)/Az.Tools.Installer/build.proj /t:"clean;build;test"' />
</Target>
<Target Name="AzToolsPredictor">
<Exec Command='dotnet msbuild $(RepoTools)/Az.Tools.Predictor/build.proj /t:"clean;build;test"' />
</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>
<Target Name="Publish" Condition="'$(Configuration)' == 'Release'">
<Message Importance="high" Text="Publishing Cmdlets using $(Scope) scope" />
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(RepoTools)/NewOutputTypeIndex.ps1 -OutputFile $(RepoArtifacts)/outputtypes.json -BuildConfig $(Configuration)"" Condition="'$(TargetModule)' == ''"/>
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(RepoTools)/NewHelpIndex.ps1 -OutputFile $(RepoArtifacts)/index.json -BuildConfig $(Configuration)"" Condition="'$(TargetModule)' == ''"/>
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(RepoTools)/CleanupBuild.ps1 -BuildConfig $(Configuration)"" />
<Error Condition="'$(NuGetKey)' == ''" Text="You must provide the NuGetKey parameter to the build: /p:NuGetKey=YOUR_PUBLISHING_KEY" />
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(RepoTools)/PublishModules.ps1 -IsNetCore:$$(NetCore) -BuildConfig $(Configuration) -Scope $(Scope) -ApiKey $(NuGetKey) -RepositoryLocation \"$(NuGetPublishingSource)\"" -NugetExe $(NuGetCommand)" />
</Target>
<Target Name="BuildInstaller" AfterTargets="Publish" Condition="('$(Scope)' == 'All' or '$(Scope)' == 'Latest' or '$(Scope)' == 'Netcore') and '$(TargetModule)' == ''">
<Exec Command="$(PowerShellCoreCommandPrefix) ". Register-PSRepository -Name MSIcreationrepository -SourceLocation $(RepoArtifacts) -InstallationPolicy Trusted "" />
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(RepoRoot)/setup/generate.ps1 -repository MSIcreationrepository "" />
<Exec Command="$(PowerShellCoreCommandPrefix) ". Unregister-PSRepository -Name MSIcreationrepository "" />
</Target>
<Target Name="BuildImages">
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(DockerTools)/GetArtifacts.ps1 -Artifacts $(RepoArtifacts) -Docker $(DockerRoot) "" />
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(DockerTools)/BuildImages.ps1 -DOCKER $(DockerRoot) -DockerImageName $(DockerImageName) "" />
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(DockerTools)/CleanArtifacts.ps1 -Docker $(DockerRoot) "" />
</Target>
<Target Name="Test" DependsOnTargets="FilterBuild">
<Message Importance="high" Text="Running check in tests..." />
<MakeDir Directories="$(TestOutputDirectory)" ContinueOnError="false" />
<!-- https://github.com/Microsoft/msbuild/issues/3157#issuecomment-378002971 -->
<!-- https://github.com/xunit/xunit/issues/1154#issuecomment-405366373 -->
<Exec Command="dotnet test $(RepoArtifacts)Azure.PowerShell.sln --filter "AcceptanceType=CheckIn%26RunType!=DesktopOnly" --configuration $(Configuration) --framework $(TestFramework) --logger trx --results-directory "$(TestOutputDirectory)"" Condition="'$(TestCsprojList)' != ''" />
<Message Importance="high" Text="Finish running tests..." />
<OnError ExecuteTargets="TestFailureErrorMessage" />
</Target>
<Target Name="TestNet472" Condition="'$(TestFramework)' == 'net472'">
<PropertyGroup>
<PowerShellCommandPrefix>powershell -NonInteractive -NoLogo -NoProfile -Command</PowerShellCommandPrefix>
</PropertyGroup>
<Message Importance="high" Text="Running check in tests..." />
<MakeDir Directories="$(TestOutputDirectory)" ContinueOnError="false" />
<Exec Command="dotnet build $(RepoArtifacts)Azure.PowerShell.sln -c $(Configuration)" />
<Exec Command="dotnet new console -n Net472Tests" />
<Exec Command="dotnet add Net472Tests package xunit.runner.console --version 2.4.0" />
<Exec Command="dotnet restore --packages $(RepoArtifacts)/xUnit -f --no-cache Net472Tests" />
<Exec Command="$(PowerShellCommandPrefix) "$(RepoTools)/TestNet472Modules.ps1 -TestExecPath '$(RepoArtifacts)/xUnit/xunit.runner.console/2.4.0/tools/net472/xunit.console.exe'"" />
<OnError ExecuteTargets="TestFailureErrorMessage" />
</Target>
<Target Name="TestFailureErrorMessage">
<Error Text="Test failures occurred, check the files in artifacts/TestResults" />
</Target>
<Target Name="CodeSignBinaries" AfterTargets="Build" Condition="'$(CodeSign)' == 'true'">
<Message Text="====> Executing CodeSignBinaries Target..." Importance="high" />
<Message Text="variables.Dlls signing section" Importance="high" />
<!-- Azure -->
<ItemGroup Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Latest' or '$(Scope)' == 'Netcore'">
<DelaySignedAssembliesToSign Include="
$(RepoArtifacts)/$(Configuration)/**/Microsoft*Azure*PowerShell*Cmdlets*.dll;
$(RepoArtifacts)/$(Configuration)/**/Microsoft.Azure.PowerShell.Authentication.dll;
$(RepoArtifacts)/$(Configuration)/**/Microsoft.Azure.PowerShell.Authentication.ResourceManager.dll;
$(RepoArtifacts)/$(Configuration)/**/Microsoft.Azure.PowerShell.Authenticators.dll" Exclude="$(RepoArtifacts)/$(Configuration)/**/Microsoft*Azure*PowerShell*Cmdlets*.Test.dll" />
</ItemGroup>
<Message Importance="high" Text="$(RepoArtifacts)/$(Configuration) does not contains any files to sign. Code sign will skip." Condition="'@(DelaySignedAssembliesToSign)' == ''" />
<ESRPSignTask CopyBackSignedFilesToOriginalLocation="true" UnsignedFileList="@(DelaySignedAssembliesToSign)" SignLogDirPath="$(RepoRoot)dlls-signing.log" Condition="!$(DelaySign) and '@(DelaySignedAssembliesToSign)' != ''" />
<!-- Copying shortcut to be signed -->
<Copy SourceFiles="$(RepoRoot)tools/Az/Az.psm1" DestinationFolder="$(RepoArtifacts)/$(Configuration)" Condition="'$(Scope)' == 'Netcore'" />
<Message Text="variables.Scripts signing section" Importance="high" />
<!-- Azure -->
<ItemGroup Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Latest' or '$(Scope)' == 'Netcore'">
<ScriptsToSign Include="$(RepoArtifacts)/$(Configuration)/**/*.ps1" />
<ScriptsToSign Include="$(RepoArtifacts)/$(Configuration)/**/*.psm1" />
<ScriptsToSign Include="$(RepoArtifacts)/$(Configuration)/**/*.ps1xml" />
<ScriptsToSign Include="$(RepoArtifacts)/$(Configuration)/**/*.js" />
</ItemGroup>
<ESRPSignTask CopyBackSignedFilesToOriginalLocation="true" UnsignedFileList="@(ScriptsToSign)" SignLogDirPath="$(RepoRoot)scripts-signing.log" Condition="!$(DelaySign) and '@(ScriptsToSign)' != ''" />
<!-- RemoveCodeSignArtifacts.ps1 -->
<Message Text="variables.Remove artifacts section" Importance="high" />
<Exec Command="$(PowerShellCoreCommandPrefix) "Get-ChildItem -Path $(RepoArtifacts) -Recurse -Include 'Signed','Unsigned' | Remove-Item -Recurse -Force -Confirm:$false -ErrorAction Ignore"" IgnoreExitCode="true" />
<!-- CheckSignature.ps1 -->
<Message Text="variables.CheckSignature section" Importance="high" />
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(RepoTools)/CheckSignature.ps1 -CustomPath $(RepoArtifacts)/$(Configuration)"" Condition="'$(Scope)' != 'Stack'" />
<!-- Copy files back after signing -->
<Copy SourceFiles="$(RepoArtifacts)/$(Configuration)/Az.psm1" DestinationFolder="$(RepoRoot)tools/Az" Condition="'$(Scope)' == 'Netcore'" />
</Target>
<Target Name="CodeSignInstaller" AfterTargets="BuildInstaller" Condition="'$(CodeSign)' == 'true'">
<Message Text="variables.CodeSignInstaller section" Importance="high" />
<GetFrameworkSdkPath>
<Output TaskParameter="Path" PropertyName="WindowsSdkPath" />
</GetFrameworkSdkPath>
<ItemGroup>
<InstallersToSign Include="$(RepoRoot)/setup/*.msi" />
</ItemGroup>
<Message Importance="high" Text="$(RepoRoot)/setup does not contain any installers to sign. Code sign will skip." Condition="'@(InstallersToSign)' == ''" />
<ESRPSignTask SignedFilesRootDirPath="$(SignedOutputRootDir)" UnsignedFileList="@(InstallersToSign)" SignLogDirPath="$(RepoRoot)/msi-signing.log" 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>
</Project>