forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.proj
424 lines (341 loc) · 23.6 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
<?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>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" />
<StaticAnalysisNetcore Include=".\tools\StaticAnalysis\StaticAnalysisNetcore.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="CorporateValidation" AssemblyFile="$(CIToolsPath)\Microsoft.WindowsAzure.Tools.Build.Tasks.OnPremise.dll" />
<Import Condition=" $(OnPremiseBuild) " Project="$(CIToolsPath)\Microsoft.WindowsAzure.Build.OnPremise.msbuild" />
<Import Project="CodeSign.targets"/>
<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..." />
<!-- Clean out the NuGet cache -->
<Exec Command="$(PowerShellCoreCommandPrefix) "Remove-Item -Path (Join-Path ($env:USERPROFILE) .nuget packages) -Recurse -Force -Confirm:$false -ErrorAction Ignore"" ContinueOnError="WarnAndContinue" IgnoreExitCode="true" />
<!-- Remove Package, Publish, bin, obj, and TestResults directories -->
<Exec Command="$(PowerShellCoreCommandPrefix) "Remove-Item -Path $(PackageDirectory),$(PublishDirectory) -Recurse -Force -Confirm:$false -ErrorAction Ignore"" ContinueOnError="WarnAndContinue" IgnoreExitCode="true" />
<Exec Command="$(PowerShellCoreCommandPrefix) "Get-ChildItem -Path $(MSBuildThisFileDirectory) -Recurse -Include 'bin','obj','TestResults' | Remove-Item -Recurse -Force -Confirm:$false -ErrorAction Ignore"" ContinueOnError="WarnAndContinue" IgnoreExitCode="true" />
</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 for local build tasks-->
<Exec Command="$(NuGetCommand) restore %(LocalBuildTasks.FullPath) $(NuGetRestoreConfigSwitch) $(NuGetRestorePackageSetting)" ContinueOnError="false" />
</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 -->
<!-- TODO: Reimplement the FilterBuild and update RepoTasks to NetStandard -->
<!-- <Target Name="Build" DependsOnTargets="RestoreNugetPackages;BuildMsBuildTask;FilterBuild"> -->
<Target Name="Build">
<Message Importance="high" Text="Building Cmdlets..." />
<PropertyGroup>
<Scope>Netcore</Scope>
</PropertyGroup>
<MakeDir Directories="$(PackageDirectory)" Condition="'$(Scope)' != 'Stack'" />
<!-- Investigate why the ChangeLogCheck target removes the 8080th character -->
<!-- <CallTarget targets="ChangeLogCheck" ContinueOnError="false" /> -->
<!-- Build and create package content -->
<Exec Command="dotnet --version" />
<Exec Command="dotnet new sln -n Azure.PowerShell --force" />
<ItemGroup>
<ModuleCsprojFiles Include="$(LibraryRoot)src/ResourceManager/**/*.csproj" Exclude="$(LibraryRoot)src/ResourceManager/**/*.Test.Netcore.csproj" />
</ItemGroup>
<Exec Command="dotnet sln Azure.PowerShell.sln add @(ModuleCsprojFiles->'%(FullPath)', ' ')" />
<Exec Command="dotnet sln Azure.PowerShell.sln add $(LibraryRoot)tools/Tools.Common/Tools.Common.Netcore.csproj $(LibraryRoot)tools/StaticAnalysis/StaticAnalysis.Netcore.csproj" />
<Exec Command="dotnet publish Azure.PowerShell.sln -c $(Configuration)" />
<!-- TODO: <REMOVE THIS SECTION> -->
<!-- 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)')" />
<!-- TODO: </REMOVE THIS SECTION> -->
<!-- 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' And '$(RunStaticAnalysis)' == 'true'" ContinueOnError="false" />
<Exec ContinueOnError="false"
Command="$(PowerShellCoreCommandPrefix) ". $(LibraryToolsFolder)\NewOutputTypeIndex.ps1 -OutputFile $(PackageDirectory)\outputtypes.json -BuildConfig $(Configuration) ""
Condition="'$(CodeSign)' == 'true'"/>
<CallTarget targets="DependencyAnalysisNetcore" ContinueOnError="ErrorAndContinue" Condition="'$(RunStaticAnalysis)' == 'true'" />
<Exec Command="$(PowerShellCommandPrefix) ". $(LibraryToolsFolder)\CheckAssemblies.ps1 -BuildConfig $(Configuration) "" Condition="'$(RunStaticAnalysis)' == 'true'" />
<!-- Cleanup extraneous files. -->
<Exec Command="$(PowerShellCoreCommandPrefix) ". $(LibraryToolsFolder)\CleanupBuild.ps1 -BuildConfig $(Configuration)"" />
<Exec ContinueOnError="false"
Command="$(PowerShellCoreCommandPrefix) " . $(LibraryToolsFolder)\NewHelpIndex.ps1 -OutputFile $(PackageDirectory)\index.json -BuildConfig $(Configuration) ""
Condition="'$(CodeSign)' == 'true'"/>
<CallTarget Targets="BinScopeCheck" Condition="'$(OnPremiseBuild)'" />
<CallTarget Targets="RunPoliCheck" Condition="'$(OnPremiseBuild)'" />
<CallTarget Targets="CodeSignBinaries" Condition="'$(CodeSign)' == 'true'" />
<Exec ContinueOnError="false" Command="$(PowerShellCoreCommandPrefix) ". $(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" />
<!-- TODO: Implement CheckAssemblies.ps1 for Az. -->
<!-- <Exec Command="$(PowerShellCoreCommandPrefix) ". $(LibraryToolsFolder)\CheckAssemblies.ps1 -BuildConfig $(Configuration) "" /> -->
<Exec ContinueOnError="false" Command="$(PowerShellCoreCommandPrefix) ". $(LibraryToolsFolder)\NewHelpIndex.ps1 -OutputFile $(PackageDirectory)\index.json -BuildConfig $(Configuration)"" Condition="('$(Scope)' == 'All' or '$(Scope)' == 'Latest') and $(CodeSign) == 'true'" />
</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="BuildInstaller" Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Latest' or '$(Scope)' == 'Netcore'">
<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>
<!-- Run Validation -->
<Target Name="DependencyAnalysis" Condition="'$(SkipDependencyAnalysis)' == 'false'">
<Message Importance="high" Text="Running dependency analysis..." />
<PropertyGroup>
<SkipHelpValue Condition=" '$(SkipHelp)' == 'true' ">-s</SkipHelpValue>
</PropertyGroup>
<!-- TODO: Use '-m @(ModulesChanged)' in command when FilterBuild is fixed. -->
<!-- <Exec Command="dotnet $(MSBuildThisFileDirectory)src/Package/StaticAnalysis/StaticAnalysis.Netcore.dll -p $(MSBuildThisFileDirectory)src/Package/$(Configuration) -r $(MSBuildThisFileDirectory)src/Package/StaticAnalysis $(SkipHelpValue) -u" /> -->
<OnError ExecuteTargets="StaticAnalysisErrorMessage" />
</Target>
<!-- Run Validation -->
<Target Name="DependencyAnalysisNetcore"
Condition="'$(SkipDependencyAnalysis)' == 'false'">
<MSBuild Projects="@(StaticAnalysisNetcore)"
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="dotnet $(MSBuildProjectDirectory)\src\Package\StaticAnalysis.Netcore.dll -p $(MSBuildProjectDirectory)\src\Package\$(Configuration) -r $(MSBuildProjectDirectory)\src\Package $(SkipHelpValue) -u -m @(ModulesChanged)" />
<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) ". $(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" />
<CallTarget Targets="BuildInstaller" Condition="'$(Scope)' =='All' or '$(Scope)' == 'Netcore'" />
</Target>
<Target Name="Test">
<Message Importance="high" Text="Running check in tests..." />
<CallTarget Targets="BinScopeCheck" Condition="'$(OnPremiseBuild)'" />
<CallTarget Targets="RunPoliCheck" Condition="'$(OnPremiseBuild)'" />
<MakeDir Directories="$(TestOutputDirectory)" ContinueOnError="false" />
<Exec Command="dotnet new sln -n Azure.PowerShell --force" />
<ItemGroup>
<ModuleCsprojFiles Include="$(LibraryRoot)src/ResourceManager/**/*.csproj" />
</ItemGroup>
<Exec Command="dotnet sln Azure.PowerShell.sln add @(ModuleCsprojFiles->'%(FullPath)', ' ')" />
<!-- https://github.com/Microsoft/msbuild/issues/3157#issuecomment-378002971 -->
<!-- https://github.com/xunit/xunit/issues/1154#issuecomment-405366373 -->
<Exec Command="dotnet test Azure.PowerShell.sln --filter "AcceptanceType=CheckIn%26RunType!=DesktopOnly" --configuration $(Configuration) --framework netcoreapp2.0 --logger trx" />
<ItemGroup>
<TestResults Include="$(LibraryRoot)src/ResourceManager/**/TestResults/*.trx" />
</ItemGroup>
<Copy SourceFiles="@(TestResults)" DestinationFolder="$(TestOutputDirectory)" />
<OnError ExecuteTargets="TestFailureErrorMessage" />
</Target>
<Target Name="TestFailureErrorMessage">
<Error Text="Test failures occured, check the files in src/Publish/TestResults." />
</Target>
<Target Name="BinScopeCheck">
<Exec Command="$(PowerShellCoreCommandPrefix) "$(MSBuildProjectDirectory)\tools\CheckBinScope.ps1 -BuildConfig $(Configuration) -CIToolsPath $(CIToolsPath)"" ContinueOnError="False" />
<OnError ExecuteTargets="BinScopeErrorMessage" />
</Target>
<Target Name="BinScopeErrorMessage">
<Error Text="Binscope failed, please check the files in src/Package/BinScope" />
</Target>
<Target Name="RunPoliCheck">
<Exec Command="$(PowerShellCoreCommandPrefix) "$(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>