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();
|
sharedHostInstallerDownloadFile).Wait();
|
||||||
|
|
||||||
File.Copy(sharedHostInstallerDownloadFile, sharedHostInstallerDestinationFile, true);
|
File.Copy(sharedHostInstallerDownloadFile, sharedHostInstallerDestinationFile, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.Success();
|
return c.Success();
|
||||||
|
|
|
@ -36,15 +36,12 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var isPortable = IsPortableApp(commandPath, runtimeConfigPath);
|
return CreateCommandSpecWrappingWithMuxerIfDll(
|
||||||
|
|
||||||
return CreateCommandSpecWrappingWithCorehostIfDll(
|
|
||||||
commandPath,
|
commandPath,
|
||||||
commandArguments,
|
commandArguments,
|
||||||
depsFilePath,
|
depsFilePath,
|
||||||
commandResolutionStrategy,
|
commandResolutionStrategy,
|
||||||
nugetPackagesRoot,
|
nugetPackagesRoot,
|
||||||
isPortable,
|
|
||||||
runtimeConfigPath);
|
runtimeConfigPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,65 +55,57 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommandSpec CreateCommandSpecWrappingWithCorehostIfDll(
|
private CommandSpec CreateCommandSpecWrappingWithMuxerIfDll(
|
||||||
string commandPath,
|
string commandPath,
|
||||||
IEnumerable<string> commandArguments,
|
IEnumerable<string> commandArguments,
|
||||||
string depsFilePath,
|
string depsFilePath,
|
||||||
CommandResolutionStrategy commandResolutionStrategy,
|
CommandResolutionStrategy commandResolutionStrategy,
|
||||||
string nugetPackagesRoot,
|
string nugetPackagesRoot,
|
||||||
bool isPortable,
|
|
||||||
string runtimeConfigPath)
|
string runtimeConfigPath)
|
||||||
{
|
{
|
||||||
var commandExtension = Path.GetExtension(commandPath);
|
var commandExtension = Path.GetExtension(commandPath);
|
||||||
|
|
||||||
if (commandExtension == FileNameSuffixes.DotNet.DynamicLib)
|
if (commandExtension == FileNameSuffixes.DotNet.DynamicLib)
|
||||||
{
|
{
|
||||||
return CreatePackageCommandSpecUsingCorehost(
|
return CreatePackageCommandSpecUsingMuxer(
|
||||||
commandPath,
|
commandPath,
|
||||||
commandArguments,
|
commandArguments,
|
||||||
depsFilePath,
|
depsFilePath,
|
||||||
commandResolutionStrategy,
|
commandResolutionStrategy,
|
||||||
nugetPackagesRoot,
|
nugetPackagesRoot,
|
||||||
isPortable,
|
|
||||||
runtimeConfigPath);
|
runtimeConfigPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CreateCommandSpec(commandPath, commandArguments, commandResolutionStrategy);
|
return CreateCommandSpec(commandPath, commandArguments, commandResolutionStrategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommandSpec CreatePackageCommandSpecUsingCorehost(
|
private CommandSpec CreatePackageCommandSpecUsingMuxer(
|
||||||
string commandPath,
|
string commandPath,
|
||||||
IEnumerable<string> commandArguments,
|
IEnumerable<string> commandArguments,
|
||||||
string depsFilePath,
|
string depsFilePath,
|
||||||
CommandResolutionStrategy commandResolutionStrategy,
|
CommandResolutionStrategy commandResolutionStrategy,
|
||||||
string nugetPackagesRoot,
|
string nugetPackagesRoot,
|
||||||
bool isPortable,
|
|
||||||
string runtimeConfigPath)
|
string runtimeConfigPath)
|
||||||
{
|
{
|
||||||
var host = string.Empty;
|
var host = string.Empty;
|
||||||
var arguments = new List<string>();
|
var arguments = new List<string>();
|
||||||
|
|
||||||
if (isPortable)
|
var muxer = new Muxer();
|
||||||
{
|
|
||||||
var muxer = new Muxer();
|
|
||||||
|
|
||||||
host = muxer.MuxerPath;
|
host = muxer.MuxerPath;
|
||||||
if (host == null)
|
if (host == null)
|
||||||
{
|
|
||||||
throw new Exception("Unable to locate dotnet multiplexer");
|
|
||||||
}
|
|
||||||
|
|
||||||
arguments.Add("exec");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
host = CoreHost.HostExePath;
|
throw new Exception("Unable to locate dotnet multiplexer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
arguments.Add("exec");
|
||||||
|
|
||||||
if (runtimeConfigPath != null)
|
if (runtimeConfigPath != null)
|
||||||
{
|
{
|
||||||
arguments.Add("--runtimeconfig");
|
arguments.Add("--runtimeconfig");
|
||||||
arguments.Add(runtimeConfigPath);
|
arguments.Add(runtimeConfigPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (depsFilePath != null)
|
if (depsFilePath != null)
|
||||||
{
|
{
|
||||||
arguments.Add("--depsfile");
|
arguments.Add("--depsfile");
|
||||||
|
@ -141,23 +130,5 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
|
|
||||||
return new CommandSpec(commandPath, escapedArgs, commandResolutionStrategy);
|
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]
|
[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();
|
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
|
|
||||||
var commandFile = Path.GetFileNameWithoutExtension(result.Path);
|
var commandFile = Path.GetFileNameWithoutExtension(result.Path);
|
||||||
|
|
||||||
commandFile.Should().Be("corehost");
|
commandFile.Should().Be("dotnet");
|
||||||
|
|
||||||
result.Args.Should().Contain(commandResolverArguments.CommandName);
|
result.Args.Should().Contain(commandResolverArguments.CommandName);
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[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();
|
var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue