diff --git a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets
index d3097b285b..aeb778b6c1 100644
--- a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets
+++ b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets
@@ -13,9 +13,6 @@
<_RazorTagHelperInputCache>$(IntermediateOutputPath)$(TargetName).TagHelpers.input.cache
<_RazorTagHelperOutputCache>$(IntermediateOutputPath)$(TargetName).TagHelpers.output.cache
-
- <_RazorToolAssembly>$(_RazorMSBuildRoot)tools\rzc.dll
-
<_RazorGenerateInputsHash>
<_RazorGenerateInputsHashFile>$(IntermediateOutputPath)$(MSBuildProjectName).RazorCoreGenerate.cache
@@ -74,6 +71,7 @@
DebugTool="$(_RazorDebugTagHelperTool)"
ToolAssembly="$(_RazorToolAssembly)"
UseServer="$(UseRazorBuildServer)"
+ PipeName="$(_RazorBuildServerPipeName)"
Assemblies="@(RazorReferencePath)"
ProjectRoot="$(MSBuildProjectDirectory)"
TagHelperManifest="$(_RazorTagHelperOutputCache)">
@@ -116,6 +114,7 @@
DebugTool="$(_RazorDebugGenerateCodeTool)"
ToolAssembly="$(_RazorToolAssembly)"
UseServer="$(UseRazorBuildServer)"
+ PipeName="$(_RazorBuildServerPipeName)"
Sources="@(RazorGenerate)"
ProjectRoot="$(MSBuildProjectDirectory)"
TagHelperManifest="$(_RazorTagHelperOutputCache)"
diff --git a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.props b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.props
index f0e4fbd5ad..52e4eaaee4 100644
--- a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.props
+++ b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.props
@@ -20,6 +20,9 @@
<_RazorTaskFolder Condition=" '$(MSBuildRuntimeType)' != 'Core' ">net46
<_RazorTaskAssembly Condition="'$(_RazorTaskAssembly)'==''">$(_RazorMSBuildRoot)\tasks\$(_RazorTaskFolder)\Microsoft.AspNetCore.Razor.Tasks.dll
+
+
+ <_RazorToolAssembly Condition="'$(_RazorToolAssembly)'==''">$(_RazorMSBuildRoot)tools\rzc.dll
diff --git a/src/Microsoft.AspNetCore.Razor.Sdk/build/netstandard2.0/Razor.Sdk.CurrentVersion.props b/src/Microsoft.AspNetCore.Razor.Sdk/build/netstandard2.0/Razor.Sdk.CurrentVersion.props
index 5a48657084..8ced51abdf 100644
--- a/src/Microsoft.AspNetCore.Razor.Sdk/build/netstandard2.0/Razor.Sdk.CurrentVersion.props
+++ b/src/Microsoft.AspNetCore.Razor.Sdk/build/netstandard2.0/Razor.Sdk.CurrentVersion.props
@@ -38,6 +38,8 @@ Copyright (c) .NET Foundation. All rights reserved.
or publish-time. By default, the Razor SDK will suppress the copying of reference assemblies to the publish directory.
-->
false
+
+ false
diff --git a/src/Microsoft.AspNetCore.Razor.Sdk/build/netstandard2.0/Razor.Sdk.CurrentVersion.targets b/src/Microsoft.AspNetCore.Razor.Sdk/build/netstandard2.0/Razor.Sdk.CurrentVersion.targets
index ce6fff4b20..02cabafedb 100644
--- a/src/Microsoft.AspNetCore.Razor.Sdk/build/netstandard2.0/Razor.Sdk.CurrentVersion.targets
+++ b/src/Microsoft.AspNetCore.Razor.Sdk/build/netstandard2.0/Razor.Sdk.CurrentVersion.targets
@@ -72,8 +72,6 @@ Copyright (c) .NET Foundation. All rights reserved.
true
-
- false
+
+
+
+ $(ProjectRuntimeConfigFileName)
+ PreserveNewest
+
+
+
diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Razor.Tools/Properties/AssemblyInfo.cs
index 96dc897437..91b536e78b 100644
--- a/src/Microsoft.AspNetCore.Razor.Tools/Properties/AssemblyInfo.cs
+++ b/src/Microsoft.AspNetCore.Razor.Tools/Properties/AssemblyInfo.cs
@@ -4,5 +4,6 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Tools.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
+[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Design.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
diff --git a/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerConnection.cs b/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerConnection.cs
index aec7e72be9..9b548e9854 100644
--- a/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerConnection.cs
+++ b/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerConnection.cs
@@ -83,12 +83,16 @@ namespace Microsoft.AspNetCore.Razor.Tools
}
public static Task RunOnServer(
+ string pipeName,
List arguments,
ServerPaths buildPaths,
CancellationToken cancellationToken,
string keepAlive = null)
{
- var pipeName = PipeName.ComputeDefault();
+ if (string.IsNullOrEmpty(pipeName))
+ {
+ pipeName = PipeName.ComputeDefault();
+ }
return RunOnServerCore(
arguments,
@@ -244,7 +248,8 @@ namespace Microsoft.AspNetCore.Razor.Tools
}
}
- private static bool TryCreateServerCore(string clientDir, string pipeName)
+ // Internal for testing.
+ internal static bool TryCreateServerCore(string clientDir, string pipeName)
{
string expectedPath;
string processArguments;
diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/BuildVariables.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/BuildVariables.cs
index 6efdf63efc..cb8b132417 100644
--- a/test/Microsoft.AspNetCore.Razor.Design.Test/BuildVariables.cs
+++ b/test/Microsoft.AspNetCore.Razor.Design.Test/BuildVariables.cs
@@ -5,7 +5,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
{
internal static partial class BuildVariables
{
- private static string _msBuildPath = "";
+ private static string _msBuildPath = string.Empty;
static partial void InitializeVariables();
diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs
new file mode 100644
index 0000000000..bdd33ec72b
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerIntegrationTest.cs
@@ -0,0 +1,39 @@
+// 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.IO;
+using System.Threading.Tasks;
+using Microsoft.DotNet.PlatformAbstractions;
+using Xunit;
+
+namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
+{
+ public class BuildServerIntegrationTest : MSBuildIntegrationTestBase, IClassFixture
+ {
+ private readonly string _pipeName;
+
+ public BuildServerIntegrationTest(BuildServerTestFixture fixture)
+ {
+ _pipeName = fixture.PipeName;
+ }
+
+ [Fact]
+ [InitializeTestProject("SimpleMvc")]
+ public Task Build_SimpleMvc_WithServer_UsingDotnetMSBuild_CanBuildSuccessfully()
+ => Build_SimpleMvc_CanBuildSuccessfully(MSBuildProcessKind.Dotnet);
+
+ private async Task Build_SimpleMvc_CanBuildSuccessfully(MSBuildProcessKind msBuildProcessKind)
+ {
+ var result = await DotnetMSBuild(
+ "Build",
+ $"/p:RazorCompileOnBuild=true /p:UseRazorBuildServer=true /p:_RazorBuildServerPipeName={_pipeName}",
+ msBuildProcessKind: msBuildProcessKind);
+
+ Assert.BuildPassed(result);
+ Assert.FileExists(result, OutputPath, "SimpleMvc.dll");
+ Assert.FileExists(result, OutputPath, "SimpleMvc.pdb");
+ Assert.FileExists(result, OutputPath, "SimpleMvc.PrecompiledViews.dll");
+ Assert.FileExists(result, OutputPath, "SimpleMvc.PrecompiledViews.pdb");
+ }
+ }
+}
diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs
new file mode 100644
index 0000000000..f63de011a4
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs
@@ -0,0 +1,61 @@
+// 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;
+using System.IO;
+using System.Threading;
+using Microsoft.AspNetCore.Razor.Tools;
+
+namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
+{
+ public class BuildServerTestFixture : IDisposable
+ {
+ private static readonly TimeSpan _defaultShutdownTimeout = TimeSpan.FromSeconds(60);
+
+ public BuildServerTestFixture()
+ {
+ PipeName = Guid.NewGuid().ToString();
+
+ if (!ServerConnection.TryCreateServerCore(Environment.CurrentDirectory, PipeName))
+ {
+ throw new InvalidOperationException($"Failed to start the build server at pipe {PipeName}.");
+ }
+ }
+
+ public string PipeName { get; }
+
+ public void Dispose()
+ {
+ // Shutdown the build server.
+ using (var cts = new CancellationTokenSource(_defaultShutdownTimeout))
+ {
+ cts.Token.Register(() =>
+ {
+ throw new TimeoutException($"Shutting down the build server at pipe {PipeName} took longer than expected.");
+ });
+
+ var application = new Application(cts.Token);
+ var exitCode = application.Execute("shutdown", "-w", "-p", PipeName);
+ if (exitCode != 0)
+ {
+ var output = application.Error.ToString();
+ throw new InvalidOperationException(
+ $"Build server at pipe {PipeName} failed to shutdown with exit code {exitCode}. Output: {output}");
+ }
+ }
+ }
+
+ private static string RecursiveFind(string path, string start)
+ {
+ var test = Path.Combine(start, path);
+ if (File.Exists(test))
+ {
+ return start;
+ }
+ else
+ {
+ return RecursiveFind(path, new DirectoryInfo(start).Parent.FullName);
+ }
+ }
+ }
+}
diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildProcessKind.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildProcessKind.cs
index dab7e73fee..d9077e7a93 100644
--- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildProcessKind.cs
+++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildProcessKind.cs
@@ -1,12 +1,6 @@
// 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;
-using System.Diagnostics;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-
namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
{
internal enum MSBuildProcessKind
diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildProcessManager.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildProcessManager.cs
index dc9179e72c..b396ea8da5 100644
--- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildProcessManager.cs
+++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/MSBuildProcessManager.cs
@@ -49,9 +49,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
StartInfo = processStartInfo,
EnableRaisingEvents = true,
};
-
+
var output = new StringBuilder();
-
+
process.ErrorDataReceived += Process_ErrorDataReceived;
process.OutputDataReceived += Process_OutputDataReceived;
diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs
index c00b317007..97a4615546 100644
--- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs
+++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs
@@ -3,7 +3,6 @@
using System;
using System.IO;
-using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Testing.xunit;
using Xunit;
diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/Microsoft.AspNetCore.Razor.Design.Test.csproj b/test/Microsoft.AspNetCore.Razor.Design.Test/Microsoft.AspNetCore.Razor.Design.Test.csproj
index 2707dc5013..4e8c1104ee 100644
--- a/test/Microsoft.AspNetCore.Razor.Design.Test/Microsoft.AspNetCore.Razor.Design.Test.csproj
+++ b/test/Microsoft.AspNetCore.Razor.Design.Test/Microsoft.AspNetCore.Razor.Design.Test.csproj
@@ -42,12 +42,11 @@
false
+
-
+
diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs
index b9969d392b..0885516fdb 100644
--- a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs
+++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs
@@ -155,7 +155,10 @@ namespace Microsoft.AspNetCore.Razor.Tools
///
/// Multiple clients should be able to send shutdown requests to the server.
///
- [Fact]
+ // Skipping temporarily on non-windows. https://github.com/aspnet/Razor/issues/1991
+ [ConditionalFact]
+ [OSSkipCondition(OperatingSystems.Linux)]
+ [OSSkipCondition(OperatingSystems.MacOSX)]
public async Task ServerRunning_MultipleShutdownRequests_HandlesSuccessfully()
{
// Arrange