Use tool assembly path for computing default pipe name
This commit is contained in:
parent
adc7184d98
commit
7bc54b99e0
|
|
@ -23,11 +23,18 @@ namespace Microsoft.AspNetCore.Razor.Tools
|
||||||
//
|
//
|
||||||
// This is similar to (and based on) the code used by Roslyn in VBCSCompiler:
|
// This is similar to (and based on) the code used by Roslyn in VBCSCompiler:
|
||||||
// https://github.com/dotnet/roslyn/blob/c273b6a9f19570a344c274ae89185b3a2b64d93d/src/Compilers/Shared/BuildServerConnection.cs#L528
|
// https://github.com/dotnet/roslyn/blob/c273b6a9f19570a344c274ae89185b3a2b64d93d/src/Compilers/Shared/BuildServerConnection.cs#L528
|
||||||
public static string ComputeDefault()
|
public static string ComputeDefault(string toolDirectory = null)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(toolDirectory))
|
||||||
|
{
|
||||||
|
// This can be null in cases where we don't have a way of knowing the tool assembly path like when someone manually
|
||||||
|
// invokes the cli tool without passing in a pipe name as argument.
|
||||||
|
toolDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
// Include a prefix so we can't conflict with VBCSCompiler if we somehow end up in the same directory.
|
// Include a prefix so we can't conflict with VBCSCompiler if we somehow end up in the same directory.
|
||||||
// That would be a pretty wacky bug to try and unravel.
|
// That would be a pretty wacky bug to try and unravel.
|
||||||
var baseName = ComputeBaseName("Razor:" + AppDomain.CurrentDomain.BaseDirectory);
|
var baseName = ComputeBaseName("Razor:" + toolDirectory);
|
||||||
|
|
||||||
// Prefix with username and elevation
|
// Prefix with username and elevation
|
||||||
var isAdmin = false;
|
var isAdmin = false;
|
||||||
|
|
|
||||||
|
|
@ -83,19 +83,19 @@ namespace Microsoft.AspNetCore.Razor.Tools
|
||||||
public static Task<ServerResponse> RunOnServer(
|
public static Task<ServerResponse> RunOnServer(
|
||||||
string pipeName,
|
string pipeName,
|
||||||
IList<string> arguments,
|
IList<string> arguments,
|
||||||
ServerPaths buildPaths,
|
ServerPaths serverPaths,
|
||||||
CancellationToken cancellationToken,
|
CancellationToken cancellationToken,
|
||||||
string keepAlive = null,
|
string keepAlive = null,
|
||||||
bool debug = false)
|
bool debug = false)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(pipeName))
|
if (string.IsNullOrEmpty(pipeName))
|
||||||
{
|
{
|
||||||
pipeName = PipeName.ComputeDefault();
|
pipeName = PipeName.ComputeDefault(serverPaths.ClientDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RunOnServerCore(
|
return RunOnServerCore(
|
||||||
arguments,
|
arguments,
|
||||||
buildPaths,
|
serverPaths,
|
||||||
pipeName: pipeName,
|
pipeName: pipeName,
|
||||||
keepAlive: keepAlive,
|
keepAlive: keepAlive,
|
||||||
timeoutOverride: null,
|
timeoutOverride: null,
|
||||||
|
|
@ -106,7 +106,7 @@ namespace Microsoft.AspNetCore.Razor.Tools
|
||||||
|
|
||||||
private static async Task<ServerResponse> RunOnServerCore(
|
private static async Task<ServerResponse> RunOnServerCore(
|
||||||
IList<string> arguments,
|
IList<string> arguments,
|
||||||
ServerPaths buildPaths,
|
ServerPaths serverPaths,
|
||||||
string pipeName,
|
string pipeName,
|
||||||
string keepAlive,
|
string keepAlive,
|
||||||
int? timeoutOverride,
|
int? timeoutOverride,
|
||||||
|
|
@ -119,12 +119,12 @@ namespace Microsoft.AspNetCore.Razor.Tools
|
||||||
return new RejectedServerResponse();
|
return new RejectedServerResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buildPaths.TempDirectory == null)
|
if (serverPaths.TempDirectory == null)
|
||||||
{
|
{
|
||||||
return new RejectedServerResponse();
|
return new RejectedServerResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
var clientDir = buildPaths.ClientDirectory;
|
var clientDir = serverPaths.ClientDirectory;
|
||||||
var timeoutNewProcess = timeoutOverride ?? TimeOutMsNewProcess;
|
var timeoutNewProcess = timeoutOverride ?? TimeOutMsNewProcess;
|
||||||
var timeoutExistingProcess = timeoutOverride ?? TimeOutMsExistingProcess;
|
var timeoutExistingProcess = timeoutOverride ?? TimeOutMsExistingProcess;
|
||||||
var clientMutexName = MutexName.GetClientMutexName(pipeName);
|
var clientMutexName = MutexName.GetClientMutexName(pipeName);
|
||||||
|
|
@ -175,8 +175,8 @@ namespace Microsoft.AspNetCore.Razor.Tools
|
||||||
if (client != null)
|
if (client != null)
|
||||||
{
|
{
|
||||||
var request = ServerRequest.Create(
|
var request = ServerRequest.Create(
|
||||||
buildPaths.WorkingDirectory,
|
serverPaths.WorkingDirectory,
|
||||||
buildPaths.TempDirectory,
|
serverPaths.TempDirectory,
|
||||||
arguments,
|
arguments,
|
||||||
keepAlive);
|
keepAlive);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue