From 0eb527a7c15c905e41a81aeb8c8afa931fad43fb Mon Sep 17 00:00:00 2001 From: Bryan Thornbury Date: Thu, 7 Apr 2016 18:07:51 -0700 Subject: [PATCH] change ordering of the args when invoking dotnet exec for xunit. Fix a bug in the host logic --- .../PackagedCommandSpecFactory.cs | 51 ++++++++++++------- src/corehost/cli/fxr/fx_muxer.cpp | 13 +++-- src/corehost/cli/hostpolicy.cpp | 2 +- src/corehost/cli/libhost.cpp | 25 +++++++-- src/corehost/cli/libhost.h | 4 +- 5 files changed, 70 insertions(+), 25 deletions(-) diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactory.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactory.cs index ae10b4812..db399bd3e 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactory.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactory.cs @@ -107,29 +107,46 @@ namespace Microsoft.DotNet.Cli.Utils } arguments.Add("exec"); + + if (runtimeConfigPath != null) + { + arguments.Add("--runtimeconfig"); + arguments.Add(runtimeConfigPath); + } + + if (depsFilePath != null) + { + arguments.Add("--depsfile"); + arguments.Add(depsFilePath); + } + + arguments.Add("--additionalprobingpath"); + arguments.Add(nugetPackagesRoot); + + arguments.Add(commandPath); } else { host = CoreHost.HostExePath; + + arguments.Add(commandPath); + + if (runtimeConfigPath != null) + { + arguments.Add("--runtimeconfig"); + arguments.Add(runtimeConfigPath); + } + + if (depsFilePath != null) + { + arguments.Add("--depsfile"); + arguments.Add(depsFilePath); + } + + arguments.Add("--additionalprobingpath"); + arguments.Add(nugetPackagesRoot); } - arguments.Add(commandPath); - - if (runtimeConfigPath != null) - { - arguments.Add("--runtimeconfig"); - arguments.Add(runtimeConfigPath); - } - - if (depsFilePath != null) - { - arguments.Add("--depsfile"); - arguments.Add(depsFilePath); - } - - arguments.Add("--additionalprobingpath"); - arguments.Add(nugetPackagesRoot); - arguments.AddRange(commandArguments); return CreateCommandSpec(host, arguments, commandResolutionStrategy); diff --git a/src/corehost/cli/fxr/fx_muxer.cpp b/src/corehost/cli/fxr/fx_muxer.cpp index 2ab9bc800..e1767fb7a 100644 --- a/src/corehost/cli/fxr/fx_muxer.cpp +++ b/src/corehost/cli/fxr/fx_muxer.cpp @@ -314,11 +314,18 @@ int fx_muxer_t::parse_args_and_execute(const pal::string_t& own_dir, int argoff, trace::verbose(_X("Current argv is %s"), app_candidate.c_str()); pal::string_t app_or_deps = deps_file.empty() ? app_candidate : deps_file; - pal::string_t app_or_runtime_config = runtime_config.empty() ? app_candidate : runtime_config; pal::string_t config_file, dev_config_file; - trace::error(_X("Finding runtimeconfig.json from [%s]"), app_or_runtime_config.c_str()); - get_runtime_config_paths_from_file(app_or_runtime_config, &config_file, &dev_config_file); + if(runtime_config.empty()) + { + trace::verbose(_X("Finding runtimeconfig.json from [%s]"), app_candidate.c_str()); + get_runtime_config_paths_from_app(app_candidate, &config_file, &dev_config_file); + } + else + { + trace::verbose(_X("Finding runtimeconfig.json from [%s]"), runtime_config.c_str()); + get_runtime_config_paths_from_arg(runtime_config, &config_file, &dev_config_file); + } runtime_config_t config(config_file, dev_config_file); for (const auto& path : config.get_probe_paths()) diff --git a/src/corehost/cli/hostpolicy.cpp b/src/corehost/cli/hostpolicy.cpp index 6349e7ce3..8c00e493d 100644 --- a/src/corehost/cli/hostpolicy.cpp +++ b/src/corehost/cli/hostpolicy.cpp @@ -248,7 +248,7 @@ SHARED_API int corehost_main(const int argc, const pal::char_t* argv[]) { pal::string_t config_file, dev_config_file; - get_runtime_config_paths_from_file(args.managed_application, &config_file, &dev_config_file); + get_runtime_config_paths_from_app(args.managed_application, &config_file, &dev_config_file); runtime_config_t config(config_file, dev_config_file); if (!config.is_valid()) diff --git a/src/corehost/cli/libhost.cpp b/src/corehost/cli/libhost.cpp index a97c8ff19..63984952f 100644 --- a/src/corehost/cli/libhost.cpp +++ b/src/corehost/cli/libhost.cpp @@ -6,14 +6,33 @@ #include "trace.h" #include "libhost.h" -void get_runtime_config_paths_from_file(const pal::string_t& file, pal::string_t* cfg, pal::string_t* dev_cfg) +void get_runtime_config_paths_from_app(const pal::string_t& app, pal::string_t* cfg, pal::string_t* dev_cfg) { - auto name = get_filename_without_ext(file); + auto name = get_filename_without_ext(app); auto json_name = name + _X(".runtimeconfig.json"); auto dev_json_name = name + _X(".runtimeconfig.dev.json"); - auto json_path = get_directory(file); + auto json_path = get_directory(app); + auto dev_json_path = json_path; + + append_path(&json_path, json_name.c_str()); + append_path(&dev_json_path, dev_json_name.c_str()); + + trace::verbose(_X("Runtime config is cfg=%s dev=%s"), json_path.c_str(), dev_json_path.c_str()); + + dev_cfg->assign(dev_json_path); + cfg -> assign(json_path); +} + +void get_runtime_config_paths_from_arg(const pal::string_t& arg, pal::string_t* cfg, pal::string_t* dev_cfg) +{ + auto name = get_filename_without_ext(arg); + + auto json_name = name + _X(".json"); + auto dev_json_name = name + _X(".dev.json"); + + auto json_path = get_directory(arg); auto dev_json_path = json_path; append_path(&json_path, json_name.c_str()); diff --git a/src/corehost/cli/libhost.h b/src/corehost/cli/libhost.h index 27b29acf7..389e21d57 100644 --- a/src/corehost/cli/libhost.h +++ b/src/corehost/cli/libhost.h @@ -80,7 +80,9 @@ public: } }; -void get_runtime_config_paths_from_file(const pal::string_t& file, pal::string_t* config_file, pal::string_t* dev_config_file); +void get_runtime_config_paths_from_app(const pal::string_t& file, pal::string_t* config_file, pal::string_t* dev_config_file); +void get_runtime_config_paths_from_arg(const pal::string_t& file, pal::string_t* config_file, pal::string_t* dev_config_file); + host_mode_t detect_operating_mode(const int argc, const pal::char_t* argv[], pal::string_t* own_dir = nullptr); void try_patch_roll_forward_in_dir(const pal::string_t& cur_dir, const fx_ver_t& start_ver, pal::string_t* max_str);