diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml index 5df483b991d844a6753b9968542af767da81bea2..55b35f32cee77e37e958ad4afb6ee025ca450400 100644 --- a/.azure/pipelines/ci.yml +++ b/.azure/pipelines/ci.yml @@ -228,7 +228,6 @@ stages: -noBuildRepoTasks -noBuildNative -noBuild - -noRestore -sign /p:DotNetSignType=$(_SignType) $(_BuildArgs) @@ -685,7 +684,8 @@ stages: - script: ./eng/build.cmd -ci -nobl -all -pack -arch x64 /p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log $(_InternalRuntimeDownloadArgs) displayName: Build shared fx - - script: ./eng/build.cmd -ci -nobl -noBuildRepoTasks -noRestore -test -all -noBuildNative + # -noBuildRepoTasks -noBuildNative -noBuild to avoid repeating work done in the previous step. + - script: ./eng/build.cmd -ci -nobl -all -noBuildRepoTasks -noBuildNative -noBuild -test -projects eng\helix\helix.proj /p:IsHelixPRCheck=true /p:IsHelixJob=true /p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log $(_InternalRuntimeDownloadArgs) displayName: Run build.cmd helix target diff --git a/.azure/pipelines/helix-matrix.yml b/.azure/pipelines/helix-matrix.yml index a11aa5e040120a4c6705f9f72a7b5d48c0ac9437..0684583d13b5ffb8e1040afd4bb75487fbb96067 100644 --- a/.azure/pipelines/helix-matrix.yml +++ b/.azure/pipelines/helix-matrix.yml @@ -33,7 +33,8 @@ jobs: - script: ./eng/build.cmd -ci -nobl -all -pack -arch x64 /p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log displayName: Build shared fx - - script: .\eng\build.cmd -ci -nobl -noBuildRepoTasks -noRestore -test -all -noBuildNative + # -noBuildRepoTasks -noBuildNative -noBuild to avoid repeating work done in the previous step. + - script: .\eng\build.cmd -ci -nobl -all -noBuildRepoTasks -noBuildNative -noBuild -test -projects eng\helix\helix.proj /p:IsHelixJob=true /p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log displayName: Run build.cmd helix target diff --git a/.azure/pipelines/quarantined-pr.yml b/.azure/pipelines/quarantined-pr.yml index 4b32ae944062683049950cd9ce690c81dc9f7123..203e9f3fdba5927ce2758f2060e49d25625101c4 100644 --- a/.azure/pipelines/quarantined-pr.yml +++ b/.azure/pipelines/quarantined-pr.yml @@ -54,10 +54,11 @@ jobs: timeoutInMinutes: 120 steps: # Build the shared framework - - script: ./eng/build.cmd -ci -nobl -all -pack -arch x64 + - script: ./eng/build.cmd -ci -nobl -all -noBuildJava -pack -arch x64 /p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log displayName: Build shared fx - - script: ./eng/build.cmd -ci -nobl -noBuildRepoTasks -noRestore -test -all -noBuildJava -noBuildNative + # -noBuildRepoTasks -noBuildNative -noBuild to avoid repeating work done in the previous step. + - script: ./eng/build.cmd -ci -nobl -all -noBuildRepoTasks -noBuildNative -noBuild -noBuildJava -test -projects eng\helix\helix.proj /p:IsHelixPRCheck=true /p:RunQuarantinedTests=true /p:IsHelixJob=true /p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log displayName: Run build.cmd helix target @@ -79,9 +80,10 @@ jobs: isAzDOTestingJob: true enablePublishTestResults: false steps: - - powershell: "& ./eng/build.ps1 -CI -nobl -all -pack -NoBuildJava" + - script: ./eng/build.cmd -ci -nobl -all -noBuildJava -pack displayName: Build - - script: ./eng/build.cmd -ci -nobl -test -NoRestore -NoBuild -NoBuilddeps "/p:RunQuarantinedTests=true /p:SkipHelixReadyTests=true" + - script: ./eng/build.cmd -ci -nobl -all -noBuildRepoTasks -noBuildNative -NoBuild -noBuildJava -test + /p:RunQuarantinedTests=true /p:SkipHelixReadyTests=true displayName: Run Quarantined Tests continueOnError: true - task: PublishTestResults@2 @@ -112,9 +114,10 @@ jobs: isAzDOTestingJob: true enablePublishTestResults: false steps: - - bash: ./eng/build.sh --all --pack --ci --nobl --no-build-java + - bash: ./eng/build.sh --ci --nobl --all --no-build-java --pack displayName: Build - - bash: ./eng/build.sh --no-build --ci --nobl --test -p:RunQuarantinedTests=true -p:SkipHelixReadyTests=true + - bash: ./eng/build.sh --ci --nobl --all --no-build-repo-tasks --no-build --no-build-java --test + -p:RunQuarantinedTests=true -p:SkipHelixReadyTests=true displayName: Run Quarantined Tests continueOnError: true - task: PublishTestResults@2 @@ -146,9 +149,10 @@ jobs: enablePublishTestResults: false useHostedUbuntu: false steps: - - bash: ./eng/build.sh --all --pack --ci --nobl --no-build-java + - bash: ./eng/build.sh --ci --nobl --all --no-build-java --pack displayName: Build - - bash: ./eng/build.sh --no-build --ci --nobl --test -p:RunQuarantinedTests=true -p:SkipHelixReadyTests=true + - bash: ./eng/build.sh --ci --nobl --all --no-build-repo-tasks --no-build --no-build-java --test + -p:RunQuarantinedTests=true -p:SkipHelixReadyTests=true displayName: Run Quarantined Tests continueOnError: true - task: PublishTestResults@2 diff --git a/.azure/pipelines/quarantined-tests.yml b/.azure/pipelines/quarantined-tests.yml index c97f007ea5da3c3472e5a17539f3a8a95ba8497d..ae481b7cbb4136bf606d03efe9fce3414a5dda6f 100644 --- a/.azure/pipelines/quarantined-tests.yml +++ b/.azure/pipelines/quarantined-tests.yml @@ -25,10 +25,11 @@ jobs: timeoutInMinutes: 480 steps: # Build the shared framework - - script: ./eng/build.cmd -ci -nobl -all -pack -arch x64 + - script: ./eng/build.cmd -ci -nobl -all -noBuildJava -pack -arch x64 /p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log displayName: Build shared fx - - script: ./eng/build.cmd -ci -nobl -noBuildRepoTasks -noRestore -test -all -noBuildJava -noBuildNative + # -noBuildRepoTasks -noBuildNative -noBuild to avoid repeating work done in the previous step. + - script: ./eng/build.cmd -ci -nobl -all -noBuildRepoTasks -noBuildNative -noBuild -noBuildJava -test -projects eng\helix\helix.proj /p:RunQuarantinedTests=true /p:IsHelixJob=true /p:CrossgenOutput=false /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log displayName: Run build.cmd helix target diff --git a/eng/scripts/RunHelix.ps1 b/eng/scripts/RunHelix.ps1 index eee981c7e37f68ecad1461bc567c0e0bcfc9883a..d0099e01738245dcb27590985b65e81ae1302e7d 100644 --- a/eng/scripts/RunHelix.ps1 +++ b/eng/scripts/RunHelix.ps1 @@ -52,7 +52,8 @@ $env:BUILD_REPOSITORY_NAME="aspnetcore" $env:SYSTEM_TEAMPROJECT="aspnetcore" Write-Host -ForegroundColor Yellow "If running tests that need the shared Fx, run './build -pack -all' before this." -Write-Host -ForegroundColor Yellow "And if packing for a different platform, add '/p:CrossgenOutput=false'." +Write-Host -ForegroundColor Yellow "If everything is up-to-date, add '/p:NoBuild=true' to this command." +Write-Host -ForegroundColor Yellow "Or, if only the test project is out-of-date, add '/p:BuildProjectReferences=false'." $HelixQueues = $HelixQueues -replace ";", "%3B" dotnet msbuild $Project /t:Helix /p:TargetArchitecture="$TargetArchitecture" ` diff --git a/eng/targets/FunctionalTestWithAssets.props b/eng/targets/FunctionalTestWithAssets.props index 126b2ca6288bf815f340ce7c0d14d7686a461170..2a8d04a3583c1ac278b08c83ad05a8862be72d9e 100644 --- a/eng/targets/FunctionalTestWithAssets.props +++ b/eng/targets/FunctionalTestWithAssets.props @@ -14,7 +14,6 @@ <RelativeFolder>%(Filename)</RelativeFolder> <!-- Whether to _only_ publish the test asset into the test project's folders. --> <SkipBuild>false</SkipBuild> - <AdditionalProperties Condition=" '%(SkipBuild)' == 'true' ">NoBuild=true</AdditionalProperties> </TestAssetProjectReference> </ItemDefinitionGroup> </Project> diff --git a/eng/targets/FunctionalTestWithAssets.targets b/eng/targets/FunctionalTestWithAssets.targets index 2dca09ec9e2c4079980168d53bf1e8aa56a5eb78..29ecd437e30e915ae3b80a59d3fc6367cf8ed50c 100644 --- a/eng/targets/FunctionalTestWithAssets.targets +++ b/eng/targets/FunctionalTestWithAssets.targets @@ -7,12 +7,25 @@ <Target Name="PublishTestAssets" BeforeTargets="Publish;RunTests;VSTest" Condition=" '@(TestAssetProjectReference->Count())' != 0 "> - <!-- Build and Publish test assets into folders relative to test project. --> <ItemGroup> <_ProjectsToPublish Include="@(TestAssetProjectReference)" /> + + <!-- Always Publish test assets relative to test project's output. --> <_ProjectsToPublish AdditionalProperties="%(_ProjectsToPublish.AdditionalProperties); - OutputPath=$(OutputPath)%(RelativeFolder); PublishDir=$(PublishDir)%(RelativeFolder)" /> + + <!-- Do not build when publishing if SkipBuild requested. --> + <_ProjectsToPublish Condition=" '%(SkipBuild)' == 'true' " + AdditionalProperties="%(_ProjectsToPublish.AdditionalProperties);NoBuild=true" /> + + <!-- + Otherwise, both Build and Publish test assets into folders relative to test project's output. Reset + NoBuild because these projects aren't referenced anywhere else. + --> + <_ProjectsToPublish Condition=" '%(SkipBuild)' != 'true' " + AdditionalProperties="%(_ProjectsToPublish.AdditionalProperties); + NoBuild=false; + OutputPath=$(OutputPath)%(RelativeFolder)" /> </ItemGroup> <!-- diff --git a/src/Mvc/samples/MvcSandbox/MvcSandbox.csproj b/src/Mvc/samples/MvcSandbox/MvcSandbox.csproj index b37cc9ac046e270e47b7fc08b13eadc4a9afda29..daf009d84dfffa9198ea61289c4572f13ad83f63 100644 --- a/src/Mvc/samples/MvcSandbox/MvcSandbox.csproj +++ b/src/Mvc/samples/MvcSandbox/MvcSandbox.csproj @@ -1,5 +1,4 @@ <Project Sdk="Microsoft.NET.Sdk.Web"> - <PropertyGroup> <TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework> <PreserveCompilationContext>true</PreserveCompilationContext> @@ -14,4 +13,12 @@ <Reference Include="Microsoft.Extensions.Logging.Debug" /> </ItemGroup> + <!-- Work around https://github.com/dotnet/sdk/issues/23777. Reset ContentWithTargetPath items if not building. --> + <Target Name="RemoveCshtmlFiles" BeforeTargets="GetCopyToPublishDirectoryItems" Condition=" '$(NoBuild)' == true "> + <ItemGroup> + <ContentWithTargetPath> + <CopyToPublishDirectory Condition=" '%(Extension)' == '.cshtml' ">None</CopyToPublishDirectory> + </ContentWithTargetPath> + </ItemGroup> + </Target> </Project> diff --git a/src/Mvc/test/Mvc.FunctionalTests/Microsoft.AspNetCore.Mvc.FunctionalTests.csproj b/src/Mvc/test/Mvc.FunctionalTests/Microsoft.AspNetCore.Mvc.FunctionalTests.csproj index 9729f62231ee71d838797de6e5d3df08cb5dd3e1..ef1661548dab12d686151535f6f0be66f4d55caf 100644 --- a/src/Mvc/test/Mvc.FunctionalTests/Microsoft.AspNetCore.Mvc.FunctionalTests.csproj +++ b/src/Mvc/test/Mvc.FunctionalTests/Microsoft.AspNetCore.Mvc.FunctionalTests.csproj @@ -19,7 +19,8 @@ <ProjectReference Include="..\..\shared\Mvc.Core.TestCommon\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj" /> <ProjectReference Include="..\WebSites\*\*.csproj" Exclude="..\WebSites\ControllersFromServicesClassLibrary\ControllersFromServicesClassLibrary.csproj; - ..\WebSites\RazorBuildWebSite.*\RazorBuildWebSite.*.csproj" /> + ..\WebSites\RazorBuildWebSite.*\RazorBuildWebSite.*.csproj; + ..\WebSites\RazorPagesClassLibrary\RazorPagesClassLibrary.csproj" /> <Reference Include="AngleSharp" /> <Reference Include="System.Net.Http" /> diff --git a/src/Mvc/test/WebSites/Directory.Build.props b/src/Mvc/test/WebSites/Directory.Build.props index 7a0c61b8c7c3f976c2bc954992e2fb55fe44ff33..110e00b967edca90b2efcc2bee92bb2be2318cf5 100644 --- a/src/Mvc/test/WebSites/Directory.Build.props +++ b/src/Mvc/test/WebSites/Directory.Build.props @@ -7,6 +7,6 @@ --> <StaticWebAssetsEnabled>false</StaticWebAssetsEnabled> </PropertyGroup> - <!-- Skip the parent folder to prevent getting test package references. --> - <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\..\, Directory.Build.props))\Directory.Build.props" /> + + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.props))\Directory.Build.props" /> </Project> diff --git a/src/Mvc/test/WebSites/Directory.Build.targets b/src/Mvc/test/WebSites/Directory.Build.targets new file mode 100644 index 0000000000000000000000000000000000000000..c1fd69c7f57c6f71d2c9284304723ef94d8c4a7f --- /dev/null +++ b/src/Mvc/test/WebSites/Directory.Build.targets @@ -0,0 +1,14 @@ +<Project> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.targets))\Directory.Build.targets" /> + + <!-- Work around https://github.com/dotnet/sdk/issues/23777. Reset ContentWithTargetPath items if not building. --> + <Target Name="RemoveCshtmlFiles" + BeforeTargets="GetCopyToPublishDirectoryItems" + Condition=" '$(RazorCompileOnPublish)' != false AND '$(NoBuild)' == true "> + <ItemGroup> + <ContentWithTargetPath> + <CopyToPublishDirectory Condition=" '%(Extension)' == '.cshtml' ">None</CopyToPublishDirectory> + </ContentWithTargetPath> + </ItemGroup> + </Target> +</Project> diff --git a/src/Servers/IIS/IIS/test/Common.LongTests/StartupTests.cs b/src/Servers/IIS/IIS/test/Common.LongTests/StartupTests.cs index b0597655a085980d370cb411bfd98da4ac0667db..0ceb00304400430eab6c5be0583d66a10c3344a6 100644 --- a/src/Servers/IIS/IIS/test/Common.LongTests/StartupTests.cs +++ b/src/Servers/IIS/IIS/test/Common.LongTests/StartupTests.cs @@ -217,7 +217,6 @@ public class StartupTests : IISFunctionalTestBase // We need the right dotnet on the path in IIS deploymentParameters.EnvironmentVariables["PATH"] = Path.GetDirectoryName(DotNetCommands.GetDotNetExecutable(deploymentParameters.RuntimeArchitecture)); - // ReferenceTestTasks is workaround for https://github.com/dotnet/sdk/issues/2482 var deploymentResult = await DeployAsync(deploymentParameters); Assert.True(File.Exists(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.exe"))); diff --git a/src/Servers/IIS/IIS/test/FunctionalTest.props b/src/Servers/IIS/IIS/test/FunctionalTest.props index 3c059a6ef63e55e9082a33579a52b4644014c302..7396b3e8b6397c3b9468f23a7403915fef98d138 100644 --- a/src/Servers/IIS/IIS/test/FunctionalTest.props +++ b/src/Servers/IIS/IIS/test/FunctionalTest.props @@ -1,25 +1,24 @@ <Project> - <ItemGroup> <Content Include="..\Common.FunctionalTests\Infrastructure\*.config" CopyToOutputDirectory="PreserveNewest" /> </ItemGroup> - <Target Name="BuildAssets" AfterTargets="Build" Condition="'$(ExcludeFromBuild)' != 'true'"> - <MSBuild Projects="@(ProjectReference)" Targets="PublishTestsAssets" SkipNonexistentTargets="true" BuildInParallel="True"> + <Target Name="CopyAssets" BeforeTargets="Publish" Condition=" '$(ExcludeFromBuild)' != true "> + <MSBuild Projects="@(ProjectReference)" + Targets="PublishTestsAssets" + SkipNonexistentTargets="true" + BuildInParallel="True"> <Output TaskParameter="TargetOutputs" ItemName="PublishedTestAsset" /> </MSBuild> - </Target> - - <Target Name="CopyAssets" AfterTargets="Publish" Condition="'@(PublishedTestAsset->Count())' != '0'"> - <ItemGroup> + <ItemGroup Condition=" @(PublishedTestAsset->Count()) != 0 "> <_FilesToCopy Include="%(PublishedTestAsset.Path)\**\*"> <DestinationDir>$(PublishDir)\%(PublishedTestAsset.Identity)\</DestinationDir> </_FilesToCopy> </ItemGroup> - <Copy SourceFiles="@(_FilesToCopy)" DestinationFiles="@(_FilesToCopy->'%(DestinationDir)%(RecursiveDir)%(FileName)%(Extension)')" /> - + <Copy SourceFiles="@(_FilesToCopy)" + Condition=" @(PublishedTestAsset->Count()) != 0 " + DestinationFiles="@(_FilesToCopy->'%(DestinationDir)%(RecursiveDir)%(FileName)%(Extension)')" /> </Target> - </Project> diff --git a/src/Servers/IIS/IIS/test/testassets/Directory.Build.targets b/src/Servers/IIS/IIS/test/testassets/Directory.Build.targets index d1c86dc48f4be3bd62430c9c1571ff74ee3b435e..045983437fdf1c80772beae20c07bccf64fd9154 100644 --- a/src/Servers/IIS/IIS/test/testassets/Directory.Build.targets +++ b/src/Servers/IIS/IIS/test/testassets/Directory.Build.targets @@ -41,7 +41,7 @@ <MSBuild Projects="$(MSBuildProjectFullPath)" Targets="PublishTestsAsset" RemoveProperties="Platform;PlatformTarget" - Properties="PublishDir=$(PublishDir);TestAssetProfile=%(TestAssetPublishProfile.Identity);ReferenceTestTasks=false;%(TestAssetPublishProfile.Properties)"> + Properties="PublishDir=$(PublishDir);TestAssetProfile=%(TestAssetPublishProfile.Identity);%(TestAssetPublishProfile.Properties)"> <Output TaskParameter="TargetOutputs" ItemName="PublishedTestAsset" /> </MSBuild> </Target> diff --git a/src/Servers/IIS/IIS/test/testassets/InProcessNewShimWebSite/InProcessNewShimWebSite.csproj b/src/Servers/IIS/IIS/test/testassets/InProcessNewShimWebSite/InProcessNewShimWebSite.csproj index 267860b5d1da692362c0f849303e1e97f6e54c36..fc765d46f8636d772d76047821fc2c31ba751d43 100644 --- a/src/Servers/IIS/IIS/test/testassets/InProcessNewShimWebSite/InProcessNewShimWebSite.csproj +++ b/src/Servers/IIS/IIS/test/testassets/InProcessNewShimWebSite/InProcessNewShimWebSite.csproj @@ -11,7 +11,11 @@ <ItemGroup Condition="'$(OS)' == 'Windows_NT'"> <TestAssetPublishProfile Include="Portable" Properties="TargetFramework=$(DefaultNetCoreTargetFramework)" /> - <TestAssetPublishProfile Condition="'$(TargetArchitecture)' != 'arm'" Include="Standalone-x64" Properties="RuntimeIdentifier=win-x64;" /> + + <!-- ReferenceTestTasks is workaround for https://github.com/dotnet/sdk/issues/2482 --> + <TestAssetPublishProfile Include="Standalone-x64" + Condition=" '$(TargetArchitecture)' != 'arm' " + Properties="RuntimeIdentifier=win-x64;ReferenceTestTasks=false" /> </ItemGroup> <ItemGroup> @@ -59,4 +63,13 @@ </PackageReference> <Reference Include="xunit.assert" /> </ItemGroup> + + <!-- Repeat Build target for win-x64 to allow later Publish w/ NoBuild=true. --> + <Target Name="BuildX64" + BeforeTargets="Build" + Condition=" '$(RuntimeIdentifier)' != 'win-x64' AND '$(TargetArchitecture)' != 'arm' "> + <MSBuild Projects="$(MSBuildProjectFullPath)" + Properties="RuntimeIdentifier=win-x64;ReferenceTestTasks=false" + Targets="Build" /> + </Target> </Project> diff --git a/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/InProcessWebSite.csproj b/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/InProcessWebSite.csproj index cb6d6071a0569d09d44cd31c9fb4737fa9be183f..2f207433c596d0d57106d1f2dd1ddb0af943d35d 100644 --- a/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/InProcessWebSite.csproj +++ b/src/Servers/IIS/IIS/test/testassets/InProcessWebSite/InProcessWebSite.csproj @@ -1,5 +1,4 @@ <Project Sdk="Microsoft.NET.Sdk.Web"> - <Import Project="..\..\..\..\build\testsite.props" /> <PropertyGroup> @@ -9,7 +8,11 @@ <ItemGroup Condition="'$(OS)' == 'Windows_NT'"> <TestAssetPublishProfile Include="Portable" Properties="TargetFramework=$(DefaultNetCoreTargetFramework)" /> - <TestAssetPublishProfile Condition="'$(TargetArchitecture)' != 'arm'" Include="Standalone-x64" Properties="RuntimeIdentifier=win-x64;" /> + + <!-- ReferenceTestTasks is workaround for https://github.com/dotnet/sdk/issues/2482 --> + <TestAssetPublishProfile Include="Standalone-x64" + Condition=" '$(TargetArchitecture)' != 'arm' " + Properties="RuntimeIdentifier=win-x64;ReferenceTestTasks=false" /> </ItemGroup> <ItemGroup> @@ -32,4 +35,12 @@ <Reference Include="xunit.assert" /> </ItemGroup> + <!-- Repeat Build target for win-x64 to allow later Publish w/ NoBuild=true. --> + <Target Name="BuildX64" + BeforeTargets="Build" + Condition=" '$(RuntimeIdentifier)' != 'win-x64' AND '$(TargetArchitecture)' != 'arm' "> + <MSBuild Projects="$(MSBuildProjectFullPath)" + Properties="RuntimeIdentifier=win-x64;ReferenceTestTasks=false" + Targets="Build" /> + </Target> </Project>