azure-powershell-1/build.proj

412 строки
26 KiB
XML

<?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
/t:CopyAboutTopics
Copys about topics to culture folders
# 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) &quot;Remove-Item -Path $(RepoArtifacts) -Recurse -Force -ErrorAction Ignore&quot;" IgnoreExitCode="true" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;Get-ChildItem -Path $(MSBuildThisFileDirectory) -Recurse -Include 'bin','obj','TestResults' | Remove-Item -Recurse -Force -ErrorAction Ignore&quot;" 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)" OutputFile="$(RepoArtifacts)/FilesChanged.txt">
<Output TaskParameter="FilesChanged" ItemName="FilesChanged" />
</FilesChangedTask>
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)PrepareAutorestModule.ps1&quot;" Condition="'$(IsGenerateBased)' == 'true'"/>
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)/CreateFilterMappings.ps1&quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)/PrepareForSecurityCheck.ps1&quot;" 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" />
<Exec Command="echo ##vso[task.setvariable variable=BuildAzPredictor;]true" Condition="$(SubTasks.Contains('Predictor')) OR $(SubTasks.Contains('all'))" />
<CallTarget Targets="AzToolsInstaller" Condition="$(SubTasks.Contains('Installer')) OR $(SubTasks.Contains('all'))" />
</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(&quot;Windows&quot;))' == '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 &quot;%(CsprojFiles.FullPath)&quot;"/>
<PropertyGroup>
<BuildAction Condition="'$(Configuration)' != 'Release'">build</BuildAction>
<BuildAction Condition="'$(Configuration)' == 'Release'">publish</BuildAction>
</PropertyGroup>
<Exec Command="dotnet $(BuildAction) $(RepoArtifacts)Azure.PowerShell.sln -c $(Configuration)" Condition="$(GenerateDocumentationFile) != 'false'"/>
<Exec Command="dotnet $(BuildAction) $(RepoArtifacts)Azure.PowerShell.sln -c $(Configuration) -p:GenerateDocumentationFile=false" Condition="$(GenerateDocumentationFile) == 'false'"/>
<!-- 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,System.IO.Hashing.dll</RuntimeDllsExcludeList>
</PropertyGroup>
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;Get-ChildItem -Path $(RepoArtifacts)/$(Configuration) -Recurse -Include $(RuntimeDllsIncludeList) -Exclude $(RuntimeDllsExcludeList) | Where-Object {$_.FullName -notlike '*PreloadAssemblies*' -and $_.FullName -notlike '*NetCoreAssemblies*' -and $_.FullName -notlike '*AzSharedAlcAssemblies*' -and $_.FullName -notlike '*ModuleAlcAssemblies*'} | Remove-Item -Force&quot;"/>
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;Get-ChildItem -Path $(RepoArtifacts)/$(Configuration) -Recurse -Include 'runtimes' | Remove-Item -Recurse -Force&quot;" Condition="'$(CodeSign)' == 'true'" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/UpdateModules.ps1 -BuildConfig $(Configuration) -Scope $(Scope)&quot;"/>
</Target>
<Target Name="OnPremChecks" Condition="'$(OnPremiseBuild)'">
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)CheckBinScope.ps1 -BuildConfig $(Configuration) -CIToolsPath $(CIToolsPath)&quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)CheckPoliCheck.ps1 -BuildConfig $(Configuration) -CIToolsPath $(CIToolsPath)&quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)CheckCredScan.ps1 -CIToolsPath $(CIToolsPath) -PullRequestNumber $(PullRequestNumber)&quot;" />
<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>
<!-- Copy about topics to culture folders -->
<Target Name="CopyAboutTopics" Condition="'$(SkipHelp)' == 'false'">
<Message Importance="high" Text="Copying about topics to culture folders..." />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;Set-Variable -Name ProgressPreference -Value 'SilentlyContinue';. $(RepoTools)/Docs/CopyAboutTopics.ps1 -BuildConfig $(Configuration)&quot;" />
</Target>
<Target Name="GenerateHelp" Condition="'$(SkipHelp)' == 'false'">
<Message Importance="high" Text="Running help generation..." />
<MakeDir Directories="$(StaticAnalysisOutputDirectory)" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;Set-Variable -Name ProgressPreference -Value 'SilentlyContinue';. $(RepoTools)/GenerateHelp.ps1 -ValidateMarkdownHelp -GenerateMamlHelp -BuildConfig $(Configuration)&quot;" />
<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;CopyAboutTopics;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="StaticAnalysisExample" Condition="'$(RunStaticAnalysis)' == 'true'" DependsOnTargets="Build" AfterTargets="StaticAnalysisHelp">
<Message Importance="high" Text="Running static analysis for PowerShell examples..." />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/StaticAnalysis/ExampleAnalyzer/Measure-MarkdownOrScript.ps1 -MarkdownPaths $(RepoArtifacts)/FilesChanged.txt -RulePaths $(RepoTools)/StaticAnalysis/ExampleAnalyzer/AnalyzeRules/*.psm1 -AnalyzeScriptsInFile -OutputScriptsInFile &quot;"/>
</Target>
<Target Name="StaticAnalysis" DependsOnTargets="StaticAnalysisBreakingChange;StaticAnalysisDependency;StaticAnalysisSignature;StaticAnalysisHelp;StaticAnalysisExample">
<Message Importance="high" Text="Running static analysis..." />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/CheckAssemblies.ps1 -BuildConfig $(Configuration) &quot;" />
<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) &quot;. $(RepoTools)/CheckChangeLog.ps1 -FilesChanged '@(FilesChanged)'&quot;" 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="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) &quot;. $(RepoTools)/NewOutputTypeIndex.ps1 -OutputFile $(RepoArtifacts)/outputtypes.json -BuildConfig $(Configuration)&quot;" Condition="'$(TargetModule)' == ''"/>
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/NewHelpIndex.ps1 -OutputFile $(RepoArtifacts)/index.json -BuildConfig $(Configuration)&quot;" Condition="'$(TargetModule)' == ''"/>
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/CleanupBuild.ps1 -BuildConfig $(Configuration)&quot;" />
<Error Condition="'$(NuGetKey)' == ''" Text="You must provide the NuGetKey parameter to the build: /p:NuGetKey=YOUR_PUBLISHING_KEY" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/PublishModules.ps1 -IsNetCore:$$(NetCore) -BuildConfig $(Configuration) -Scope $(Scope) -ApiKey $(NuGetKey) -RepositoryLocation \&quot;$(NuGetPublishingSource)\&quot;&quot; -NugetExe $(NuGetCommand)" />
</Target>
<Target Name="BuildInstaller" AfterTargets="Publish" Condition="('$(Scope)' == 'All' or '$(Scope)' == 'Latest' or '$(Scope)' == 'Netcore') and '$(TargetModule)' == ''">
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. Register-PSRepository -Name MSIcreationrepository -SourceLocation $(RepoArtifacts) -InstallationPolicy Trusted &quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoRoot)/setup/generate.ps1 -repository MSIcreationrepository &quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. Unregister-PSRepository -Name MSIcreationrepository &quot;" />
</Target>
<Target Name="BuildImages">
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(DockerTools)/GetArtifacts.ps1 -Artifacts $(RepoArtifacts) -Docker $(DockerRoot) &quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(DockerTools)/BuildImages.ps1 -DOCKER $(DockerRoot) -DockerImageName $(DockerImageName) &quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(DockerTools)/CleanArtifacts.ps1 -Docker $(DockerRoot) &quot;" />
</Target>
<Target Name="Test" DependsOnTargets="FilterBuild" Condition="'$(IsGenerateBased)' == 'false'">
<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 &quot;AcceptanceType=CheckIn%26RunType!=DesktopOnly&quot; --configuration $(Configuration) --framework $(TestFramework) --logger trx --results-directory &quot;$(TestOutputDirectory)&quot;" 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) &quot;$(RepoTools)/TestNet472Modules.ps1 -TestExecPath '$(RepoArtifacts)/xUnit/xunit.runner.console/2.4.0/tools/net472/xunit.console.exe'&quot;" />
<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) &quot;Get-ChildItem -Path $(RepoArtifacts) -Recurse -Include 'Signed','Unsigned' | Remove-Item -Recurse -Force -Confirm:$false -ErrorAction Ignore&quot;" IgnoreExitCode="true" />
<!-- CheckSignature.ps1 -->
<Message Text="variables.CheckSignature section" Importance="high" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/CheckSignature.ps1 -CustomPath $(RepoArtifacts)/$(Configuration)&quot;" 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>