From 547b97a195c28c6ada89648a9ba2a53dd920050d Mon Sep 17 00:00:00 2001 From: Senthil Date: Wed, 11 May 2016 20:58:01 -0700 Subject: [PATCH] Help message for dotnet --- scripts/dotnet-cli-build/CompileTargets.cs | 4 +++ src/corehost/build.sh | 12 +++++-- src/corehost/cli/fxr/fx_muxer.cpp | 37 ++++++++++++++++++++-- src/corehost/cli/setup.cmake | 6 ++++ src/corehost/common/pal.h | 2 ++ src/corehost/common/trace.cpp | 13 ++++++++ src/corehost/common/trace.h | 2 ++ 7 files changed, 71 insertions(+), 5 deletions(-) diff --git a/scripts/dotnet-cli-build/CompileTargets.cs b/scripts/dotnet-cli-build/CompileTargets.cs index f63e73b2d..7a629ceec 100644 --- a/scripts/dotnet-cli-build/CompileTargets.cs +++ b/scripts/dotnet-cli-build/CompileTargets.cs @@ -174,6 +174,7 @@ namespace Microsoft.DotNet.Cli.Build var arch = IsWinx86 ? "x86" : "x64"; var baseSupportedRid = $"win7-{arch}"; var cmakeHostPolicyVer = $"-DCLI_CMAKE_HOST_POLICY_VER:STRING={hostVersion.LatestHostPolicyVersion}"; + var cmakeHostFxrVer = $"-DCLI_CMAKE_HOST_FXR_VER:STRING={hostVersion.LatestHostFxrVersion}"; var cmakeBaseRid = $"-DCLI_CMAKE_PKG_RID:STRING={baseSupportedRid}"; var cmakeCommitHash = $"-DCLI_CMAKE_COMMIT_HASH:STRING={commitHash}"; @@ -181,6 +182,7 @@ namespace Microsoft.DotNet.Cli.Build corehostSrcDir, archMacro, ridMacro, + cmakeHostFxrVer, cmakeHostPolicyVer, cmakeBaseRid, cmakeCommitHash, @@ -214,6 +216,8 @@ namespace Microsoft.DotNet.Cli.Build ExecIn(cmakeOut, Path.Combine(c.BuildContext.BuildDirectory, "src", "corehost", "build.sh"), "--arch", "x64", + "--fxrver", + hostVersion.LatestHostFxrVersion, "--policyver", hostVersion.LatestHostPolicyVersion, "--rid", diff --git a/src/corehost/build.sh b/src/corehost/build.sh index 390762002..297965e99 100755 --- a/src/corehost/build.sh +++ b/src/corehost/build.sh @@ -27,11 +27,12 @@ init_distro_name_and_rid() usage() { - echo "Usage: $0 --arch --rid --policyver --commithash [--xcompiler ]" + echo "Usage: $0 --arch --rid --fxrver --policyver --commithash [--xcompiler ]" echo "" echo "Options:" echo " --arch Target Architecture (amd64, x86, arm)" echo " --rid Target Runtime Identifier" + echo " --fxrver Version of the hostfxr library" echo " --policyver Version of the hostpolicy library" echo " --commithash Current commit hash of the repo at build time" echo " --xcompiler Cross Compiler when the target is arm" @@ -53,6 +54,7 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" __build_arch= __runtime_id= __policy_ver= +__fxr_ver= __CrossBuild=0 __commit_hash= @@ -71,6 +73,10 @@ while [ "$1" != "" ]; do shift __runtime_id=$1 ;; + --fxrver) + shift + __fxr_ver=$1 + ;; --policyver) shift __policy_ver=$1 @@ -133,9 +139,9 @@ __base_rid=$__rid_plat-$__build_arch_lowcase echo "Building Corehost from $DIR to $(pwd)" set -x # turn on trace if [ $__CrossBuild == 1 ]; then - cmake "$DIR" -G "Unix Makefiles" $__cmake_defines -DCLI_CMAKE_RUNTIME_ID:STRING=$__runtime_id -DCLI_CMAKE_HOST_POLICY_VER:STRING=$__policy_ver -DCMAKE_CXX_COMPILER="$__CrossCompiler" -DCLI_CMAKE_PKG_RID:STRING=$__base_rid -DCLI_CMAKE_COMMIT_HASH:STRING=$__commit_hash + cmake "$DIR" -G "Unix Makefiles" $__cmake_defines -DCLI_CMAKE_RUNTIME_ID:STRING=$__runtime_id -DCLI_CMAKE_HOST_FXR_VER:STRING=$__fxr_ver -DCLI_CMAKE_HOST_POLICY_VER:STRING=$__policy_ver -DCLI_CMAKE_PKG_RID:STRING=$__base_rid -DCLI_CMAKE_COMMIT_HASH:STRING=$__commit_hash -DCMAKE_CXX_COMPILER="$__CrossCompiler" else - cmake "$DIR" -G "Unix Makefiles" $__cmake_defines -DCLI_CMAKE_RUNTIME_ID:STRING=$__runtime_id -DCLI_CMAKE_HOST_POLICY_VER:STRING=$__policy_ver -DCLI_CMAKE_PKG_RID:STRING=$__base_rid -DCLI_CMAKE_COMMIT_HASH:STRING=$__commit_hash + cmake "$DIR" -G "Unix Makefiles" $__cmake_defines -DCLI_CMAKE_RUNTIME_ID:STRING=$__runtime_id -DCLI_CMAKE_HOST_FXR_VER:STRING=$__fxr_ver -DCLI_CMAKE_HOST_POLICY_VER:STRING=$__policy_ver -DCLI_CMAKE_PKG_RID:STRING=$__base_rid -DCLI_CMAKE_COMMIT_HASH:STRING=$__commit_hash fi set +x # turn off trace make diff --git a/src/corehost/cli/fxr/fx_muxer.cpp b/src/corehost/cli/fxr/fx_muxer.cpp index ce2b108fa..a8f0975b8 100644 --- a/src/corehost/cli/fxr/fx_muxer.cpp +++ b/src/corehost/cli/fxr/fx_muxer.cpp @@ -15,6 +15,8 @@ #include "deps_format.h" +static const pal::char_t* s_dotnet_sdk_download_url = _X("http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409"); + /** * When the framework is not found, display detailed error message * about available frameworks and installation of new framework. @@ -556,7 +558,29 @@ bool fx_muxer_t::resolve_sdk_dotnet_path(const pal::string_t& own_dir, pal::stri int muxer_usage() { - trace::error(_X("Usage: dotnet [--help | app.dll]")); + trace::println(); + trace::println(_X("Microsoft .NET Core Shared Framework Host")); + trace::println(); + trace::println(_X(" Version : %s"), _STRINGIFY(HOST_FXR_PKG_VER)); + trace::println(_X(" Build : %s"), _STRINGIFY(REPO_COMMIT_HASH)); + trace::println(); + trace::println(_X("Usage: dotnet [common-options] [[options] path-to-application]")); + trace::println(); + trace::println(_X("Common Options:")); + trace::println(_X(" --help Display .NET Core Shared Framework Host help.")); + trace::println(_X(" --version Display .NET Core Shared Framework Host version.")); + trace::println(); + trace::println(_X("Options:")); + trace::println(_X(" --additionalprobingpath Path containing probing policy and assemblies to probe for.")); + trace::println(); + trace::println(_X("Path to Application:")); + trace::println(_X(" The path to a .NET Core managed application, dll or exe file to execute.")); + trace::println(); + trace::println(_X("If you are debugging the Shared Framework Host, set 'COREHOST_TRACE' to '1' in your environment.")); + trace::println(); + trace::println(_X("To get started on developing applications for .NET Core, install .NET SDK from:")); + trace::println(_X(" %s"), s_dotnet_sdk_download_url); + return StatusCode::InvalidArgFailure; } @@ -778,7 +802,16 @@ int fx_muxer_t::execute(const int argc, const pal::char_t* argv[]) pal::string_t sdk_dotnet; if (!resolve_sdk_dotnet_path(own_dir, &sdk_dotnet)) { - trace::error(_X("Did not find a suitable dotnet SDK at '%s'. Install dotnet SDK from https://github.com/dotnet/cli"), own_dir.c_str()); + assert(argc > 1); + if (pal::strcasecmp(_X("--help"), argv[1]) == 0 || + pal::strcasecmp(_X("--version"), argv[1]) == 0 || + pal::strcasecmp(_X("-h"), argv[1]) == 0 || + pal::strcasecmp(_X("-v"), argv[1]) == 0) + { + return muxer_usage(); + } + trace::error(_X("Did you mean to run dotnet SDK commands? Please install dotnet SDK from: ")); + trace::error(_X(" %s"), s_dotnet_sdk_download_url); return StatusCode::LibHostSdkFindFailure; } append_path(&sdk_dotnet, _X("dotnet.dll")); diff --git a/src/corehost/cli/setup.cmake b/src/corehost/cli/setup.cmake index f278f699f..5658a5acf 100644 --- a/src/corehost/cli/setup.cmake +++ b/src/corehost/cli/setup.cmake @@ -70,6 +70,12 @@ else() add_definitions(-DHOST_POLICY_PKG_VER="${CLI_CMAKE_HOST_POLICY_VER}") endif() +if("${CLI_CMAKE_HOST_FXR_VER}" STREQUAL "") + message(FATAL_ERROR "Host FXR version is not specified") +else() + add_definitions(-DHOST_FXR_PKG_VER="${CLI_CMAKE_HOST_FXR_VER}") +endif() + if("${CLI_CMAKE_PKG_RID}" STREQUAL "") message(FATAL_ERROR "A minimum supported package rid is not specified (ex: win7-x86 or ubuntu.14.04-x64, osx.10.10-x64, rhel.7-x64)") else() diff --git a/src/corehost/common/pal.h b/src/corehost/common/pal.h index 8ea1cca06..740d6283d 100644 --- a/src/corehost/common/pal.h +++ b/src/corehost/common/pal.h @@ -116,6 +116,7 @@ namespace pal inline size_t strlen(const char_t* str) { return ::wcslen(str); } inline void err_vprintf(const char_t* format, va_list vl) { ::vfwprintf(stderr, format, vl); ::fputws(_X("\r\n"), stderr); } + inline void out_vprintf(const char_t* format, va_list vl) { ::vfwprintf(stdout, format, vl); ::fputws(_X("\r\n"), stdout); } bool utf8_palstring(const std::string& str, pal::string_t* out); bool pal_clrstring(const pal::string_t& str, std::vector* out); @@ -158,6 +159,7 @@ namespace pal inline size_t strlen(const char_t* str) { return ::strlen(str); } inline void err_vprintf(const char_t* format, va_list vl) { ::vfprintf(stderr, format, vl); ::fputc('\n', stderr); } + inline void out_vprintf(const char_t* format, va_list vl) { ::vfprintf(stdout, format, vl); ::fputc('\n', stdout); } inline bool utf8_palstring(const std::string& str, pal::string_t* out) { out->assign(str); return true; } inline bool pal_clrstring(const pal::string_t& str, std::vector* out) { out->assign(str.begin(), str.end()); out->push_back('\0'); return true; } inline bool clr_palstring(const char* cstr, pal::string_t* out) { out->assign(cstr); return true; } diff --git a/src/corehost/common/trace.cpp b/src/corehost/common/trace.cpp index ac363988c..b04c9d3e1 100644 --- a/src/corehost/common/trace.cpp +++ b/src/corehost/common/trace.cpp @@ -66,6 +66,19 @@ void trace::error(const pal::char_t* format, ...) va_end(args); } +void trace::println(const pal::char_t* format, ...) +{ + va_list args; + va_start(args, format); + pal::out_vprintf(format, args); + va_end(args); +} + +void trace::println() +{ + println(_X("")); +} + void trace::warning(const pal::char_t* format, ...) { if (g_enabled) diff --git a/src/corehost/common/trace.h b/src/corehost/common/trace.h index d1fbfd5ab..d462ef12c 100644 --- a/src/corehost/common/trace.h +++ b/src/corehost/common/trace.h @@ -15,6 +15,8 @@ namespace trace void info(const pal::char_t* format, ...); void warning(const pal::char_t* format, ...); void error(const pal::char_t* format, ...); + void println(const pal::char_t* format, ...); + void println(); }; #endif // TRACE_H