diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index fd85abb361..0000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,17 +0,0 @@ -init: -- git config --global core.autocrlf true -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -build_script: -- ps: .\run.ps1 default-build -clone_depth: 1 -environment: - global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 -test: 'off' -deploy: 'off' -os: Visual Studio 2017 Preview diff --git a/README.md b/README.md index e584eaef12..e99bc694b5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ Razor ===== -AppVeyor: [![AppVeyor](https://ci.appveyor.com/api/projects/status/olbc8ur2jna0v27j/branch/dev?svg=true)](https://ci.appveyor.com/project/aspnetci/razor/branch/dev) - Travis: [![Travis](https://travis-ci.org/aspnet/Razor.svg?branch=dev)](https://travis-ci.org/aspnet/Razor) The Razor syntax provides a fast, terse, clean and lightweight way to combine server code with HTML to create dynamic web content. This repo contains the parser and the C# code generator for the Razor syntax. diff --git a/build/dependencies.props b/build/dependencies.props index bb46a4acdc..e92d72528f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,22 +4,22 @@ 0.10.11 - 2.1.0-preview2-15723 - 2.1.0-preview2-30192 - 2.1.0-preview2-30192 - 2.1.0-preview2-30192 - 15.7.0-preview-000011-1378327 - 15.7.0-preview-000011-1378327 - 15.7.0-preview-000011-1378327 + 2.1.0-preview2-15728 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 15.6.82 + 15.6.82 + 15.6.82 2.6.1 2.6.1 - 2.1.0-preview2-30192 - 2.1.0-preview2-30192 - 2.1.0-preview2-25711-01 - 2.1.0-preview2-30192 - 2.1.0-preview2-30192 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-26224-02 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 2.0.0 - 2.1.0-preview2-26130-04 + 2.1.0-preview2-26225-03 15.6.0 15.0.26606 15.6.161-preview @@ -42,8 +42,8 @@ 2.0.1 10.0.1 1.1.92 - 4.5.0-preview2-26130-01 - 4.5.0-preview2-26130-01 + 4.5.0-preview2-26224-02 + 4.5.0-preview2-26224-02 9.0.1 2.7.0-beta3-62512-06 2.7.0-beta3-62512-06 diff --git a/build/sources.props b/build/sources.props index b97c0c5cfb..02efac4549 100644 --- a/build/sources.props +++ b/build/sources.props @@ -1,10 +1,11 @@ - + $(DotNetRestoreSources) $(RestoreSources); + https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; https://dotnet.myget.org/F/msbuild/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2c1067648b..5ace9326ce 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15723 -commithash:f9bb4be59e39938ec59a6975257e26099b0d03c1 +version:2.1.0-preview2-15728 +commithash:393377068ddcf51dfee0536536d455f57a828b06 diff --git a/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs b/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs index a57b9e83a0..ce1b0791f2 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/CompilerHost.cs @@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var writer = ServerLogger.IsLoggingEnabled ? new StringWriter() : TextWriter.Null; - var checker = new DefaultExtensionDependencyChecker(Loader, writer); + var checker = new DefaultExtensionDependencyChecker(Loader, writer, writer); var app = new Application(cancellationToken, Loader, checker, AssemblyReferenceProvider) { Out = writer, diff --git a/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionDependencyChecker.cs b/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionDependencyChecker.cs index f5ce49abac..79d01afb9d 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionDependencyChecker.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/DefaultExtensionDependencyChecker.cs @@ -26,15 +26,18 @@ namespace Microsoft.AspNetCore.Razor.Tools private readonly ExtensionAssemblyLoader _loader; private readonly TextWriter _output; + private readonly TextWriter _error; private readonly string[] _ignoredAssemblies; public DefaultExtensionDependencyChecker( ExtensionAssemblyLoader loader, TextWriter output, + TextWriter error, string[] ignoredAssemblies = null) { _loader = loader; _output = output; + _error = error; _ignoredAssemblies = ignoredAssemblies ?? DefaultIgnoredAssemblies; } @@ -46,8 +49,8 @@ namespace Microsoft.AspNetCore.Razor.Tools } catch (Exception ex) { - _output.WriteLine("Exception performing Extension dependency check:"); - _output.WriteLine(ex.ToString()); + _error.WriteLine("Exception performing Extension dependency check:"); + _error.WriteLine(ex.ToString()); return false; } } @@ -64,7 +67,7 @@ namespace Microsoft.AspNetCore.Razor.Tools if (!Path.IsPathRooted(item.FilePath)) { - _output.WriteLine($"The file path '{item.FilePath}' is not a rooted path. File paths must be absolute and fully-qualified."); + _error.WriteLine($"The file path '{item.FilePath}' is not a rooted path. File paths must be absolute and fully-qualified."); return false; } @@ -83,7 +86,7 @@ namespace Microsoft.AspNetCore.Razor.Tools } // If we get here we can't resolve this assembly. This is an error. - _output.WriteLine($"Extension assembly '{item.Identity.Name}' depends on '{reference.ToString()} which is missing."); + _error.WriteLine($"Extension assembly '{item.Identity.Name}' depends on '{reference.ToString()} which is missing."); return false; } } @@ -110,7 +113,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var item = items[i]; if (item.Mvid != item.Assembly.ManifestModule.ModuleVersionId) { - _output.WriteLine($"Extension assembly '{item.Identity.Name}' at '{item.FilePath}' has a different ModuleVersionId than loaded assembly '{item.Assembly.FullName}'"); + _error.WriteLine($"Extension assembly '{item.Identity.Name}' at '{item.FilePath}' has a different ModuleVersionId than loaded assembly '{item.Assembly.FullName}'"); return false; } } diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Program.cs b/src/Microsoft.AspNetCore.Razor.Tools/Program.cs index 386a8837c5..27807cd23e 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Program.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/Program.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Razor.Tools // Prevent shadow copying. var loader = new DefaultExtensionAssemblyLoader(baseDirectory: null); - var checker = new DefaultExtensionDependencyChecker(loader, Console.Error); + var checker = new DefaultExtensionDependencyChecker(loader, Console.Out, Console.Error); var application = new Application( cancel.Token, diff --git a/src/Microsoft.AspNetCore.Razor.Tools/ShutdownCommand.cs b/src/Microsoft.AspNetCore.Razor.Tools/ShutdownCommand.cs index f77b30f5b2..3e0907774b 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/ShutdownCommand.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/ShutdownCommand.cs @@ -57,19 +57,21 @@ namespace Microsoft.AspNetCore.Razor.Tools var process = Process.GetProcessById(response.ServerProcessId); process.WaitForExit(); } - catch (Exception) + catch (Exception ex) { // There is an inherent race here with the server process. If it has already shutdown - // by the time we try to access it then the operation has succeed. + // by the time we try to access it then the operation has succeeded. + Error.Write(ex); } Out.Write("Server pid:{0} shut down", response.ServerProcessId); } } } - catch (Exception) when (IsServerRunning()) + catch (Exception ex) when (IsServerRunning()) { // Ignore an exception that occurred while the server was shutting down. + Error.Write(ex); } return 0; diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props index 8df8703baa..c9778644e2 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props @@ -59,9 +59,9 @@ Copyright (c) .NET Foundation. All rights reserved. false - false + true diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index 6dbdf8f49a..fbad5a3ff9 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -79,7 +79,7 @@ Copyright (c) .NET Foundation. All rights reserved. Default values for properties that affect Razor targets to the standard build lifecycle. --> - false + true diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs index 75cc832f72..53192cf8cf 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIncrementalismTest.cs @@ -10,8 +10,13 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class BuildIncrementalismTest : MSBuildIntegrationTestBase + public class BuildIncrementalismTest : MSBuildIntegrationTestBase, IClassFixture { + public BuildIncrementalismTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task BuildIncremental_SimpleMvc_PersistsTargetInputFile() @@ -20,7 +25,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests var thumbprintLookup = new Dictionary(); // Act 1 - var result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); var directoryPath = Path.Combine(result.Project.DirectoryPath, IntermediateOutputPath); var filesToIgnore = new[] @@ -45,7 +50,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests // We want to make sure nothing changed between multiple incremental builds. using (var razorGenDirectoryLock = LockDirectory(RazorIntermediateOutputPath)) { - result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true"); + result = await DotnetMSBuild("Build"); } Assert.BuildPassed(result); @@ -63,7 +68,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { // Act - 1 var expectedTagHelperCacheContent = @"""Name"":""SimpleMvc.SimpleTagHelper"""; - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); var file = Path.Combine(Project.DirectoryPath, "SimpleTagHelper.cs"); var tagHelperOutputCache = Path.Combine(IntermediateOutputPath, "SimpleMvc.TagHelpers.output.cache"); var generatedFile = Path.Combine(RazorIntermediateOutputPath, "Views", "Home", "Index.cs"); @@ -76,7 +81,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests // Act - 2 // Update the source content and build. We should expect the outputs to be regenerated. ReplaceContent(string.Empty, file); - result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + result = await DotnetMSBuild("Build"); // Assert - 2 Assert.BuildPassed(result); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs index ecfa3c0f77..b5a6f75bc8 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs @@ -12,23 +12,32 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class BuildIntegrationTest : MSBuildIntegrationTestBase + public class BuildIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { + public BuildIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] - public Task Build_SimpleMvc_UsingDotnetMSBuild_CanBuildSuccessfully() - => Build_SimpleMvc_CanBuildSuccessfully(MSBuildProcessKind.Dotnet); + public Task Build_SimpleMvc_UsingDotnetMSBuildAndWithoutBuildServer_CanBuildSuccessfully() + => Build_SimpleMvc_WithoutBuildServer_CanBuildSuccessfully(MSBuildProcessKind.Dotnet); [ConditionalFact] [OSSkipCondition(OperatingSystems.Linux)] [OSSkipCondition(OperatingSystems.MacOSX)] [InitializeTestProject("SimpleMvc")] - public Task Build_SimpleMvc_UsingDesktopMSBuild_CanBuildSuccessfully() - => Build_SimpleMvc_CanBuildSuccessfully(MSBuildProcessKind.Desktop); + public Task Build_SimpleMvc_UsingDesktopMSBuildAndWithoutBuildServer_CanBuildSuccessfully() + => Build_SimpleMvc_WithoutBuildServer_CanBuildSuccessfully(MSBuildProcessKind.Desktop); - private async Task Build_SimpleMvc_CanBuildSuccessfully(MSBuildProcessKind msBuildProcessKind) + // This test is identical to the ones in BuildServerIntegrationTest except this one explicitly disables the Razor build server. + private async Task Build_SimpleMvc_WithoutBuildServer_CanBuildSuccessfully(MSBuildProcessKind msBuildProcessKind) { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true", msBuildProcessKind: msBuildProcessKind); + var result = await DotnetMSBuild("Build", + "/p:UseRazorBuildServer=false", + suppressBuildServer: true, + msBuildProcessKind: msBuildProcessKind); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "SimpleMvc.dll"); @@ -50,7 +59,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { Directory.Delete(Path.Combine(Project.DirectoryPath, "Views"), recursive: true); - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "SimpleMvc.dll"); @@ -61,9 +70,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [Fact] [InitializeTestProject("SimpleMvc")] - public async Task Build_SimpleMvc_NoopsWithRazorCompileOnPublish() + public async Task Build_SimpleMvc_NoopsWithRazorCompileOnBuild_False() { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnPublish=true"); + var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=false"); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "SimpleMvc.dll"); @@ -79,7 +88,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests // Introducing a C# semantic error ReplaceContent("@{ var foo = \"\".Substring(\"bleh\"); }", "Views", "Home", "Index.cshtml"); - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); Assert.BuildFailed(result); @@ -95,7 +104,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimplePages")] public async Task Build_Works_WhenFilesAtDifferentPathsHaveSameNamespaceHierarchy() { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); Assert.BuildPassed(result); @@ -108,7 +117,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests public async Task Build_RazorOutputPath_SetToNonDefault() { var customOutputPath = Path.Combine("bin", Configuration, TargetFramework, "Razor"); - var result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true /p:RazorOutputPath={customOutputPath}"); + var result = await DotnetMSBuild("Build", $"/p:RazorOutputPath={customOutputPath}"); Assert.BuildPassed(result); @@ -124,7 +133,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests public async Task Build_MvcRazorOutputPath_SetToNonDefault() { var customOutputPath = Path.Combine("bin", Configuration, TargetFramework, "Razor"); - var result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true /p:MvcRazorOutputPath={customOutputPath}"); + var result = await DotnetMSBuild("Build", $"/p:MvcRazorOutputPath={customOutputPath}"); Assert.BuildPassed(result); @@ -139,7 +148,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Build_SkipsCopyingBinariesToOutputDirectory_IfCopyBuildOutputToOutputDirectory_IsUnset() { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true /p:CopyBuildOutputToOutputDirectory=false"); + var result = await DotnetMSBuild("Build", "/p:CopyBuildOutputToOutputDirectory=false"); Assert.BuildPassed(result); @@ -154,7 +163,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Build_SkipsCopyingBinariesToOutputDirectory_IfCopyOutputSymbolsToOutputDirectory_IsUnset() { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true /p:CopyOutputSymbolsToOutputDirectory=false"); + var result = await DotnetMSBuild("Build", "/p:CopyOutputSymbolsToOutputDirectory=false"); Assert.BuildPassed(result); @@ -168,7 +177,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Build_Works_WhenSymbolsAreNotGenerated() { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true /p:DebugType=none"); + var result = await DotnetMSBuild("Build", "/p:DebugType=none"); Assert.BuildPassed(result); @@ -184,7 +193,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("AppWithP2PReference", "ClassLibrary")] public async Task Build_WithP2P_CopiesRazorAssembly() { - var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); Assert.BuildPassed(result); @@ -211,7 +220,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests AddProjectFileContent(additionalProjectContent); Directory.CreateDirectory(Path.Combine(Project.DirectoryPath, "..", "LinkedDir")); - var result = await DotnetMSBuild("Build", "/t:_IntrospectRazorEmbeddedResources /p:RazorCompileOnBuild=true /p:EmbedRazorGenerateSources=true"); + var result = await DotnetMSBuild("Build", "/t:_IntrospectRazorEmbeddedResources /p:EmbedRazorGenerateSources=true"); Assert.BuildPassed(result); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntrospectionTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntrospectionTest.cs index 59e95d6805..0e6875ee22 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntrospectionTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntrospectionTest.cs @@ -7,13 +7,18 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class BuildIntrospectionTest : MSBuildIntegrationTestBase + public class BuildIntrospectionTest : MSBuildIntegrationTestBase, IClassFixture { + public BuildIntrospectionTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task RazorSdk_AddsCshtmlFilesToUpToDateCheckInput() { - var result = await DotnetMSBuild("_IntrospectUpToDateCheckInput", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("_IntrospectUpToDateCheckInput"); Assert.BuildPassed(result); Assert.BuildOutputContainsLine(result, $"UpToDateCheckInput: {Path.Combine("Views", "Home", "Index.cshtml")}"); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs index 4c54a0cb11..7ffbbc27e9 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs @@ -10,11 +10,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { public class BuildServerIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { - private readonly string _pipeName; - - public BuildServerIntegrationTest(BuildServerTestFixture fixture) + public BuildServerIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) { - _pipeName = fixture.PipeName; } [Fact] @@ -32,7 +30,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { var result = await DotnetMSBuild( "Build", - $"/p:RazorCompileOnBuild=true /p:UseRazorBuildServer=true /p:_RazorBuildServerPipeName={_pipeName} /p:_RazorForceBuildServer=true", + "/p:_RazorForceBuildServer=true", msBuildProcessKind: msBuildProcessKind); Assert.BuildPassed(result); @@ -59,7 +57,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { var result = await DotnetMSBuild( "Build", - $"/p:RazorCompileOnBuild=true /p:UseRazorBuildServer=true /p:_RazorBuildServerPipeName={_pipeName} /p:_RazorForceBuildServer=true"); + "/p:_RazorForceBuildServer=true"); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "SimpleMvc.dll"); @@ -74,7 +72,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { var result = await DotnetMSBuild( "Build", - $"/p:RazorCompileOnBuild=true /p:UseRazorBuildServer=true /p:_RazorBuildServerPipeName={_pipeName} /p:_RazorForceBuildServer=true"); + "/p:_RazorForceBuildServer=true"); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "Whitespace in name.dll"); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs index a628f5224a..7f3933c0da 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs @@ -31,16 +31,23 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests // Shutdown the build server. using (var cts = new CancellationTokenSource(_defaultShutdownTimeout)) { + var writer = new StringWriter(); + cts.Token.Register(() => { - throw new TimeoutException($"Shutting down the build server at pipe {PipeName} took longer than expected."); + var output = writer.ToString(); + throw new TimeoutException($"Shutting down the build server at pipe {PipeName} took longer than expected.{Environment.NewLine}Output: {output}."); }); - var application = new Application(cts.Token, Mock.Of(), Mock.Of(), (path, properties) => Mock.Of()); + var application = new Application(cts.Token, Mock.Of(), Mock.Of(), (path, properties) => Mock.Of()) + { + Out = writer, + Error = writer, + }; var exitCode = application.Execute("shutdown", "-w", "-p", PipeName); if (exitCode != 0) { - var output = application.Error.ToString(); + var output = writer.ToString(); throw new InvalidOperationException( $"Build server at pipe {PipeName} failed to shutdown with exit code {exitCode}. Output: {output}"); } diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ConfigurationMetadataIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ConfigurationMetadataIntegrationTest.cs index cbfafc5041..b4f81e102e 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ConfigurationMetadataIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ConfigurationMetadataIntegrationTest.cs @@ -7,13 +7,18 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class ConfigurationMetadataIntegrationTest : MSBuildIntegrationTestBase + public class ConfigurationMetadataIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { + public ConfigurationMetadataIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task Build_WithMvc_AddsConfigurationMetadata() { - var result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); Assert.BuildPassed(result); @@ -39,7 +44,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Build_WithGenerateRazorAssemblyInfo_False_SuppressesConfigurationMetadata() { - var result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true /p:GenerateRazorAssemblyInfo=false"); + var result = await DotnetMSBuild("Build", "/p:GenerateRazorAssemblyInfo=false"); Assert.BuildPassed(result); @@ -67,7 +72,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { TargetFramework = "netstandard2.0"; - var result = await DotnetMSBuild("Build", $"/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Build"); Assert.BuildPassed(result); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/DesignTimeBuildIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/DesignTimeBuildIntegrationTest.cs index ab55289280..9fd41950e7 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/DesignTimeBuildIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/DesignTimeBuildIntegrationTest.cs @@ -6,15 +6,20 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class DesignTimeBuildIntegrationTest : MSBuildIntegrationTestBase + public class DesignTimeBuildIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { + public DesignTimeBuildIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task DesignTimeBuild_DoesNotRunRazorTargets() { // Using Compile here instead of CompileDesignTime because the latter is only defined when using // the VS targets. This is a close enough simulation for an SDK project - var result = await DotnetMSBuild("Compile", "/p:RazorCompileOnBuild=true /p:DesignTimeBuild=true /clp:PerformanceSummary"); + var result = await DotnetMSBuild("Compile", "/p:DesignTimeBuild=true /clp:PerformanceSummary"); Assert.BuildPassed(result); Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.dll"); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildIntegrationTestBase.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildIntegrationTestBase.cs index 020887b57c..5247f1aca9 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildIntegrationTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildIntegrationTestBase.cs @@ -15,8 +15,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { private static readonly AsyncLocal _project = new AsyncLocal(); - protected MSBuildIntegrationTestBase() + protected MSBuildIntegrationTestBase(BuildServerTestFixture buildServer) { + BuildServer = buildServer; } #if DEBUG @@ -44,19 +45,35 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests protected string TargetFramework { get; set; } = "netcoreapp2.0"; + protected BuildServerTestFixture BuildServer { get; set; } + internal Task DotnetMSBuild( string target, string args = null, bool suppressRestore = false, bool suppressTimeout = false, + bool suppressBuildServer = false, MSBuildProcessKind msBuildProcessKind = MSBuildProcessKind.Dotnet) { var timeout = suppressTimeout ? (TimeSpan?)Timeout.InfiniteTimeSpan : null; - var restoreArgument = suppressRestore ? "" : "/restore"; + var buildArgumentList = new List(); + + if (!suppressRestore) + { + buildArgumentList.Add("/restore"); + } + + if (!suppressBuildServer) + { + buildArgumentList.Add($"/p:_RazorBuildServerPipeName={BuildServer.PipeName}"); + } + + buildArgumentList.Add($"/t:{target} /p:Configuration={Configuration} {args}"); + var buildArguments = string.Join(" ", buildArgumentList); return MSBuildProcessManager.RunProcessAsync( Project, - $"{restoreArgument} /t:{target} /p:Configuration={Configuration} {args}", + buildArguments, timeout, msBuildProcessKind); } diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs index 983e7ea629..d217a3b02d 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs @@ -8,14 +8,19 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class PackIntegrationTest : MSBuildIntegrationTestBase + public class PackIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { + public PackIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("ClassLibrary")] public async Task Pack_Works_IncludesRazorAssembly() { TargetFramework = "netstandard2.0"; - var result = await DotnetMSBuild("Pack", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Pack"); Assert.BuildPassed(result); @@ -85,7 +90,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests public async Task Pack_IncludesRazorFilesAsContent_WhenIncludeRazorContentInPack_IsSet() { TargetFramework = "netstandard2.0"; - var result = await DotnetMSBuild("Pack", "/p:RazorCompileOnBuild=true /p:IncludeRazorContentInPack=true"); + var result = await DotnetMSBuild("Pack", "/p:IncludeRazorContentInPack=true"); Assert.BuildPassed(result); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs index cab91e9f09..22407311fa 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs @@ -7,8 +7,13 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class PublishIntegrationTest : MSBuildIntegrationTestBase + public class PublishIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { + public PublishIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task Publish_RazorCompileOnPublish_IsDefault() @@ -17,9 +22,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.BuildPassed(result); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.dll"); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb"); - Assert.FileExists(result, PublishOutputPath, "SimpleMvc.dll"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.pdb"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.Views.dll"); @@ -32,9 +34,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [Fact] [InitializeTestProject("SimpleMvc")] - public async Task Publish_WithRazorCompileOnBuild_PublishesAssembly() + public async Task Publish_PublishesAssembly() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Publish"); Assert.BuildPassed(result); @@ -57,7 +59,26 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Publish_WithRazorCompileOnPublish_PublishesAssembly() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnPublish=true"); + var result = await DotnetMSBuild("Publish"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, PublishOutputPath, "SimpleMvc.dll"); + Assert.FileExists(result, PublishOutputPath, "SimpleMvc.pdb"); + Assert.FileExists(result, PublishOutputPath, "SimpleMvc.Views.dll"); + Assert.FileExists(result, PublishOutputPath, "SimpleMvc.Views.pdb"); + + // By default refs and .cshtml files will not be copied on publish + Assert.FileCountEquals(result, 0, Path.Combine(PublishOutputPath, "refs"), "*.dll"); + Assert.FileCountEquals(result, 0, Path.Combine(PublishOutputPath, "Views"), "*.cshtml"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Publish_WithRazorCompileOnBuildFalse_PublishesAssembly() + { + // RazorCompileOnBuild is turned off, but RazorCompileOnPublish should still be enabled + var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=false"); Assert.BuildPassed(result); @@ -96,9 +117,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.BuildPassed(result); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.dll"); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb"); - Assert.FileExists(result, PublishOutputPath, "SimpleMvc.dll"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.pdb"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.Views.dll"); @@ -115,7 +133,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { Directory.Delete(Path.Combine(Project.DirectoryPath, "Views"), recursive: true); - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Publish"); Assert.BuildPassed(result); @@ -162,7 +180,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Publish_SkipsCopyingBinariesToOutputDirectory_IfCopyBuildOutputToOutputDirectory_IsUnset() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=true /p:CopyBuildOutputToPublishDirectory=false"); + var result = await DotnetMSBuild("Publish", "/p:CopyBuildOutputToPublishDirectory=false"); Assert.BuildPassed(result); @@ -177,7 +195,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Publish_SkipsCopyingBinariesToOutputDirectory_IfCopyOutputSymbolsToOutputDirectory_IsUnset() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=true /p:CopyOutputSymbolsToPublishDirectory=false"); + var result = await DotnetMSBuild("Publish", "/p:CopyOutputSymbolsToPublishDirectory=false"); Assert.BuildPassed(result); @@ -191,7 +209,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Publish_Works_WhenSymbolsAreNotGenerated() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=true /p:DebugType=none"); + var result = await DotnetMSBuild("Publish", "/p:DebugType=none"); Assert.BuildPassed(result); @@ -207,13 +225,10 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Publish_IncludeCshtmlAndRefAssemblies_CopiesFiles() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnPublish=true /p:CopyRazorGenerateFilesToPublishDirectory=true /p:CopyRefAssembliesToPublishDirectory=true"); + var result = await DotnetMSBuild("Publish", "/p:CopyRazorGenerateFilesToPublishDirectory=true /p:CopyRefAssembliesToPublishDirectory=true"); Assert.BuildPassed(result); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.dll"); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb"); - Assert.FileExists(result, PublishOutputPath, "SimpleMvc.dll"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.pdb"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.Views.dll"); @@ -228,13 +243,10 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("SimpleMvc")] public async Task Publish_MvcRazorExcludeFilesFromPublish_False_CopiesFiles() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnPublish=true /p:MvcRazorExcludeViewFilesFromPublish=false /p:MvcRazorExcludeRefAssembliesFromPublish=false"); + var result = await DotnetMSBuild("Publish", "/p:MvcRazorExcludeViewFilesFromPublish=false /p:MvcRazorExcludeRefAssembliesFromPublish=false"); Assert.BuildPassed(result); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.dll"); - Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb"); - Assert.FileExists(result, PublishOutputPath, "SimpleMvc.dll"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.pdb"); Assert.FileExists(result, PublishOutputPath, "SimpleMvc.Views.dll"); @@ -249,7 +261,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("AppWithP2PReference", "ClassLibrary")] public async Task Publish_WithP2P_AndRazorCompileOnBuild_CopiesRazorAssembly() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnBuild=true"); + var result = await DotnetMSBuild("Publish"); Assert.BuildPassed(result); @@ -267,15 +279,10 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests [InitializeTestProject("AppWithP2PReference", "ClassLibrary")] public async Task Publish_WithP2P_AndRazorCompileOnPublish_CopiesRazorAssembly() { - var result = await DotnetMSBuild("Publish", "/p:RazorCompileOnPublish=true"); + var result = await DotnetMSBuild("Publish"); Assert.BuildPassed(result); - Assert.FileDoesNotExist(result, OutputPath, "AppWithP2PReference.Views.dll"); - Assert.FileDoesNotExist(result, OutputPath, "AppWithP2PReference.Views.pdb"); - Assert.FileDoesNotExist(result, OutputPath, "ClassLibrary.Views.dll"); - Assert.FileDoesNotExist(result, OutputPath, "ClassLibrary.Views.pdb"); - Assert.FileExists(result, PublishOutputPath, "AppWithP2PReference.dll"); Assert.FileExists(result, PublishOutputPath, "AppWithP2PReference.pdb"); Assert.FileExists(result, PublishOutputPath, "AppWithP2PReference.Views.dll"); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorCompileIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorCompileIntegrationTest.cs index 88f325c7f9..c375b99354 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorCompileIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorCompileIntegrationTest.cs @@ -9,8 +9,13 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class RazorCompileIntegrationTest : MSBuildIntegrationTestBase + public class RazorCompileIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { + public RazorCompileIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task RazorCompile_Success_CompilesAssembly() diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs index c5254cfe37..0834a37974 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs @@ -10,10 +10,15 @@ using Xunit; namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { - public class RazorGenerateIntegrationTest : MSBuildIntegrationTestBase + public class RazorGenerateIntegrationTest : MSBuildIntegrationTestBase, IClassFixture { private const string RazorGenerateTarget = "RazorGenerate"; + public RazorGenerateIntegrationTest(BuildServerTestFixture buildServer) + : base(buildServer) + { + } + [Fact] [InitializeTestProject("SimpleMvc")] public async Task RazorGenerate_Success_GeneratesFilesOnDisk() diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/xunit.runner.json b/test/Microsoft.AspNetCore.Razor.Design.Test/xunit.runner.json index fcf172c8fc..d00e4ae907 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/xunit.runner.json +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/xunit.runner.json @@ -1,4 +1,5 @@ { "methodDisplay": "method", - "shadowCopy": false + "shadowCopy": false, + "maxParallelThreads": -1 } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionDependencyCheckerTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionDependencyCheckerTest.cs index 72d719fdc8..b9b9c8ac11 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionDependencyCheckerTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/DefaultExtensionDependencyCheckerTest.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var alphaFilePath = LoaderTestResources.Alpha.WriteToFile(directory.DirectoryPath, "Alpha.dll"); var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); - var checker = new DefaultExtensionDependencyChecker(loader, output); + var checker = new DefaultExtensionDependencyChecker(loader, output, output); // Act var result = checker.Check(new[] { alphaFilePath, }); @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var deltaFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); - var checker = new DefaultExtensionDependencyChecker(loader, output); + var checker = new DefaultExtensionDependencyChecker(loader, output, output); // Act var result = checker.Check(new[] { alphaFilePath, betaFilePath, gammaFilePath, deltaFilePath, }); @@ -70,7 +70,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var deltaFilePath = LoaderTestResources.Delta.WriteToFile(directory.DirectoryPath, "Delta.dll"); var loader = new TestDefaultExtensionAssemblyLoader(Path.Combine(directory.DirectoryPath, "shadow")); - var checker = new DefaultExtensionDependencyChecker(loader, output); + var checker = new DefaultExtensionDependencyChecker(loader, output, output); // This will cause the loader to cache some inconsistent information. loader.LoadFromPath(alphaFilePath); @@ -98,7 +98,7 @@ namespace Microsoft.AspNetCore.Razor.Tools loader .Setup(l => l.LoadFromPath(It.IsAny())) .Throws(new InvalidOperationException()); - var checker = new DefaultExtensionDependencyChecker(loader.Object, output); + var checker = new DefaultExtensionDependencyChecker(loader.Object, output, output); // Act var result = checker.Check(new[] { deltaFilePath, }); diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs index e8b30514f9..d6494d1d37 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/Infrastructure/ServerUtilities.cs @@ -26,7 +26,8 @@ namespace Microsoft.AspNetCore.Razor.Tools internal static ServerData CreateServer( string pipeName = null, CompilerHost compilerHost = null, - ConnectionHost connectionHost = null) + ConnectionHost connectionHost = null, + Action onListening = null) { pipeName = pipeName ?? Guid.NewGuid().ToString(); compilerHost = compilerHost ?? CompilerHost.Create(); @@ -40,6 +41,10 @@ namespace Microsoft.AspNetCore.Razor.Tools { var eventBus = new TestableEventBus(); eventBus.Listening += (sender, e) => { serverListenSource.TrySetResult(true); }; + if (onListening != null) + { + eventBus.Listening += (sender, e) => onListening(sender, e); + } try { RunServer( diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs index 3f415fe509..f91fbc5fdd 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs @@ -116,17 +116,19 @@ namespace Microsoft.AspNetCore.Razor.Tools /// A shutdown request should not abort an existing compilation. It should be allowed to run to /// completion. /// - // Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991 - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + [Fact] public async Task ServerRunning_ShutdownRequest_DoesNotAbortCompilation() { // Arrange - var completionSource = new TaskCompletionSource(); + var startCompilationSource = new TaskCompletionSource(); + var finishCompilationSource = new TaskCompletionSource(); var host = CreateCompilerHost(c => c.ExecuteFunc = (req, ct) => { + // At this point, the connection has been accepted and the compilation has started. + startCompilationSource.SetResult(true); + // We want this to keep running even after the shutdown is seen. - completionSource.Task.Wait(); + finishCompilationSource.Task.Wait(); return EmptyServerResponse; }); @@ -134,13 +136,16 @@ namespace Microsoft.AspNetCore.Razor.Tools { var compileTask = ServerUtilities.Send(serverData.PipeName, EmptyServerRequest); + // Wait for the request to go through and trigger compilation. + await startCompilationSource.Task; + // Act // The compilation is now in progress, send the shutdown. await ServerUtilities.SendShutdown(serverData.PipeName); Assert.False(compileTask.IsCompleted); // Now let the task complete. - completionSource.SetResult(true); + finishCompilationSource.SetResult(true); // Assert var response = await compileTask; @@ -154,17 +159,19 @@ namespace Microsoft.AspNetCore.Razor.Tools /// /// Multiple clients should be able to send shutdown requests to the server. /// - // Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991 - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + [Fact] public async Task ServerRunning_MultipleShutdownRequests_HandlesSuccessfully() { // Arrange - var completionSource = new TaskCompletionSource(); + var startCompilationSource = new TaskCompletionSource(); + var finishCompilationSource = new TaskCompletionSource(); var host = CreateCompilerHost(c => c.ExecuteFunc = (req, ct) => { + // At this point, the connection has been accepted and the compilation has started. + startCompilationSource.SetResult(true); + // We want this to keep running even after the shutdown is seen. - completionSource.Task.Wait(); + finishCompilationSource.Task.Wait(); return EmptyServerResponse; }); @@ -172,6 +179,9 @@ namespace Microsoft.AspNetCore.Razor.Tools { var compileTask = ServerUtilities.Send(serverData.PipeName, EmptyServerRequest); + // Wait for the request to go through and trigger compilation. + await startCompilationSource.Task; + // Act for (var i = 0; i < 10; i++) { @@ -182,7 +192,7 @@ namespace Microsoft.AspNetCore.Razor.Tools } // Now let the task complete. - completionSource.SetResult(true); + finishCompilationSource.SetResult(true); // Assert var response = await compileTask; @@ -193,7 +203,7 @@ namespace Microsoft.AspNetCore.Razor.Tools } } - // Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991 + // https://github.com/aspnet/Razor/issues/1991 [ConditionalFact] [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] public async Task ServerRunning_CancelCompilation_CancelsSuccessfully() @@ -213,18 +223,28 @@ namespace Microsoft.AspNetCore.Razor.Tools return new RejectedServerResponse(); }); - using (var serverData = ServerUtilities.CreateServer(compilerHost: host)) + var semaphore = new SemaphoreSlim(1); + Action onListening = (s, e) => { - var tasks = new List>(); + semaphore.Release(); + }; + using (var serverData = ServerUtilities.CreateServer(compilerHost: host, onListening: onListening)) + { + // Send all the requests. + var clients = new List(); for (var i = 0; i < requestCount; i++) { - var task = ServerUtilities.Send(serverData.PipeName, EmptyServerRequest); - tasks.Add(task); + // Wait for the server to start listening. + await semaphore.WaitAsync(TimeSpan.FromMinutes(1)); + + var client = await Client.ConnectAsync(serverData.PipeName, timeout: null, cancellationToken: default); + await EmptyServerRequest.WriteAsync(client.Stream); + clients.Add(client); } // Act // Wait until all of the connections are being processed by the server. - completionSource.Task.Wait(); + await completionSource.Task; // Now cancel var stats = await serverData.CancelAndCompleteAsync(); @@ -233,10 +253,13 @@ namespace Microsoft.AspNetCore.Razor.Tools Assert.Equal(requestCount, stats.Connections); Assert.Equal(requestCount, count); - foreach (var task in tasks) + // Read the server response to each client. + foreach (var client in clients) { + var task = ServerResponse.ReadAsync(client.Stream); // We expect this to throw because the stream is already closed. - await Assert.ThrowsAsync(() => task); + await Assert.ThrowsAnyAsync(() => task); + client.Dispose(); } } } diff --git a/version.props b/version.props index 68a44892f6..5965a8e4d2 100644 --- a/version.props +++ b/version.props @@ -5,7 +5,8 @@ $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 - $(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) + a- + $(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) $(VersionSuffix)-$(BuildNumber) 99999