Make build.proj logic work on non source build

... and simplify the Arcade Build.props extension point.

Move the build.proj source build logic into an extra targets file
so that infrastructure can be conditioned and then imported once.
This commit is contained in:
Viktor Hofer 2024-01-11 19:48:24 +01:00
parent a5585609f8
commit d7f415494a
4 changed files with 281 additions and 291 deletions

View file

@ -1,282 +1,24 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<UsingTask AssemblyFile="$(LeakDetectionTasksAssembly)" TaskName="CheckForPoison" />
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="WriteUsageBurndownData" />
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="ReplaceTextInFile" />
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="CreateSdkSymbolsLayout" />
<PropertyGroup>
<!-- Fake, to satisfy the SDK. -->
<TargetFramework>netstandard2.0</TargetFramework>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<SkipErrorOnPrebuilts>true</SkipErrorOnPrebuilts>
</PropertyGroup>
<Target Name="Build">
<Message Text="Build Environment: $(TargetArchitecture) $(Configuration) $(TargetOS) $(TargetRid)" Importance="high" />
<Target Name="Build" DependsOnTargets="PrepareOutput;InitBuild">
<Message Text="Build Environment: $(Platform) $(Configuration) $(TargetOS) $(TargetRid)" />
<MSBuild Projects="$(RepoProjectsDir)$(RootRepo).proj" Targets="Build" BuildInParallel="$(BuildInParallel)" StopOnFirstFailure="true" />
<MSBuild Projects="$(ToolsDir)init-build.proj;
$(RepoProjectsDir)$(RootRepo).proj"
Targets="Build"
BuildInParallel="false"
StopOnFirstFailure="true" />
</Target>
<Target Name="PrepareOutput">
<MakeDir Directories="$(OutputPath)" />
<MakeDir Directories="$(LoggingDir)" />
<MakeDir Directories="$(IntermediatePath)" />
<MakeDir Directories="$(SourceBuiltBlobFeedDir)" />
<MakeDir Directories="$(SourceBuiltPackagesPath)" />
<MakeDir Directories="$(SourceBuiltAssetsDir)" />
<MakeDir Directories="$(MSBuildDebugPathTargetDir)" />
<MakeDir Directories="$(RoslynDebugPathTargetDir)" />
<MakeDir Directories="$(AspNetRazorBuildServerLogDir)" />
</Target>
<Import Project="$(RepositoryEngineeringDir)build.sourcebuild.targets" Condition="'$(DotNetBuildFromSource)' == 'true'" />
<Target Name="InitBuild">
<MSBuild Projects="$(ToolsDir)init-build.proj" />
</Target>
<Target Name="Clean">
<RemoveDir Directories="$(BaseOutputPath)" />
</Target>
<!-- Copies the output assets of the builds to the output path. -->
<Target Name="CopyBinariesToBinFolder"
AfterTargets="Build"
Inputs="$(MSBuildProjectFullPath)"
Outputs="$(CompletedSemaphorePath)CopyBinariesToBinFolder.complete">
<ItemGroup>
<BinariesToCopy Include="$(SourceBuiltAssetsDir)*.*" Exclude="$(SourceBuiltAssetsDir)*.nupkg;$(SourceBuiltAssetsDir)*.requires_nupkg_signing" />
</ItemGroup>
<Copy SourceFiles="@(BinariesToCopy)"
DestinationFolder="$(OutputPath)"
Condition="'@(BinariesToCopy)'!=''" />
<WriteLinesToFile File="$(CompletedSemaphorePath)CopyBinariesToBinFolder.complete" Overwrite="true" />
</Target>
<!-- After building, generate a prebuilt usage report. -->
<Target Name="ReportPrebuiltUsage"
AfterTargets="Build"
Condition="'$(SkipReportPrebuiltUsage)' != 'true'">
<MSBuild Projects="$(RepoProjectsDir)$(RootRepo).proj" Targets="WritePrebuiltUsageData;ReportPrebuiltUsage" />
</Target>
<Target Name="DiscoverSymbolsTarballs"
AfterTargets="Build">
<ItemGroup>
<SymbolsTarball Include="$(OutputPath)Symbols.*.tar.gz" />
</ItemGroup>
</Target>
<Target Name="ExtractSymbolsTarballs"
AfterTargets="Build"
DependsOnTargets="DiscoverSymbolsTarballs"
Outputs="%(SymbolsTarball.Identity)">
<PropertyGroup>
<Filename>$([System.IO.Path]::GetFileName('%(SymbolsTarball.Identity)'))</Filename>
<RepositoryName>$(Filename.Split('.')[1])</RepositoryName>
<UnifiedSymbolsLayout>$(ArtifactsTmpDir)Symbols</UnifiedSymbolsLayout>
<DestinationFolder>$(UnifiedSymbolsLayout)/$(RepositoryName)</DestinationFolder>
</PropertyGroup>
<MakeDir Directories="$(DestinationFolder)" />
<Exec Command="tar -xzf %(SymbolsTarball.Identity) -C $(DestinationFolder)"
WorkingDirectory="$(SymbolsRoot)" />
<Delete Files="%(SymbolsTarball.Identity)" />
</Target>
<!-- After building, repackage symbols into a single tarball. -->
<Target Name="RepackageSymbols"
AfterTargets="Build"
DependsOnTargets="
DetermineMicrosoftSourceBuildIntermediateInstallerVersion;
DiscoverSymbolsTarballs;
ExtractSymbolsTarballs">
<PropertyGroup>
<UnifiedSymbolsTarball>$(OutputPath)dotnet-symbols-all-$(MicrosoftSourceBuildIntermediateInstallerVersion)-$(TargetRid).tar.gz</UnifiedSymbolsTarball>
</PropertyGroup>
<Exec Command="tar --numeric-owner -czf $(UnifiedSymbolsTarball) *"
WorkingDirectory="$(UnifiedSymbolsLayout)" />
<Message Importance="High" Text="Packaged all symbols in '$(UnifiedSymbolsTarball)'" />
</Target>
<!-- After building, create the sdk symbols tarball. -->
<Target Name="CreateSdkSymbolsTarball"
AfterTargets="Build"
DependsOnTargets="RepackageSymbols">
<ItemGroup>
<SdkTarballItem Include="$(OutputPath)dotnet-sdk-*$(TarBallExtension)" />
</ItemGroup>
<PropertyGroup>
<SdkSymbolsLayout>$(ArtifactsTmpDir)SdkSymbols</SdkSymbolsLayout>
<SdkSymbolsTarball>$(OutputPath)dotnet-symbols-sdk-$(MicrosoftSourceBuildIntermediateInstallerVersion)-$(TargetRid).tar.gz</SdkSymbolsTarball>
<SdkLayout>$(ArtifactsTmpDir)Sdk</SdkLayout>
<SdkTarball>%(SdkTarballItem.Identity)</SdkTarball>
</PropertyGroup>
<MakeDir Directories="$(SdkLayout)" />
<Exec Command="tar -xzf $(SdkTarball) -C $(SdkLayout)"
WorkingDirectory="$(OutputPath)" />
<CreateSdkSymbolsLayout SdkLayoutPath="$(SdkLayout)"
AllSymbolsPath="$(UnifiedSymbolsLayout)"
SdkSymbolsLayoutPath="$(SdkSymbolsLayout)"
FailOnMissingPDBs="false" />
<Exec Command="tar --numeric-owner -czf $(SdkSymbolsTarball) *"
WorkingDirectory="$(SdkSymbolsLayout)" />
<Message Importance="High" Text="Packaged sdk symbols in '$(SdkSymbolsTarball)'" />
<RemoveDir Directories="$(UnifiedSymbolsLayout)" />
<RemoveDir Directories="$(SdkSymbolsLayout)" />
<RemoveDir Directories="$(SdkLayout)" />
</Target>
<!--
Dev scenario: rewrite a prebuilt-report. This makes it easy to add data to an existing
prebuilt report without performing another full build. This doesn't reevalutate which packages
are prebuilts or search the projects: it uses the existing usage.xml file to generate report
XMLs based on the info put in artifacts/.
-->
<Target Name="RewritePrebuiltUsageReport">
<MSBuild Projects="$(RepoProjectsDir)$(RootRepo).proj" Targets="ReportPrebuiltUsage" />
</Target>
<Target Name="ReportPoisonUsage"
AfterTargets="Build"
Condition="'$(EnablePoison)' == 'true'"
Inputs="$(MSBuildProjectFullPath)"
Outputs="$(CompletedSemaphorePath)ReportPoisonUsage.complete" >
<ItemGroup>
<FinalCliTarball Include="$(SourceBuiltTarBallPath)**/*$(TarBallExtension)" />
</ItemGroup>
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Checking @(FinalCliTarball) for poisoned files." />
<ItemGroup>
<NonShippingPackagesList Include="$(PackageListsDir)**/$(NonShippingPackagesListPrefix)*" />
</ItemGroup>
<CheckForPoison FilesToCheck="@(FinalCliTarball)"
ProjectDirPath="$(ProjectDir)"
HashCatalogFilePath="$(PoisonReportDataFile)"
MarkerFileName="$(PoisonMarkerFile)"
PoisonReportOutputFilePath="$(PoisonUsageReportFile)"
NonShippingPackagesListFiles="@(NonShippingPackagesList)" />
<WriteLinesToFile File="$(CompletedSemaphorePath)ReportPoisonUsage.complete" Overwrite="true" />
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Done checking for poison." />
</Target>
<Target Name="GeneratePrebuiltBurndownData"
Inputs="$(MSBuildProjectFullPath)"
Outputs="$(CompletedSemaphorePath)GeneratePrebuiltBurndownData.complete" >
<WriteUsageBurndownData RootDirectory="$(ProjectDir)"
PrebuiltBaselineFile="$(BaselineDataFile)"
OutputFilePath="$(PrebuiltBurndownDataFile)" />
<WriteLinesToFile File="$(CompletedSemaphorePath)GeneratePrebuiltBurndownData.complete" Overwrite="true" />
</Target>
<Target Name="RunSmokeTest">
<ItemGroup>
<SdkTarballItem Include="$(SourceBuiltTarBallPath)**/dotnet-sdk*$(TarBallExtension)" />
<SourceBuiltArtifactsItem Include="$(SourceBuiltTarBallPath)**/Private.SourceBuilt.Artifacts.*$(TarBallExtension)" />
</ItemGroup>
<PropertyGroup>
<CustomTestEnvVars Condition="'$(EnablePoison)' == 'true'">SMOKE_TESTS_POISON_REPORT_PATH=$(PoisonUsageReportFile);</CustomTestEnvVars>
<SdkTarballPath>%(SdkTarballItem.Identity)</SdkTarballPath>
<SourceBuiltArtifactsPath>%(SourceBuiltArtifactsItem.Identity)</SourceBuiltArtifactsPath>
<SmokeTestConsoleVerbosity Condition="'$(SmokeTestConsoleVerbosity)' == ''">normal</SmokeTestConsoleVerbosity>
</PropertyGroup>
<!-- Multiple loggers are specified so that results are captured in trx and pipelines can fail with AzDO pipeline warnings -->
<Exec Command="$(DotnetToolCommand) test $(SmokeTestsDir) --logger:trx --logger:'console;verbosity=$(SmokeTestConsoleVerbosity)' -c $(Configuration)"
IgnoreStandardErrorWarningFormat="true"
EnvironmentVariables="
SMOKE_TESTS_SDK_TARBALL_PATH=$(SdkTarballPath);
SMOKE_TESTS_SOURCEBUILT_ARTIFACTS_PATH=$(SourceBuiltArtifactsPath);
SMOKE_TESTS_TARGET_RID=$(TargetRid);
SMOKE_TESTS_PORTABLE_RID=$(PortableRid);
SMOKE_TESTS_CUSTOM_PACKAGES_PATH=$(CustomSourceBuiltPackagesPath);
$(CustomTestEnvVars)" />
</Target>
<Target Name="CreateSmokeTestPrereqsTarball"
AfterTargets="RunSmokeTest"
Condition="'$(SkipSmokeTestPrereqsTarballCreation)' != 'true'"
DependsOnTargets="
CheckIfCreateSmokeTestPrereqsExistToPack;
CreateSmokeTestPrereqsTarballIfPrereqsExist"/>
<Target Name="CheckIfCreateSmokeTestPrereqsExistToPack">
<PropertyGroup>
<SmokeTestsArtifactsDir>$(SmokeTestsDir)bin/$(Configuration)/$(NetCurrent)/</SmokeTestsArtifactsDir>
<SmokeTestsPackagesDir>$(SmokeTestsArtifactsDir)packages/</SmokeTestsPackagesDir>
</PropertyGroup>
<ItemGroup>
<SmokeTestsPrereqs Include="$(SmokeTestsPackagesDir)**/*.nupkg" />
</ItemGroup>
<Message Text="Found @(SmokeTestsPrereqs->Count()) prereqs in '$(SmokeTestsPackagesDir)'." Importance="High" />
</Target>
<Target Name="CreateSmokeTestPrereqsTarballIfPrereqsExist"
DependsOnTargets="DetermineMicrosoftSourceBuildIntermediateInstallerVersion"
Condition="'@(SmokeTestsPrereqs->Count())' != '0'">
<PropertyGroup>
<SmokeTestPrereqsTarballName>$(OutputPath)dotnet-smoke-test-prereqs.$(MicrosoftSourceBuildIntermediateInstallerVersion).$(TargetRid).tar.gz</SmokeTestPrereqsTarballName>
<SmokeTestsPrereqPackagesDir>$(SmokeTestsArtifactsDir)prereq-packages/</SmokeTestsPrereqPackagesDir>
</PropertyGroup>
<Copy SourceFiles="@(SmokeTestsPrereqs)"
DestinationFolder="$(SmokeTestsPrereqPackagesDir)" />
<Exec Command="tar --numeric-owner -czf $(SmokeTestPrereqsTarballName) ."
WorkingDirectory="$(SmokeTestsPrereqPackagesDir)"/>
<Message Importance="High" Text="Packaged smoke-test prereqs in '$(SmokeTestPrereqsTarballName)'" />
</Target>
<Target Name="CreatePrebuiltsTarball"
AfterTargets="Build"
DependsOnTargets="
CheckIfPrebuiltsExistToPack;
CreatePrebuiltsTarballIfPrebuiltsExist;
ErrorOnPrebuilts"/>
<Target Name="CheckIfPrebuiltsExistToPack">
<!-- Directory existence doesn't mean there are files inside. Use a pattern to find files. -->
<ItemGroup>
<PrebuiltFile Include="$(ResultingPrebuiltPackagesDir)**" />
</ItemGroup>
<Message Text="Found @(PrebuiltFile->Count()) files in prebuilt packages dir." Importance="High" />
</Target>
<Target Name="CreatePrebuiltsTarballIfPrebuiltsExist"
DependsOnTargets="DetermineMicrosoftSourceBuildIntermediateInstallerVersion"
Condition="'@(PrebuiltFile->Count())' != '0'">
<PropertyGroup>
<TarballFilePath>$(OutputPath)$(SourceBuiltPrebuiltsTarballName).$(MicrosoftSourceBuildIntermediateInstallerVersion).$(TargetRid).tar.gz</TarballFilePath>
<TarballWorkingDir>$(ResultingPrebuiltPackagesDir)</TarballWorkingDir>
</PropertyGroup>
<Exec Command="tar --numeric-owner -zcf $(TarballFilePath) -C $(TarballWorkingDir) ." />
<Message Text="Tarball '$(TarballFilePath)' was successfully created from '$(TarballWorkingDir)'" Importance="High" />
</Target>
<Target Name="ErrorOnPrebuilts"
Condition="'@(PrebuiltFile->Count())' != '0' AND '$(SkipErrorOnPrebuilts)' != 'true'">
<Error Text="@(PrebuiltFile->Count()) Prebuilts Exist" />
</Target>
</Project>

View file

@ -1,17 +1,7 @@
<Project>
<ItemGroup Condition="'$(SkipProductionBuild)' != 'true'">
<ItemGroup>
<ProjectToBuild Include="$(RepoRoot)build.proj" />
</ItemGroup>
<!-- Prevent Arcade from trying to find something to build, if we want to build nothing. -->
<ItemGroup Condition="'@(ProjectToBuild)' == ''">
<ProjectToBuild Include="$(MSBuildThisFileDirectory)No.proj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props, $(MSBuildThisFileDirectory)))" />
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets, $(MSBuildThisFileDirectory)))" />
<Import Project="$(MSBuildThisFileDirectory)SourceBuild.Tarball.targets" />
</Project>

View file

@ -1,9 +0,0 @@
<!--
This project intentionally does nothing. It is a stub used to avoid building while preventing
Arcade from searching the repo root to find something to do.
-->
<Project>
<Target Name="Build" />
</Project>

View file

@ -0,0 +1,267 @@
<Project>
<PropertyGroup>
<SkipErrorOnPrebuilts>true</SkipErrorOnPrebuilts>
<SmokeTestsDir>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'test', 'Microsoft.DotNet.SourceBuild.SmokeTests'))</SmokeTestsDir>
</PropertyGroup>
<PropertyGroup Condition="'$(EnablePoison)' == 'true'">
<PoisonUsageReportFile>$(PackageReportDir)poison-usage.xml</PoisonUsageReportFile>
</PropertyGroup>
<!-- Copies the output assets of the builds to the output path. -->
<Target Name="CopyBinariesToBinFolder"
AfterTargets="Build">
<ItemGroup>
<BinariesToCopy Include="$(SourceBuiltAssetsDir)*.*"
Exclude="$(SourceBuiltAssetsDir)*.nupkg;$(SourceBuiltAssetsDir)*.requires_nupkg_signing" />
</ItemGroup>
<Copy SourceFiles="@(BinariesToCopy)"
DestinationFolder="$(CollapsedOutputPath)"
SkipUnchangedFiles="true"
Condition="'@(BinariesToCopy)'!=''" />
</Target>
<!-- After building, generate a prebuilt usage report. -->
<Target Name="ReportPrebuiltUsage"
AfterTargets="Build"
Condition="'$(SkipReportPrebuiltUsage)' != 'true'">
<MSBuild Projects="$(RepoProjectsDir)$(RootRepo).proj" Targets="WritePrebuiltUsageData;ReportPrebuiltUsage" />
</Target>
<Target Name="DiscoverSymbolsTarballs"
AfterTargets="Build">
<ItemGroup>
<SymbolsTarball Include="$(CollapsedOutputPath)Symbols.*$(ArchiveExtension)" />
</ItemGroup>
</Target>
<Target Name="ExtractSymbolsTarballs"
AfterTargets="Build"
DependsOnTargets="DiscoverSymbolsTarballs"
Outputs="%(SymbolsTarball.Identity)">
<PropertyGroup>
<Filename>$([System.IO.Path]::GetFileName('%(SymbolsTarball.Identity)'))</Filename>
<RepositoryName>$(Filename.Split('.')[1])</RepositoryName>
<UnifiedSymbolsLayout>$(ArtifactsTmpDir)Symbols</UnifiedSymbolsLayout>
<DestinationFolder>$(UnifiedSymbolsLayout)/$(RepositoryName)</DestinationFolder>
</PropertyGroup>
<MakeDir Directories="$(DestinationFolder)" />
<Exec Command="tar -xzf %(SymbolsTarball.Identity) -C $(DestinationFolder)"
WorkingDirectory="$(SymbolsRoot)" />
<Delete Files="%(SymbolsTarball.Identity)" />
</Target>
<!-- After building, repackage symbols into a single tarball. -->
<Target Name="RepackageSymbols"
AfterTargets="Build"
DependsOnTargets="
DetermineMicrosoftSourceBuildIntermediateInstallerVersion;
DiscoverSymbolsTarballs;
ExtractSymbolsTarballs">
<PropertyGroup>
<UnifiedSymbolsTarball>$(CollapsedOutputPath)dotnet-symbols-all-$(MicrosoftSourceBuildIntermediateInstallerVersion)-$(TargetRid)$(ArchiveExtension)</UnifiedSymbolsTarball>
</PropertyGroup>
<Exec Command="tar --numeric-owner -czf $(UnifiedSymbolsTarball) *"
WorkingDirectory="$(UnifiedSymbolsLayout)" />
<Message Importance="High" Text="Packaged all symbols in '$(UnifiedSymbolsTarball)'" />
</Target>
<!-- After building, create the sdk symbols tarball. -->
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="CreateSdkSymbolsLayout" />
<Target Name="CreateSdkSymbolsTarball"
AfterTargets="Build"
DependsOnTargets="RepackageSymbols">
<ItemGroup>
<SdkTarballItem Include="$(CollapsedOutputPath)dotnet-sdk-*$(ArchiveExtension)" />
</ItemGroup>
<PropertyGroup>
<SdkSymbolsLayout>$(ArtifactsTmpDir)SdkSymbols</SdkSymbolsLayout>
<SdkSymbolsTarball>$(CollapsedOutputPath)dotnet-symbols-sdk-$(MicrosoftSourceBuildIntermediateInstallerVersion)-$(TargetRid)$(ArchiveExtension)</SdkSymbolsTarball>
<SdkLayout>$(ArtifactsTmpDir)Sdk</SdkLayout>
<SdkTarball>%(SdkTarballItem.Identity)</SdkTarball>
</PropertyGroup>
<MakeDir Directories="$(SdkLayout)" />
<Exec Command="tar -xzf $(SdkTarball) -C $(SdkLayout)"
WorkingDirectory="$(CollapsedOutputPath)" />
<CreateSdkSymbolsLayout SdkLayoutPath="$(SdkLayout)"
AllSymbolsPath="$(UnifiedSymbolsLayout)"
SdkSymbolsLayoutPath="$(SdkSymbolsLayout)"
FailOnMissingPDBs="false" />
<Exec Command="tar --numeric-owner -czf $(SdkSymbolsTarball) *"
WorkingDirectory="$(SdkSymbolsLayout)" />
<Message Importance="High" Text="Packaged sdk symbols in '$(SdkSymbolsTarball)'" />
<RemoveDir Directories="$(UnifiedSymbolsLayout)" />
<RemoveDir Directories="$(SdkSymbolsLayout)" />
<RemoveDir Directories="$(SdkLayout)" />
</Target>
<!--
Dev scenario: rewrite a prebuilt-report. This makes it easy to add data to an existing
prebuilt report without performing another full build. This doesn't reevalutate which packages
are prebuilts or search the projects: it uses the existing usage.xml file to generate report
XMLs based on the info put in artifacts/.
-->
<Target Name="RewritePrebuiltUsageReport">
<MSBuild Projects="$(RepoProjectsDir)$(RootRepo).proj"
Targets="ReportPrebuiltUsage" />
</Target>
<UsingTask AssemblyFile="$(LeakDetectionTasksAssembly)" TaskName="CheckForPoison" Condition="'$(EnablePoison)' == 'true'" />
<Target Name="ReportPoisonUsage"
AfterTargets="Build"
Condition="'$(EnablePoison)' == 'true'"
Inputs="$(MSBuildProjectFullPath)"
Outputs="$(BaseIntermediateOutputPath)ReportPoisonUsage.complete" >
<ItemGroup>
<FinalCliTarball Include="$(CollapsedOutputPath)**/*$(ArchiveExtension)" />
</ItemGroup>
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Checking @(FinalCliTarball) for poisoned files." />
<ItemGroup>
<NonShippingPackagesList Include="$(PackageListsDir)**/$(NonShippingPackagesListPrefix)*" />
</ItemGroup>
<CheckForPoison FilesToCheck="@(FinalCliTarball)"
ProjectDirPath="$(RepoRoot)"
HashCatalogFilePath="$(PoisonReportDataFile)"
MarkerFileName="$(PoisonMarkerFile)"
PoisonReportOutputFilePath="$(PoisonUsageReportFile)"
NonShippingPackagesListFiles="@(NonShippingPackagesList)" />
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Done checking for poison." />
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
<Touch Files="$(BaseIntermediateOutputPath)ReportPoisonUsage.complete" AlwaysCreate="true">
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>
</Target>
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="WriteUsageBurndownData" />
<Target Name="GeneratePrebuiltBurndownData"
Inputs="$(MSBuildProjectFullPath)"
Outputs="$(BaseIntermediateOutputPath)GeneratePrebuiltBurndownData.complete" >
<PropertyGroup>
<PrebuiltBurndownDataFile>$(PackageReportDir)PrebuiltBurndownData.csv</PrebuiltBurndownDataFile>
</PropertyGroup>
<WriteUsageBurndownData RootDirectory="$(RepoRoot)"
PrebuiltBaselineFile="$(BaselineDataFile)"
OutputFilePath="$(PrebuiltBurndownDataFile)" />
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
<Touch Files="$(BaseIntermediateOutputPath)GeneratePrebuiltBurndownData.complete" AlwaysCreate="true">
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>
</Target>
<Target Name="RunSmokeTest">
<ItemGroup>
<SdkTarballItem Include="$(CollapsedOutputPath)**/dotnet-sdk*$(ArchiveExtension)" />
<SourceBuiltArtifactsItem Include="$(CollapsedOutputPath)**/$(SourceBuiltArtifactsTarballName).*$(ArchiveExtension)" />
</ItemGroup>
<PropertyGroup>
<CustomTestEnvVars Condition="'$(EnablePoison)' == 'true'">SMOKE_TESTS_POISON_REPORT_PATH=$(PoisonUsageReportFile);</CustomTestEnvVars>
<SdkTarballPath>%(SdkTarballItem.Identity)</SdkTarballPath>
<SourceBuiltArtifactsPath>%(SourceBuiltArtifactsItem.Identity)</SourceBuiltArtifactsPath>
<SmokeTestConsoleVerbosity Condition="'$(SmokeTestConsoleVerbosity)' == ''">normal</SmokeTestConsoleVerbosity>
</PropertyGroup>
<!-- Multiple loggers are specified so that results are captured in trx and pipelines can fail with AzDO pipeline warnings -->
<Exec Command="$(DotnetTool) test $(SmokeTestsDir) --logger:trx --logger:'console;verbosity=$(SmokeTestConsoleVerbosity)' -c $(Configuration)"
IgnoreStandardErrorWarningFormat="true"
EnvironmentVariables="
SMOKE_TESTS_SDK_TARBALL_PATH=$(SdkTarballPath);
SMOKE_TESTS_SOURCEBUILT_ARTIFACTS_PATH=$(SourceBuiltArtifactsPath);
SMOKE_TESTS_TARGET_RID=$(TargetRid);
SMOKE_TESTS_PORTABLE_RID=$(PortableRid);
SMOKE_TESTS_CUSTOM_PACKAGES_PATH=$(CustomSourceBuiltPackagesPath);
$(CustomTestEnvVars)" />
</Target>
<Target Name="CreateSmokeTestPrereqsTarball"
AfterTargets="RunSmokeTest"
Condition="'$(SkipSmokeTestPrereqsTarballCreation)' != 'true'"
DependsOnTargets="
CheckIfCreateSmokeTestPrereqsExistToPack;
CreateSmokeTestPrereqsTarballIfPrereqsExist"/>
<Target Name="CheckIfCreateSmokeTestPrereqsExistToPack">
<PropertyGroup>
<SmokeTestsArtifactsDir>$(SmokeTestsDir)bin/$(Configuration)/$(NetCurrent)/</SmokeTestsArtifactsDir>
<SmokeTestsPackagesDir>$(SmokeTestsArtifactsDir)packages/</SmokeTestsPackagesDir>
</PropertyGroup>
<ItemGroup>
<SmokeTestsPrereqs Include="$(SmokeTestsPackagesDir)**/*.nupkg" />
</ItemGroup>
<Message Text="Found @(SmokeTestsPrereqs->Count()) prereqs in '$(SmokeTestsPackagesDir)'." Importance="High" />
</Target>
<Target Name="CreateSmokeTestPrereqsTarballIfPrereqsExist"
DependsOnTargets="DetermineMicrosoftSourceBuildIntermediateInstallerVersion"
Condition="'@(SmokeTestsPrereqs->Count())' != '0'">
<PropertyGroup>
<SmokeTestPrereqsTarballName>$(CollapsedOutputPath)dotnet-smoke-test-prereqs.$(MicrosoftSourceBuildIntermediateInstallerVersion).$(TargetRid)$(ArchiveExtension)</SmokeTestPrereqsTarballName>
<SmokeTestsPrereqPackagesDir>$(SmokeTestsArtifactsDir)prereq-packages/</SmokeTestsPrereqPackagesDir>
</PropertyGroup>
<Copy SourceFiles="@(SmokeTestsPrereqs)"
DestinationFolder="$(SmokeTestsPrereqPackagesDir)" />
<Exec Command="tar --numeric-owner -czf $(SmokeTestPrereqsTarballName) ."
WorkingDirectory="$(SmokeTestsPrereqPackagesDir)"/>
<Message Importance="High" Text="Packaged smoke-test prereqs in '$(SmokeTestPrereqsTarballName)'" />
</Target>
<Target Name="CreatePrebuiltsTarball"
AfterTargets="Build"
DependsOnTargets="
CheckIfPrebuiltsExistToPack;
CreatePrebuiltsTarballIfPrebuiltsExist;
ErrorOnPrebuilts"/>
<Target Name="CheckIfPrebuiltsExistToPack">
<!-- Directory existence doesn't mean there are files inside. Use a pattern to find files. -->
<ItemGroup>
<PrebuiltFile Include="$(ResultingPrebuiltPackagesDir)**" />
</ItemGroup>
<Message Text="Found @(PrebuiltFile->Count()) files in prebuilt packages dir." Importance="High" />
</Target>
<Target Name="CreatePrebuiltsTarballIfPrebuiltsExist"
DependsOnTargets="DetermineMicrosoftSourceBuildIntermediateInstallerVersion"
Condition="'@(PrebuiltFile->Count())' != '0'">
<PropertyGroup>
<TarballFilePath>$(CollapsedOutputPath)$(SourceBuiltPrebuiltsTarballName).$(MicrosoftSourceBuildIntermediateInstallerVersion).$(TargetRid)$(ArchiveExtension)</TarballFilePath>
<TarballWorkingDir>$(ResultingPrebuiltPackagesDir)</TarballWorkingDir>
</PropertyGroup>
<Exec Command="tar --numeric-owner -zcf $(TarballFilePath) -C $(TarballWorkingDir) ." />
<Message Text="Tarball '$(TarballFilePath)' was successfully created from '$(TarballWorkingDir)'" Importance="High" />
</Target>
<Target Name="ErrorOnPrebuilts"
Condition="'@(PrebuiltFile->Count())' != '0' AND '$(SkipErrorOnPrebuilts)' != 'true'">
<Error Text="@(PrebuiltFile->Count()) Prebuilts Exist" />
</Target>
</Project>