Normalize the tool assembly path before using it as the base for pipe name

This commit is contained in:
Ajay Bhargav Baaskaran 2018-03-29 12:28:27 -07:00
parent 03938dfd95
commit a2a920dde5
4 changed files with 30 additions and 7 deletions

View File

@ -122,7 +122,7 @@ namespace Microsoft.AspNetCore.Razor.Tasks
Log.LogMessage(StandardOutputLoggingImportance, $"ServerResponseFile = '{responseFileCommands}'"); Log.LogMessage(StandardOutputLoggingImportance, $"ServerResponseFile = '{responseFileCommands}'");
// The server contains the tools for discovering tag helpers and generating Razor code. // The server contains the tools for discovering tag helpers and generating Razor code.
var clientDir = Path.GetDirectoryName(ToolAssembly); var clientDir = Path.GetFullPath(Path.GetDirectoryName(ToolAssembly));
var workingDir = CurrentDirectoryToUse(); var workingDir = CurrentDirectoryToUse();
var tempDir = ServerConnection.GetTempPath(workingDir); var tempDir = ServerConnection.GetTempPath(workingDir);
var serverPaths = new ServerPaths( var serverPaths = new ServerPaths(

View File

@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Razor.Tools
Error.Write(ex); Error.Write(ex);
} }
Out.Write("Server pid:{0} shut down", response.ServerProcessId); Out.Write("Server pid:{0} shut down completed.", response.ServerProcessId);
} }
} }
} }

View File

@ -2,9 +2,13 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO; using System.IO;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Tools;
using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.CodeAnalysis;
using Moq;
using Xunit; using Xunit;
namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
@ -133,5 +137,27 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
// Note: We don't need to handle server clean up here because it will fail before // Note: We don't need to handle server clean up here because it will fail before
// it reaches server creation part. // it reaches server creation part.
} }
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task ManualServerShutdown_NoPipeName_ShutsDownServer()
{
var toolAssembly = typeof(Application).Assembly.Location;
var result = await DotnetMSBuild(
"Build",
$"/p:_RazorForceBuildServer=true /p:_RazorToolAssembly={toolAssembly}",
suppressBuildServer: true); // We don't want to specify a pipe name
Assert.BuildPassed(result);
// Shutdown the server
var output = new StringWriter();
var error = new StringWriter();
var application = new Application(CancellationToken.None, Mock.Of<ExtensionAssemblyLoader>(), Mock.Of<ExtensionDependencyChecker>(), (path, properties) => Mock.Of<PortableExecutableReference>(), output, error);
var exitCode = application.Execute("shutdown", "-w");
Assert.Equal(0, exitCode);
Assert.Contains("shut down completed", output.ToString());
}
} }
} }

View File

@ -39,11 +39,8 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
throw new TimeoutException($"Shutting down the build server at pipe {PipeName} took longer than expected.{Environment.NewLine}Output: {output}."); 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<ExtensionAssemblyLoader>(), Mock.Of<ExtensionDependencyChecker>(), (path, properties) => Mock.Of<PortableExecutableReference>()) var application = new Application(cts.Token, Mock.Of<ExtensionAssemblyLoader>(), Mock.Of<ExtensionDependencyChecker>(), (path, properties) => Mock.Of<PortableExecutableReference>(), writer, writer);
{
Out = writer,
Error = writer,
};
var exitCode = application.Execute("shutdown", "-w", "-p", PipeName); var exitCode = application.Execute("shutdown", "-w", "-p", PipeName);
if (exitCode != 0) if (exitCode != 0)
{ {