fixes #2408 stop using corehost to activate projectdependencycommands
This commit is contained in:
parent
48b3b02d3c
commit
64508f08ab
3 changed files with 15 additions and 45 deletions
|
@ -232,7 +232,6 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
sharedHostInstallerDownloadFile).Wait();
|
||||
|
||||
File.Copy(sharedHostInstallerDownloadFile, sharedHostInstallerDestinationFile, true);
|
||||
|
||||
}
|
||||
|
||||
return c.Success();
|
||||
|
|
|
@ -36,15 +36,12 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
return null;
|
||||
}
|
||||
|
||||
var isPortable = IsPortableApp(commandPath, runtimeConfigPath);
|
||||
|
||||
return CreateCommandSpecWrappingWithCorehostIfDll(
|
||||
return CreateCommandSpecWrappingWithMuxerIfDll(
|
||||
commandPath,
|
||||
commandArguments,
|
||||
depsFilePath,
|
||||
commandResolutionStrategy,
|
||||
nugetPackagesRoot,
|
||||
isPortable,
|
||||
runtimeConfigPath);
|
||||
}
|
||||
|
||||
|
@ -58,46 +55,41 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
return filePath;
|
||||
}
|
||||
|
||||
private CommandSpec CreateCommandSpecWrappingWithCorehostIfDll(
|
||||
private CommandSpec CreateCommandSpecWrappingWithMuxerIfDll(
|
||||
string commandPath,
|
||||
IEnumerable<string> commandArguments,
|
||||
string depsFilePath,
|
||||
CommandResolutionStrategy commandResolutionStrategy,
|
||||
string nugetPackagesRoot,
|
||||
bool isPortable,
|
||||
string runtimeConfigPath)
|
||||
{
|
||||
var commandExtension = Path.GetExtension(commandPath);
|
||||
|
||||
if (commandExtension == FileNameSuffixes.DotNet.DynamicLib)
|
||||
{
|
||||
return CreatePackageCommandSpecUsingCorehost(
|
||||
return CreatePackageCommandSpecUsingMuxer(
|
||||
commandPath,
|
||||
commandArguments,
|
||||
depsFilePath,
|
||||
commandResolutionStrategy,
|
||||
nugetPackagesRoot,
|
||||
isPortable,
|
||||
runtimeConfigPath);
|
||||
}
|
||||
|
||||
return CreateCommandSpec(commandPath, commandArguments, commandResolutionStrategy);
|
||||
}
|
||||
|
||||
private CommandSpec CreatePackageCommandSpecUsingCorehost(
|
||||
private CommandSpec CreatePackageCommandSpecUsingMuxer(
|
||||
string commandPath,
|
||||
IEnumerable<string> commandArguments,
|
||||
string depsFilePath,
|
||||
CommandResolutionStrategy commandResolutionStrategy,
|
||||
string nugetPackagesRoot,
|
||||
bool isPortable,
|
||||
string runtimeConfigPath)
|
||||
{
|
||||
var host = string.Empty;
|
||||
var arguments = new List<string>();
|
||||
|
||||
if (isPortable)
|
||||
{
|
||||
var muxer = new Muxer();
|
||||
|
||||
host = muxer.MuxerPath;
|
||||
|
@ -107,16 +99,13 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
}
|
||||
|
||||
arguments.Add("exec");
|
||||
}
|
||||
else
|
||||
{
|
||||
host = CoreHost.HostExePath;
|
||||
}
|
||||
|
||||
if (runtimeConfigPath != null)
|
||||
{
|
||||
arguments.Add("--runtimeconfig");
|
||||
arguments.Add(runtimeConfigPath);
|
||||
}
|
||||
|
||||
if (depsFilePath != null)
|
||||
{
|
||||
arguments.Add("--depsfile");
|
||||
|
@ -141,23 +130,5 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
return new CommandSpec(commandPath, escapedArgs, commandResolutionStrategy);
|
||||
}
|
||||
|
||||
private bool IsPortableApp(string commandPath, string runtimeConfigPath)
|
||||
{
|
||||
var commandDir = Path.GetDirectoryName(commandPath);
|
||||
|
||||
runtimeConfigPath = string.IsNullOrEmpty(runtimeConfigPath)
|
||||
? Directory.EnumerateFiles(commandDir).FirstOrDefault(x => x.EndsWith("runtimeconfig.json"))
|
||||
: runtimeConfigPath;
|
||||
|
||||
if (runtimeConfigPath == null || !File.Exists(runtimeConfigPath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var runtimeConfig = new RuntimeConfig(runtimeConfigPath);
|
||||
|
||||
return runtimeConfig.IsPortable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void It_returns_a_CommandSpec_with_CoreHost_as_FileName_and_CommandName_in_Args_when_CommandName_exists_in_ProjectDependencies()
|
||||
public void It_returns_a_CommandSpec_with_Dotnet_as_FileName_and_CommandName_in_Args_when_CommandName_exists_in_ProjectDependencies()
|
||||
{
|
||||
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
||||
|
||||
|
@ -133,7 +133,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
|||
|
||||
var commandFile = Path.GetFileNameWithoutExtension(result.Path);
|
||||
|
||||
commandFile.Should().Be("corehost");
|
||||
commandFile.Should().Be("dotnet");
|
||||
|
||||
result.Args.Should().Contain(commandResolverArguments.CommandName);
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void It_passes_depsfile_arg_to_corehost_when_returning_a_commandspec()
|
||||
public void It_passes_depsfile_arg_to_host_when_returning_a_commandspec()
|
||||
{
|
||||
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue