|
1 | | -<Project Sdk="Microsoft.Build.NoTargets"> |
| 1 | +<Project Sdk="Microsoft.Build.NoTargets" TreatAsLocalProperty="CleanWhileBuilding"> |
2 | 2 |
|
3 | 3 | <ItemGroup> |
4 | 4 | <RepositoryReference Include="arcade" /> |
|
10 | 10 | <RepositoryReference Include="source-build-reference-packages" /> |
11 | 11 | </ItemGroup> |
12 | 12 |
|
| 13 | + <PropertyGroup> |
| 14 | + <!-- The scenario-tests repo shouldn't be cleaned after building as we run tests from it. --> |
| 15 | + <CleanWhileBuilding>false</CleanWhileBuilding> |
| 16 | + |
| 17 | + <ScenarioTestsArtifactsDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'scenario-tests'))</ScenarioTestsArtifactsDir> |
| 18 | + <ScenarioTestsResultsDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsTestResultsDir)', 'scenario-tests'))</ScenarioTestsResultsDir> |
| 19 | + <_ScenarioTestsNuGetConfig>$(ScenarioTestsArtifactsDir)NuGet.config</_ScenarioTestsNuGetConfig> |
| 20 | + <_InstallerNuGetConfig>$([MSBuild]::NormalizePath('$(SrcDir)', 'installer', 'NuGet.config'))</_InstallerNuGetConfig> |
| 21 | + </PropertyGroup> |
| 22 | + |
| 23 | + <Target Name="SetupNuGetConfig" |
| 24 | + Inputs="$(_InstallerNuGetConfig)" |
| 25 | + Outputs="$(_ScenarioTestsNuGetConfig)"> |
| 26 | + |
| 27 | + <Copy SourceFiles="$(_InstallerNuGetConfig)" |
| 28 | + DestinationFiles="$(_ScenarioTestsNuGetConfig)" /> |
| 29 | + |
| 30 | + </Target> |
| 31 | + |
| 32 | + <Target Name="RunScenarioTests" |
| 33 | + DependsOnTargets="SetupNuGetConfig;DetermineSourceBuiltSdkVersion"> |
| 34 | + |
| 35 | + <PropertyGroup> |
| 36 | + <_CurrentDateTime>$([System.DateTime]::Now.ToString("yyyy-MM-dd_HH_mm_ss"))</_CurrentDateTime> |
| 37 | + <_TestXmlOutputPath>$(ScenarioTestsResultsDir)$(_CurrentDateTime).xml</_TestXmlOutputPath> |
| 38 | + <_ScenarioTestsAdditionalArgs>--xml $(_TestXmlOutputPath) --target-rid $(TargetRid) --no-cleanup --no-traits Category=MultiTFM</_ScenarioTestsAdditionalArgs> |
| 39 | + |
| 40 | + <!-- Define the test root as a sub-directory of the scenario test artifacts directory. It needs to be a sub-directory because the scenario test execution |
| 41 | + will clean that directory. Since we need the NuGet.config file that we copied in to be preserved, that's stored in the directory above the test root. --> |
| 42 | + <_TestRoot>$(ScenarioTestsArtifactsDir)artifacts/</_TestRoot> |
| 43 | + |
| 44 | + <!-- It's necessary to explicitly define the path to the dotnet tool to prevent Arcade from attempting to derive it. Otherwise, it will run the dotnet |
| 45 | + install script to get a new one. We must use the locally built SDK instead in order to support non-portable RIDs for source build. --> |
| 46 | + <_DotNetTool>$(DotNetSdkExtractDir)$([System.IO.Path]::GetFileName('$(DotNetTool)'))</_DotNetTool> |
| 47 | + </PropertyGroup> |
| 48 | + |
| 49 | + <MakeDir Directories="$(ScenarioTestsResultsDir)" /> |
| 50 | + |
| 51 | + <ItemGroup> |
| 52 | + <_ScenarioTestEnvVars Include=" |
| 53 | + TestRoot=$(_TestRoot); |
| 54 | + DotNetRoot=$(DotNetSdkExtractDir); |
| 55 | + TestSdkVersion=$(SourceBuiltSdkVersion); |
| 56 | + AdditionalTestArgs=$(_ScenarioTestsAdditionalArgs); |
| 57 | + DotNetTool=$(_DotNetTool); |
| 58 | + _InitializeDotNetCli=$(DotNetSdkExtractDir)" /> |
| 59 | + </ItemGroup> |
| 60 | + |
| 61 | + <Exec Command="$(TestCommand)" |
| 62 | + WorkingDirectory="$(ProjectDirectory)" |
| 63 | + EnvironmentVariables="@(_ScenarioTestEnvVars)" /> |
| 64 | + </Target> |
| 65 | + |
13 | 66 | </Project> |
0 commit comments