Skip to content

Commit 8eb2e11

Browse files
committed
Use -noBuild in second build steps of test jobs
- building again in Publish target adds nothing in most cases - use `-noBuildRepoTasks` more consistently - again, building the repo tasks wastefully repeated work done in previous build step - use `-noBuildJava` more consistently in quarantined pipelines - Java tests aren't worth testing _or building_ in these pipelines because they cannot be quarantined - remove `-noRestore` and `-noBuildDeps` when `-noBuild` specified; redundant - work around https://github.com/dotnet/sdk/issues/23777 - do not publish .cshtml files of most test asset projects when `$(NoBuild)` is set - update FunctionalTestWithAssets.targets to help Publish succeed when `$(NoBuild)` is set - fixes build jobs in quarantined-pr pipeline where `--no-build` was already specified - for IIS test assets, perform all builds needed for their profiles within Build target - move `ReferenceTestTasks=false` and comments about it to where property matters - merge separate targets in FunctionalTest.props to make items available during (now separate) Publish nits: - touch up RunHelix.ps1 console output - reorder command line arguments for consistency in changed parts of the YAML files - move `NoBuild=true` setting out of FunctionalTestWithAssets.props - use `BeforeTargets` in FunctionalTest.props to improve determinism
1 parent c2cf4e9 commit 8eb2e11

16 files changed

+95
-36
lines changed

.azure/pipelines/ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ stages:
228228
-noBuildRepoTasks
229229
-noBuildNative
230230
-noBuild
231-
-noRestore
232231
-sign
233232
/p:DotNetSignType=$(_SignType)
234233
$(_BuildArgs)
@@ -685,7 +684,7 @@ stages:
685684
- script: ./eng/build.cmd -ci -nobl -all -pack -arch x64
686685
/p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log $(_InternalRuntimeDownloadArgs)
687686
displayName: Build shared fx
688-
- script: ./eng/build.cmd -ci -nobl -noBuildRepoTasks -noRestore -test -all -noBuildNative
687+
- script: ./eng/build.cmd -ci -nobl -all -noBuildRepoTasks -noBuildNative -noBuild -test
689688
-projects eng\helix\helix.proj /p:IsHelixPRCheck=true /p:IsHelixJob=true
690689
/p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log $(_InternalRuntimeDownloadArgs)
691690
displayName: Run build.cmd helix target

.azure/pipelines/helix-matrix.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- script: ./eng/build.cmd -ci -nobl -all -pack -arch x64
3434
/p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log
3535
displayName: Build shared fx
36-
- script: .\eng\build.cmd -ci -nobl -noBuildRepoTasks -noRestore -test -all -noBuildNative
36+
- script: .\eng\build.cmd -ci -nobl -all -noBuildRepoTasks -noBuildNative -noBuild -test
3737
-projects eng\helix\helix.proj /p:IsHelixJob=true
3838
/p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log
3939
displayName: Run build.cmd helix target

.azure/pipelines/quarantined-pr.yml

+11-8
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ jobs:
5454
timeoutInMinutes: 120
5555
steps:
5656
# Build the shared framework
57-
- script: ./eng/build.cmd -ci -nobl -all -pack -arch x64
57+
- script: ./eng/build.cmd -ci -nobl -all -noBuildJava -pack -arch x64
5858
/p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log
5959
displayName: Build shared fx
60-
- script: ./eng/build.cmd -ci -nobl -noBuildRepoTasks -noRestore -test -all -noBuildJava -noBuildNative
60+
- script: ./eng/build.cmd -ci -nobl -all -noBuildRepoTasks -noBuildNative -noBuild -noBuildJava -test
6161
-projects eng\helix\helix.proj /p:IsHelixPRCheck=true /p:RunQuarantinedTests=true /p:IsHelixJob=true
6262
/p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log
6363
displayName: Run build.cmd helix target
@@ -79,9 +79,10 @@ jobs:
7979
isAzDOTestingJob: true
8080
enablePublishTestResults: false
8181
steps:
82-
- powershell: "& ./eng/build.ps1 -CI -nobl -all -pack -NoBuildJava"
82+
- script: ./eng/build.cmd -ci -nobl -all -noBuildJava -pack
8383
displayName: Build
84-
- script: ./eng/build.cmd -ci -nobl -test -NoRestore -NoBuild -NoBuilddeps "/p:RunQuarantinedTests=true /p:SkipHelixReadyTests=true"
84+
- script: ./eng/build.cmd -ci -nobl -all -noBuildRepoTasks -noBuildNative -NoBuild -noBuildJava -test
85+
/p:RunQuarantinedTests=true /p:SkipHelixReadyTests=true
8586
displayName: Run Quarantined Tests
8687
continueOnError: true
8788
- task: PublishTestResults@2
@@ -112,9 +113,10 @@ jobs:
112113
isAzDOTestingJob: true
113114
enablePublishTestResults: false
114115
steps:
115-
- bash: ./eng/build.sh --all --pack --ci --nobl --no-build-java
116+
- bash: ./eng/build.sh --ci --nobl --all --no-build-java --pack
116117
displayName: Build
117-
- bash: ./eng/build.sh --no-build --ci --nobl --test -p:RunQuarantinedTests=true -p:SkipHelixReadyTests=true
118+
- bash: ./eng/build.sh --ci --nobl --all --no-build-repo-tasks --no-build --no-build-java --test
119+
-p:RunQuarantinedTests=true -p:SkipHelixReadyTests=true
118120
displayName: Run Quarantined Tests
119121
continueOnError: true
120122
- task: PublishTestResults@2
@@ -146,9 +148,10 @@ jobs:
146148
enablePublishTestResults: false
147149
useHostedUbuntu: false
148150
steps:
149-
- bash: ./eng/build.sh --all --pack --ci --nobl --no-build-java
151+
- bash: ./eng/build.sh --ci --nobl --all --no-build-java --pack
150152
displayName: Build
151-
- bash: ./eng/build.sh --no-build --ci --nobl --test -p:RunQuarantinedTests=true -p:SkipHelixReadyTests=true
153+
- bash: ./eng/build.sh --ci --nobl --all --no-build-repo-tasks --no-build --no-build-java --test
154+
-p:RunQuarantinedTests=true -p:SkipHelixReadyTests=true
152155
displayName: Run Quarantined Tests
153156
continueOnError: true
154157
- task: PublishTestResults@2

.azure/pipelines/quarantined-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
timeoutInMinutes: 480
2626
steps:
2727
# Build the shared framework
28-
- script: ./eng/build.cmd -ci -nobl -all -pack -arch x64
28+
- script: ./eng/build.cmd -ci -nobl -all -noBuildJava -pack -arch x64
2929
/p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log
3030
displayName: Build shared fx
31-
- script: ./eng/build.cmd -ci -nobl -noBuildRepoTasks -noRestore -test -all -noBuildJava -noBuildNative
31+
- script: ./eng/build.cmd -ci -nobl -all -noBuildRepoTasks -noBuildNative -noBuild -noBuildJava -test
3232
-projects eng\helix\helix.proj /p:RunQuarantinedTests=true /p:IsHelixJob=true
3333
/p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log
3434
displayName: Run build.cmd helix target

eng/scripts/RunHelix.ps1

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ $env:BUILD_REPOSITORY_NAME="aspnetcore"
5252
$env:SYSTEM_TEAMPROJECT="aspnetcore"
5353

5454
Write-Host -ForegroundColor Yellow "If running tests that need the shared Fx, run './build -pack -all' before this."
55-
Write-Host -ForegroundColor Yellow "And if packing for a different platform, add '/p:CrossgenOutput=false'."
55+
Write-Host -ForegroundColor Yellow "If everything is up-to-date, add '/p:NoBuild=true' to this command."
56+
Write-Host -ForegroundColor Yellow "Or, if only the test project is out-of-date, add '/p:BuildProjectReferences=false'."
5657

5758
$HelixQueues = $HelixQueues -replace ";", "%3B"
5859
dotnet msbuild $Project /t:Helix /p:TargetArchitecture="$TargetArchitecture" `

eng/targets/FunctionalTestWithAssets.props

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
<RelativeFolder>%(Filename)</RelativeFolder>
1515
<!-- Whether to _only_ publish the test asset into the test project's folders. -->
1616
<SkipBuild>false</SkipBuild>
17-
<AdditionalProperties Condition=" '%(SkipBuild)' == 'true' ">NoBuild=true</AdditionalProperties>
1817
</TestAssetProjectReference>
1918
</ItemDefinitionGroup>
2019
</Project>

eng/targets/FunctionalTestWithAssets.targets

+15-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,25 @@
77
<Target Name="PublishTestAssets"
88
BeforeTargets="Publish;RunTests;VSTest"
99
Condition=" '@(TestAssetProjectReference->Count())' != 0 ">
10-
<!-- Build and Publish test assets into folders relative to test project. -->
1110
<ItemGroup>
1211
<_ProjectsToPublish Include="@(TestAssetProjectReference)" />
12+
13+
<!-- Always Publish test assets relative to test project's output. -->
1314
<_ProjectsToPublish AdditionalProperties="%(_ProjectsToPublish.AdditionalProperties);
14-
OutputPath=$(OutputPath)%(RelativeFolder);
1515
PublishDir=$(PublishDir)%(RelativeFolder)" />
16+
17+
<!-- Do not build when publishing if SkipBuild requested. -->
18+
<_ProjectsToPublish Condition=" '%(SkipBuild)' == 'true' "
19+
AdditionalProperties="%(_ProjectsToPublish.AdditionalProperties);NoBuild=true" />
20+
21+
<!--
22+
Otherwise, both Build and Publish test assets into folders relative to test project's output. Reset
23+
NoBuild because these projects aren't referenced anywhere else.
24+
-->
25+
<_ProjectsToPublish Condition=" '%(SkipBuild)' != 'true' "
26+
AdditionalProperties="%(_ProjectsToPublish.AdditionalProperties);
27+
NoBuild=false;
28+
OutputPath=$(OutputPath)%(RelativeFolder)" />
1629
</ItemGroup>
1730

1831
<!--

src/Mvc/samples/MvcSandbox/MvcSandbox.csproj

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
2-
32
<PropertyGroup>
43
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
54
<PreserveCompilationContext>true</PreserveCompilationContext>
@@ -14,4 +13,12 @@
1413
<Reference Include="Microsoft.Extensions.Logging.Debug" />
1514
</ItemGroup>
1615

16+
<!-- Work around https://github.com/dotnet/sdk/issues/23777. Reset ContentWithTargetPath items if not building. -->
17+
<Target Name="RemoveCshtmlFiles" BeforeTargets="GetCopyToPublishDirectoryItems" Condition=" '$(NoBuild)' == true ">
18+
<ItemGroup>
19+
<ContentWithTargetPath>
20+
<CopyToPublishDirectory Condition=" '%(Extension)' == '.cshtml' ">None</CopyToPublishDirectory>
21+
</ContentWithTargetPath>
22+
</ItemGroup>
23+
</Target>
1724
</Project>

src/Mvc/test/Mvc.FunctionalTests/Microsoft.AspNetCore.Mvc.FunctionalTests.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
<ProjectReference Include="..\..\shared\Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj" />
2020
<ProjectReference Include="..\WebSites\*\*.csproj"
2121
Exclude="..\WebSites\ControllersFromServicesClassLibrary\ControllersFromServicesClassLibrary.csproj;
22-
..\WebSites\RazorBuildWebSite.*\RazorBuildWebSite.*.csproj" />
22+
..\WebSites\RazorBuildWebSite.*\RazorBuildWebSite.*.csproj;
23+
..\WebSites\RazorPagesClassLibrary\RazorPagesClassLibrary.csproj" />
2324

2425
<Reference Include="AngleSharp" />
2526
<Reference Include="System.Net.Http" />

src/Mvc/test/WebSites/Directory.Build.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
-->
88
<StaticWebAssetsEnabled>false</StaticWebAssetsEnabled>
99
</PropertyGroup>
10-
<!-- Skip the parent folder to prevent getting test package references. -->
11-
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\..\, Directory.Build.props))\Directory.Build.props" />
10+
11+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" />
1212
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.targets))\Directory.Build.targets" />
3+
4+
<!-- Work around https://github.com/dotnet/sdk/issues/23777. Reset ContentWithTargetPath items if not building. -->
5+
<Target Name="RemoveCshtmlFiles"
6+
BeforeTargets="GetCopyToPublishDirectoryItems"
7+
Condition=" '$(RazorCompileOnPublish)' != false AND '$(NoBuild)' == true ">
8+
<ItemGroup>
9+
<ContentWithTargetPath>
10+
<CopyToPublishDirectory Condition=" '%(Extension)' == '.cshtml' ">None</CopyToPublishDirectory>
11+
</ContentWithTargetPath>
12+
</ItemGroup>
13+
</Target>
14+
</Project>

src/Servers/IIS/IIS/test/Common.LongTests/StartupTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ public async Task StartsWithPortableAndBootstraperExe()
217217
// We need the right dotnet on the path in IIS
218218
deploymentParameters.EnvironmentVariables["PATH"] = Path.GetDirectoryName(DotNetCommands.GetDotNetExecutable(deploymentParameters.RuntimeArchitecture));
219219

220-
// ReferenceTestTasks is workaround for https://github.com/dotnet/sdk/issues/2482
221220
var deploymentResult = await DeployAsync(deploymentParameters);
222221

223222
Assert.True(File.Exists(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.exe")));
+9-10
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
<Project>
2-
32
<ItemGroup>
43
<Content Include="..\Common.FunctionalTests\Infrastructure\*.config" CopyToOutputDirectory="PreserveNewest" />
54
</ItemGroup>
65

7-
<Target Name="BuildAssets" AfterTargets="Build" Condition="'$(ExcludeFromBuild)' != 'true'">
8-
<MSBuild Projects="@(ProjectReference)" Targets="PublishTestsAssets" SkipNonexistentTargets="true" BuildInParallel="True">
6+
<Target Name="CopyAssets" BeforeTargets="Publish" Condition=" '$(ExcludeFromBuild)' != true ">
7+
<MSBuild Projects="@(ProjectReference)"
8+
Targets="PublishTestsAssets"
9+
SkipNonexistentTargets="true"
10+
BuildInParallel="True">
911
<Output TaskParameter="TargetOutputs" ItemName="PublishedTestAsset" />
1012
</MSBuild>
11-
</Target>
12-
13-
<Target Name="CopyAssets" AfterTargets="Publish" Condition="'@(PublishedTestAsset->Count())' != '0'">
1413

15-
<ItemGroup>
14+
<ItemGroup Condition=" @(PublishedTestAsset->Count()) != 0 ">
1615
<_FilesToCopy Include="%(PublishedTestAsset.Path)\**\*">
1716
<DestinationDir>$(PublishDir)\%(PublishedTestAsset.Identity)\</DestinationDir>
1817
</_FilesToCopy>
1918
</ItemGroup>
2019

21-
<Copy SourceFiles="@(_FilesToCopy)" DestinationFiles="@(_FilesToCopy->'%(DestinationDir)%(RecursiveDir)%(FileName)%(Extension)')" />
22-
20+
<Copy SourceFiles="@(_FilesToCopy)"
21+
Condition=" @(PublishedTestAsset->Count()) != 0 "
22+
DestinationFiles="@(_FilesToCopy->'%(DestinationDir)%(RecursiveDir)%(FileName)%(Extension)')" />
2323
</Target>
24-
2524
</Project>

src/Servers/IIS/IIS/test/testassets/Directory.Build.targets

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<MSBuild Projects="$(MSBuildProjectFullPath)"
4242
Targets="PublishTestsAsset"
4343
RemoveProperties="Platform;PlatformTarget"
44-
Properties="PublishDir=$(PublishDir);TestAssetProfile=%(TestAssetPublishProfile.Identity);ReferenceTestTasks=false;%(TestAssetPublishProfile.Properties)">
44+
Properties="PublishDir=$(PublishDir);TestAssetProfile=%(TestAssetPublishProfile.Identity);%(TestAssetPublishProfile.Properties)">
4545
<Output TaskParameter="TargetOutputs" ItemName="PublishedTestAsset" />
4646
</MSBuild>
4747
</Target>

src/Servers/IIS/IIS/test/testassets/InProcessNewShimWebSite/InProcessNewShimWebSite.csproj

+14-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111

1212
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
1313
<TestAssetPublishProfile Include="Portable" Properties="TargetFramework=$(DefaultNetCoreTargetFramework)" />
14-
<TestAssetPublishProfile Condition="'$(TargetArchitecture)' != 'arm'" Include="Standalone-x64" Properties="RuntimeIdentifier=win-x64;" />
14+
15+
<!-- ReferenceTestTasks is workaround for https://github.com/dotnet/sdk/issues/2482 -->
16+
<TestAssetPublishProfile Include="Standalone-x64"
17+
Condition=" '$(TargetArchitecture)' != 'arm' "
18+
Properties="RuntimeIdentifier=win-x64;ReferenceTestTasks=false" />
1519
</ItemGroup>
1620

1721
<ItemGroup>
@@ -59,4 +63,13 @@
5963
</PackageReference>
6064
<Reference Include="xunit.assert" />
6165
</ItemGroup>
66+
67+
<!-- Repeat Build target for win-x64 to allow later Publish w/ NoBuild=true. -->
68+
<Target Name="BuildX64"
69+
BeforeTargets="Build"
70+
Condition=" '$(RuntimeIdentifier)' != 'win-x64' AND '$(TargetArchitecture)' != 'arm' ">
71+
<MSBuild Projects="$(MSBuildProjectFullPath)"
72+
Properties="RuntimeIdentifier=win-x64;ReferenceTestTasks=false"
73+
Targets="Build" />
74+
</Target>
6275
</Project>

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/InProcessWebSite.csproj

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
2-
32
<Import Project="..\..\..\..\build\testsite.props" />
43

54
<PropertyGroup>
@@ -9,7 +8,11 @@
98

109
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
1110
<TestAssetPublishProfile Include="Portable" Properties="TargetFramework=$(DefaultNetCoreTargetFramework)" />
12-
<TestAssetPublishProfile Condition="'$(TargetArchitecture)' != 'arm'" Include="Standalone-x64" Properties="RuntimeIdentifier=win-x64;" />
11+
12+
<!-- ReferenceTestTasks is workaround for https://github.com/dotnet/sdk/issues/2482 -->
13+
<TestAssetPublishProfile Include="Standalone-x64"
14+
Condition=" '$(TargetArchitecture)' != 'arm' "
15+
Properties="RuntimeIdentifier=win-x64;ReferenceTestTasks=false" />
1316
</ItemGroup>
1417

1518
<ItemGroup>
@@ -32,4 +35,12 @@
3235
<Reference Include="xunit.assert" />
3336
</ItemGroup>
3437

38+
<!-- Repeat Build target for win-x64 to allow later Publish w/ NoBuild=true. -->
39+
<Target Name="BuildX64"
40+
BeforeTargets="Build"
41+
Condition=" '$(RuntimeIdentifier)' != 'win-x64' AND '$(TargetArchitecture)' != 'arm' ">
42+
<MSBuild Projects="$(MSBuildProjectFullPath)"
43+
Properties="RuntimeIdentifier=win-x64;ReferenceTestTasks=false"
44+
Targets="Build" />
45+
</Target>
3546
</Project>

0 commit comments

Comments
 (0)