Bladeren bron

Unify publish/test mvc.testing functionality + switch to helix for mvc functional tests (#29028)

Hao Kung 5 jaren geleden
bovenliggende
commit
339c8b7c6f

+ 10 - 0
src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.targets

@@ -46,6 +46,16 @@
     </ItemGroup>
   </Target>
 
+  <Target Name="_GeneratePublishTestManifest" BeforeTargets="Publish" DependsOnTargets="_ResolveMvcTestProjectReferences">
+    <ItemGroup>
+      <_PublishManifestProjects Include="%(_ContentRootProjectReferences.FusionName)">
+        <ContentRoot>~</ContentRoot>
+      </_PublishManifestProjects>
+    </ItemGroup>
+
+    <GenerateMvcTestManifestTask ManifestPath="$(PublishDir)MvcTestingAppManifest.json" Projects="@(_PublishManifestProjects)" />
+  </Target>
+
   <Target Name="_MvcCopyDependencyFiles" AfterTargets="Build;_ResolveMvcTestProjectReferences" Condition="'$(TargetFramework)'!=''">
     <ItemGroup>
       <DepsFilePaths

+ 4 - 5
src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs

@@ -190,14 +190,13 @@ namespace Microsoft.AspNetCore.Mvc.Testing
         {
             var data = JsonSerializer.Deserialize<IDictionary<string, string>>(File.ReadAllBytes(file));
             var key = typeof(TEntryPoint).Assembly.GetName().FullName;
-            try
-            {
-                return data[key];
-            } catch
+            
+            if (!data.TryGetValue(key, out var contentRoot))
             {
-                throw new KeyNotFoundException($"Could not find content root for project '{key}' in test manifest file '{file}'");
+               throw new KeyNotFoundException($"Could not find content root for project '{key}' in test manifest file '{file}'");
             }
 
+            return (contentRoot == "~") ? AppContext.BaseDirectory : contentRoot;
         }
 
         private string GetContentRootFromAssembly()

+ 1 - 0
src/Mvc/samples/MvcSandbox/MvcSandbox.csproj

@@ -2,6 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
+    <PreserveCompilationContext>true</PreserveCompilationContext>
   </PropertyGroup>
 
   <ItemGroup>

+ 5 - 25
src/Mvc/test/Mvc.FunctionalTests/BasicTests.cs

@@ -49,11 +49,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
             Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
 
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Fact]
@@ -73,11 +69,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
             Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
 
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Theory]
@@ -101,11 +93,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
             Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
 
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Fact]
@@ -125,11 +113,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
             Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
 
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Fact]
@@ -147,11 +131,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             // Assert
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
 
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Fact]

+ 1 - 1
src/Mvc/test/Mvc.FunctionalTests/ErrorPageTests.cs

@@ -117,7 +117,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             // Arrange
             var expectedMessage = "The type or namespace name &#x27;NamespaceDoesNotExist&#x27; could not be found ("
                 + "are you missing a using directive or an assembly reference?)";
-            var expectedCompilationContent = "public class Views_ErrorFromViewImports_Index : "
+            var expectedCompilationContent = "Views_ErrorFromViewImports_Index : "
                 + "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage&lt;dynamic&gt;";
             var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");
 

+ 49 - 73
src/Mvc/test/Mvc.FunctionalTests/HtmlGenerationTest.cs

@@ -65,8 +65,6 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
                     { "Environment", null },
                     // Testing InputTagHelper with File
                     { "Input", null },
-                    // Testing the LinkTagHelper
-                    { "Link", null },
                     // Test ability to generate nearly identical HTML with MVC tag and HTML helpers.
                     // Only attribute order should differ.
                     { "Order", "/HtmlGeneration_Order/Submit" },
@@ -78,8 +76,6 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
                     { "ProductList", "/HtmlGeneration_Product" },
                     { "ProductListUsingTagHelpers", "/HtmlGeneration_Product" },
                     { "ProductListUsingTagHelpersWithNullModel", "/HtmlGeneration_Product" },
-                    // Testing the ScriptTagHelper
-                    { "Script", null },
                 };
 
                 return data;
@@ -118,26 +114,34 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             responseContent = responseContent.Trim();
             if (antiforgeryPath == null)
             {
-#if GENERATE_BASELINES
                 ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
                 Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true);
-#endif
             }
             else
             {
                 var forgeryToken = AntiforgeryTestHelper.RetrieveAntiforgeryToken(responseContent, antiforgeryPath);
-#if GENERATE_BASELINES
-                // Reverse usual substitution and insert a format item into the new file content.
-                responseContent = responseContent.Replace(forgeryToken, "{0}");
-                ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-                expectedContent = string.Format(CultureInfo.InvariantCulture, expectedContent, forgeryToken);
-                Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true);
-#endif
+
+                if (ResourceFile.GenerateBaselines)
+                {
+                    // Reverse usual substitution and insert a format item into the new file content.
+                    responseContent = responseContent.Replace(forgeryToken, "{0}");
+                    ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
+                }
+                else
+                {
+                    expectedContent = string.Format(CultureInfo.InvariantCulture, expectedContent, forgeryToken);
+                    Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true);
+                }
             }
         }
 
+        [ConditionalTheory]
+        [InlineData("Link", null)]
+        [InlineData("Script", null)]
+        [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/10423")]
+        public Task HtmlGenerationWebSite_GeneratesExpectedResultsNotReadyForHelix(string action, string antiforgeryPath)
+            => HtmlGenerationWebSite_GeneratesExpectedResults(action, antiforgeryPath);
+
         [Fact]
         [QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/25206")]
         public async Task HtmlGenerationWebSite_GeneratesExpectedResults_WithImageData()
@@ -167,11 +171,8 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
 
             responseContent = responseContent.Trim();
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true);
-#endif
+
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         public static TheoryData<string, string> EncodedPagesData
@@ -183,11 +184,9 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
                     { "AttributesWithBooleanValues", null },
                     { "EditWarehouse", null },
                     { "Index", null },
-                    { "Link", null },
                     { "Order", "/HtmlGeneration_Order/Submit" },
                     { "OrderUsingHtmlHelpers", "/HtmlGeneration_Order/Submit" },
                     { "Product", null },
-                    { "Script", null },
                 };
             }
         }
@@ -214,29 +213,22 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             responseContent = responseContent.Trim();
             if (antiforgeryPath == null)
             {
-#if GENERATE_BASELINES
-                ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-                Assert.Equal(
-                    expectedContent.Trim(),
-                    responseContent,
-                    ignoreLineEndingDifferences: true);
-#endif
+                ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
             }
             else
             {
-                var forgeryToken = AntiforgeryTestHelper.RetrieveAntiforgeryToken(responseContent, antiforgeryPath);
-#if GENERATE_BASELINES
-                // Reverse usual substitution and insert a format item into the new file content.
-                responseContent = responseContent.Replace(forgeryToken, "{0}");
-                ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-                expectedContent = string.Format(CultureInfo.InvariantCulture, expectedContent, forgeryToken);
-                Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true);
-#endif
+                ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent, token: AntiforgeryTestHelper.RetrieveAntiforgeryToken(responseContent, antiforgeryPath));
             }
         }
 
+
+        [ConditionalTheory]
+        [InlineData("Link", null)]
+        [InlineData("Script", null)]
+        [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/10423")]
+        public Task HtmlGenerationWebSite_GenerateEncodedResultsNotReadyForHelix(string action, string antiforgeryPath)
+            => HtmlGenerationWebSite_GenerateEncodedResults(action, antiforgeryPath);
+
         // Testing how ModelMetadata is handled as ViewDataDictionary instances are created.
         [Theory]
         [InlineData("AtViewModel")]
@@ -259,11 +251,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
 
             responseContent = responseContent.Trim();
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Fact]
@@ -293,17 +281,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
 
             responseContent = responseContent.Trim();
-            var forgeryToken =
-                AntiforgeryTestHelper.RetrieveAntiforgeryToken(responseContent, "Customer/HtmlGeneration_Customer");
-
-#if GENERATE_BASELINES
-            // Reverse usual substitution and insert a format item into the new file content.
-            responseContent = responseContent.Replace(forgeryToken, "{0}");
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            expectedContent = string.Format(CultureInfo.InvariantCulture, expectedContent, forgeryToken);
-            Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent, token: AntiforgeryTestHelper.RetrieveAntiforgeryToken(responseContent, "Customer/HtmlGeneration_Customer"));
         }
 
         [Fact]
@@ -396,12 +374,12 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             var response2 = await (await Client.SendAsync(request)).Content.ReadAsStringAsync();
 
             // Assert - 1
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile1, expected1, response1.Trim());
-#else
-            Assert.Equal(expected1, response1.Trim(), ignoreLineEndingDifferences: true);
-            Assert.Equal(expected1, response2.Trim(), ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile1, expected1, response1.Trim());
+
+            if (!ResourceFile.GenerateBaselines)
+            {
+                Assert.Equal(expected1, response2.Trim(), ignoreLineEndingDifferences: true);
+            }
 
             // Act - 2
             // Verify content gets changed in partials when one of the vary by parameters is changed
@@ -412,12 +390,11 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             var response4 = await (await Client.SendAsync(request)).Content.ReadAsStringAsync();
 
             // Assert - 2
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile2, expected2, response3.Trim());
-#else
-            Assert.Equal(expected2, response3.Trim(), ignoreLineEndingDifferences: true);
-            Assert.Equal(expected2, response4.Trim(), ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile2, expected2, response3.Trim());
+            if (!ResourceFile.GenerateBaselines)
+            {
+                Assert.Equal(expected2, response4.Trim(), ignoreLineEndingDifferences: true);
+            }
 
             // Act - 3
             // Verify content gets changed in a View Component when the Vary-by-header parameters is changed
@@ -428,12 +405,11 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             var response6 = await (await Client.SendAsync(request)).Content.ReadAsStringAsync();
 
             // Assert - 3
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile3, expected3, response5.Trim());
-#else
-            Assert.Equal(expected3, response5.Trim(), ignoreLineEndingDifferences: true);
-            Assert.Equal(expected3, response6.Trim(), ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile3, expected3, response5.Trim());
+            if (!ResourceFile.GenerateBaselines)
+            {
+                Assert.Equal(expected3, response6.Trim(), ignoreLineEndingDifferences: true);
+            }
         }
 
         [Fact]

+ 41 - 10
src/Mvc/test/Mvc.FunctionalTests/Infrastructure/ResourceFile.cs

@@ -3,23 +3,52 @@
 
 using System;
 using System.Diagnostics;
+using System.Globalization;
 using System.IO;
 using System.Reflection;
 using System.Text;
 using System.Threading.Tasks;
 using Microsoft.AspNetCore.Testing;
+using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources;
 using Xunit;
 
 namespace Microsoft.AspNetCore.Mvc
 {
     /// <summary>
-    /// Reader and, if GENERATE_BASELINES is defined, writer for files compiled into an assembly as resources.
+    /// Reader and, if GenerateBaselines is set to true, writer for files compiled into an assembly as resources.
     /// </summary>
     /// <remarks>Inspired by Razor's BaselineWriter and TestFile test classes.</remarks>
     public static class ResourceFile
     {
+        /// <summary>
+        /// Set this to true to cause baseline files to becompiled into an assembly as resources.
+        /// </summary>
+        public static readonly bool GenerateBaselines = false;
+
         private static object writeLock = new object();
 
+        public static void UpdateOrVerify(Assembly assembly, string outputFile, string expectedContent, string responseContent, string token = null)
+        {
+            if (GenerateBaselines)
+            {
+                // Reverse usual substitution and insert a format item into the new file content.
+                if (token != null)
+                {
+                    responseContent = responseContent.Replace(token, "{0}");
+                }
+                UpdateFile(assembly, outputFile, expectedContent, responseContent);
+            }
+            else
+            {
+                if (token != null)
+                {
+                    expectedContent = string.Format(CultureInfo.InvariantCulture, expectedContent, token);
+                }
+                Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
+            }
+        }
+
+
         /// <summary>
         /// Return <see cref="Stream"/> for <paramref name="resourceName"/> from <paramref name="assembly"/>'s
         /// manifest.
@@ -48,16 +77,19 @@ namespace Microsoft.AspNetCore.Mvc
             var fullName = $"{ assembly.GetName().Name }.{ resourceName.Replace('/', '.') }";
             if (!Exists(assembly, fullName))
             {
-#if GENERATE_BASELINES
-                if (sourceFile)
+                if (GenerateBaselines)
+                {
+                    if (sourceFile)
+                    {
+                        // Even when generating baselines, a missing source file is a serious problem.
+                        Assert.True(false, $"Manifest resource: { fullName } not found.");
+                    }
+                }
+                else
                 {
-                    // Even when generating baselines, a missing source file is a serious problem.
-                    Assert.True(false, $"Manifest resource: { fullName } not found.");
+                    // When not generating baselines, a missing source or output file is always an error.
+                    Assert.True(false, $"Manifest resource '{ fullName }' not found.");
                 }
-#else
-                // When not generating baselines, a missing source or output file is always an error.
-                Assert.True(false, $"Manifest resource '{ fullName }' not found.");
-#endif
 
                 return null;
             }
@@ -179,7 +211,6 @@ namespace Microsoft.AspNetCore.Mvc
         /// <param name="content">
         /// New content of <paramref name="resourceName"/> in <paramref name="assembly"/>.
         /// </param>
-        [Conditional("GENERATE_BASELINES")]
         public static void UpdateFile(Assembly assembly, string resourceName, string previousContent, string content)
         {
             // Normalize line endings to '\r\n' for comparison. This removes Environment.NewLine from the equation. Not

+ 2 - 6
src/Mvc/test/Mvc.FunctionalTests/LinkGenerationTests.cs

@@ -77,11 +77,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
             Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
 
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
     }
-}
+}

+ 27 - 2
src/Mvc/test/Mvc.FunctionalTests/Microsoft.AspNetCore.Mvc.FunctionalTests.csproj

@@ -9,8 +9,6 @@
     <TestGroupName>Mvc.FunctionalTests</TestGroupName>
     <!-- The test asset projects this depends on are not strong-named. -->
     <SignAssembly>false</SignAssembly>
-    <!-- https://github.com/dotnet/aspnetcore/issues/10423 -->
-    <BuildHelixPayload>false</BuildHelixPayload>
   </PropertyGroup>
 
   <ItemGroup>
@@ -60,4 +58,31 @@
     <Reference Include="Microsoft.AspNetCore.Routing" />
     <Reference Include="Microsoft.AspNetCore.TestHost" />
   </ItemGroup>
+
+  <Target Name="PublishAssets" AfterTargets="Publish">
+    <ItemGroup>
+      <_PublishFiles Include="$(ArtifactsBinDir)ApiExplorerWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\ApiExplorerWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)ApplicationModelWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\ApplicationModelWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)BasicWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\BasicWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)ControllersFromServicesWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\ControllersFromServicesWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)CorsWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\CorsWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)ErrorPageMiddlewareWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\ErrorPageMiddlewareWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)FilesWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\FilesWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)FormatterWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\FormatterWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)GenericHostWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\GenericHostWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)HtmlGenerationWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\HtmlGenerationWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)Mvc.RoutingWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\Mvc.RoutingWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)MvcSandbox\$(Configuration)\$(DefaultNetCoreTargetFramework)\MvcSandbox.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)RazorBuildWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\RazorBuildWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)RazorPagesWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\RazorPagesWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)RazorWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\RazorWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)SecurityWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\SecurityWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)SimpleWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\SimpleWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)TagHelpersWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\TagHelpersWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)VersioningWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\VersioningWebSite.deps.json" />
+      <_PublishFiles Include="$(ArtifactsBinDir)XmlFormattersWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\XmlFormattersWebSite.deps.json" />
+    </ItemGroup>
+    <Copy SourceFiles="@(_PublishFiles)" DestinationFolder="$(PublishDir)" />
+  </Target>
+
 </Project>

+ 2 - 9
src/Mvc/test/Mvc.FunctionalTests/RazorPagesTest.cs

@@ -1,4 +1,4 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// Copyright (c) .NET Foundation. All rights reserved.
 // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
@@ -50,14 +50,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
 
             var forgeryToken = AntiforgeryTestHelper.RetrieveAntiforgeryToken(responseContent, "SimpleForms");
-#if GENERATE_BASELINES
-            // Reverse usual substitution and insert a format item into the new file content.
-            responseContent = responseContent.Replace(forgeryToken, "{0}");
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            expectedContent = string.Format(CultureInfo.InvariantCulture, expectedContent, forgeryToken);
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent, forgeryToken);
         }
 
         [Fact]

+ 2 - 9
src/Mvc/test/Mvc.FunctionalTests/RemoteAttributeValidationTest.cs

@@ -42,14 +42,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             Assert.Equal("utf-8", response.Content.Headers.ContentType.CharSet);
 
             var responseContent = await response.Content.ReadAsStringAsync();
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(
-                expectedContent,
-                responseContent,
-                ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Theory]
@@ -105,4 +98,4 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             Assert.Equal(expectedContent, responseContent);
         }
     }
-}
+}

+ 4 - 16
src/Mvc/test/Mvc.FunctionalTests/TagHelperComponentTagHelperTest.cs

@@ -1,4 +1,4 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// Copyright (c) .NET Foundation. All rights reserved.
 // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System.Net;
@@ -37,11 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             // Assert
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
 
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Fact]
@@ -61,11 +57,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             // Assert
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
 
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Fact]
@@ -85,11 +77,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             // Assert
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
 
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
     }
 }

+ 15 - 51
src/Mvc/test/Mvc.FunctionalTests/TagHelpersTest.cs

@@ -8,6 +8,7 @@ using System.Net.Http;
 using System.Net.Http.Headers;
 using System.Reflection;
 using System.Threading.Tasks;
+using Microsoft.AspNetCore.Testing;
 using Xunit;
 
 namespace Microsoft.AspNetCore.Mvc.FunctionalTests
@@ -35,12 +36,10 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
         public HttpClient EncodedClient { get; }
 
         [Theory]
-        [InlineData("GlobbingTagHelpers")]
         [InlineData("Index")]
         [InlineData("About")]
         [InlineData("Help")]
         [InlineData("UnboundDynamicAttributes")]
-        [InlineData("ViewComponentTagHelpers")]
         public async Task CanRenderViewsWithTagHelpers(string action)
         {
             // Arrange
@@ -58,13 +57,16 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
 
             var responseContent = await response.Content.ReadAsStringAsync();
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
+        [ConditionalTheory]
+        [InlineData("GlobbingTagHelpers")]
+        [InlineData("ViewComponentTagHelpers")]
+        [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/10423")]
+        public Task CanRenderViewsWithTagHelpersNotReadyForHelix(string action)
+            => CanRenderViewsWithTagHelpers(action);
+
         [Fact]
         public async Task GivesCorrectCallstackForSyncronousCalls()
         {
@@ -94,11 +96,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
             Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
 
             var responseContent = await response.Content.ReadAsStringAsync();
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Fact]
@@ -122,18 +120,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
 
             var forgeryToken = AntiforgeryTestHelper.RetrieveAntiforgeryToken(
                 responseContent, "/Employee/DuplicateAntiforgeryTokenRegistration");
-
-#if GENERATE_BASELINES
-            // Reverse usual substitution and insert a format item into the new file content.
-            responseContent = responseContent.Replace(forgeryToken, "{0}");
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            expectedContent = string.Format(CultureInfo.InvariantCulture, expectedContent, forgeryToken);
-            Assert.Equal(
-                expectedContent.Trim(),
-                responseContent,
-                ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent, forgeryToken);
         }
 
         public static TheoryData TagHelpersAreInheritedFromViewImportsPagesData
@@ -226,14 +213,7 @@ page:<root>root-content</root>"
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
 
             var responseContent = await response.Content.ReadAsStringAsync();
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(
-                expectedContent,
-                responseContent,
-                ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Fact]
@@ -261,11 +241,7 @@ page:<root>root-content</root>"
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
 
             var responseContent = await response.Content.ReadAsStringAsync();
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Fact]
@@ -293,14 +269,7 @@ page:<root>root-content</root>"
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
 
             var responseContent = await response.Content.ReadAsStringAsync();
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(
-                expectedContent,
-                responseContent,
-                ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Theory]
@@ -322,12 +291,7 @@ page:<root>root-content</root>"
             // Assert
             Assert.Equal(HttpStatusCode.OK, response.StatusCode);
             var responseContent = await response.Content.ReadAsStringAsync();
-
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
     }
 }

+ 3 - 11
src/Mvc/test/Mvc.FunctionalTests/UrlResolutionTest.cs

@@ -40,11 +40,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
 
             // Assert
             responseContent = responseContent.Trim();
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
 
         [Fact]
@@ -61,11 +57,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
 
             // Assert
             responseContent = responseContent.Trim();
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_resourcesAssembly, outputFile, expectedContent, responseContent);
         }
     }
-}
+}

+ 1 - 8
src/Mvc/test/Mvc.FunctionalTests/ViewEngineTests.cs

@@ -438,14 +438,7 @@ Partial that does not specify Layout
 
             // Assert
             responseContent = responseContent.Trim();
-#if GENERATE_BASELINES
-            ResourceFile.UpdateFile(_assembly, outputFile, expectedContent, responseContent);
-#else
-            Assert.Equal(
-                expectedContent,
-                responseContent,
-                ignoreLineEndingDifferences: true);
-#endif
+            ResourceFile.UpdateOrVerify(_assembly, outputFile, expectedContent, responseContent);
         }
 
         [Fact]

+ 1 - 0
src/Mvc/test/WebSites/ErrorPageMiddlewareWebSite/ErrorPageMiddlewareWebSite.csproj

@@ -4,6 +4,7 @@
     <TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
     <!-- We want to validate runtime parser \ compilation exceptions -->
     <RazorCompileOnBuild>false</RazorCompileOnBuild>
+    <RazorCompileOnPublish>false</RazorCompileOnPublish>
   </PropertyGroup>
 
   <ItemGroup>

+ 1 - 0
src/Mvc/test/WebSites/RazorBuildWebSite/RazorBuildWebSite.csproj

@@ -4,6 +4,7 @@
     <TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
     <!-- We have tests that test runtime view compilation. -->
     <RazorCompileOnBuild>false</RazorCompileOnBuild>
+    <RazorCompileOnPublish>false</RazorCompileOnPublish>
   </PropertyGroup>
 
   <ItemGroup>

+ 1 - 0
src/Mvc/test/WebSites/RazorPagesWebSite/RazorPagesWebSite.csproj

@@ -5,6 +5,7 @@
 
     <!-- Resx files are embedded data -->
     <GenerateResxSource>false</GenerateResxSource>
+    <PreserveCompilationContext>true</PreserveCompilationContext>
   </PropertyGroup>
 
   <ItemGroup>

+ 1 - 0
src/Mvc/test/WebSites/RoutingWebSite/Mvc.RoutingWebSite.csproj

@@ -2,6 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
+    <PreserveCompilationContext>true</PreserveCompilationContext>
   </PropertyGroup>
 
   <ItemGroup>