Ubuntu上的.NET Core - CORECLR_DIR env变量的正确值是什么?

时间:2016-08-19 19:09:57

标签: node.js ubuntu-14.04 coreclr

在我的Ubuntu 14主机上,我正在尝试使用名为node-msmq的节点模块,它提供了到MS MSMQ的桥接器 此模块依赖于安装.NET环境。 我使用git repo在Ubuntu上编译.NET,并将它放在/ home / ubuntu / coreclr下:

ubuntu@lin-dev-42:~/coreclr$ pwd
/home/ubuntu/coreclr

ubuntu@lin-dev-42:~/coreclr$ ls
all.locproj            clrdefinitions.cmake   crossgen.cmake                     generateversionscript.awk   README.md
bin                    clr.desktop.props      dac.cmake                          global.json                 run.cmd
build.cmd              clr.native.targets     dac.props                          init-tools.cmd              run-cppcheck.sh
build-packages.cmd     clr.props              definitionsconsistencycheck.cmake  init-tools.sh               run.sh
build-packages.sh      clr.targets            dir.props                          LICENSE.TXT                 sanitizerblacklist.txt
build.proj             cmake.definitions      dirs.proj                          netci.groovy                src
build.sh               CMakeLists.txt         dir.targets                        oacr.cfg                    sync.cmd
build-test.cmd         CODE_OWNERS.TXT        dir.traversal.targets              packages                    sync.sh
BuildToolsVersion.txt  compileoptions.cmake   Documentation                      partition.settings.targets  tests
clean.cmd              config.json            DotnetCLIVersion.txt               PATENTS.TXT                 THIRD-PARTY-NOTICES
clean.sh               CONTRIBUTING.md        enablesanitizers.sh                perf.groovy                 Tools
clr.coreclr.props      cross                  functions.cmake                    publish-packages.cmd        UpdateDependencies.ps1
clr.defines.targets    crosscomponents.cmake  generateexportedsymbols.awk        publish-packages.sh         UpdatePublishedVersions.ps1

我的Node脚本看起来非常简单:

const msmq = require('node-msmq');

//var queue = msmq.openOrCreateQueue('.\\Private$\\MyAwesomeQueue');

// Send message to queue 
//queue.send('Hello from Node.JS!');

当我运行此代码时,我收到错误,抱怨没有正确设置env var CORECLR_DIR:

ubuntu@lin-dev-42:~/dev/node/msmq-producer$ node producer.js 

module.js:355
  Module._extensions[extension](this, filename);
                               ^
Error: Unable to load the CLR from the directory (��S) specified in the CORECLR_DIR environment variable.
    at Error (native)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/ubuntu/dev/node/msmq-producer/node_modules/node-msmq/node_modules/edge/lib/edge.js:53:8)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)

目前,我将此var设置为:

ubuntu@lin-dev-42:~/dev/node/msmq-producer$ echo $CORECLR_DIR
/home/ubuntu/coreclr

,显然,这是不正确的价值。

为了在Ubuntu上检测我的coercer .NET环境,我应该设置什么值?

1 个答案:

答案 0 :(得分:0)

该错误不是来自CoreCLR本身。

根据您的堆栈,您似乎正在使用edge.js。我只是看了GitHub README for edge,它说下面关于那个环境变量(我建议阅读整个README):

  

Edge将尝试在下面找到.NET Core运行时   位置:

     
      
  • CORECLR_DIR环境变量中的路径(如果提供)
  •   
  • 当前目录
  •   
  • 包含edge_*.node
  • 的目录   
  • PATH环境变量中的目录。一旦找到包含dotnet可执行文件的目录,我们就会执行   以下决定框架的哪个版本(你可以拥有   一次安装几个)加载      
        
    • 如果CORECLR_VERSION   指定了环境变量,我们尝试加载该版本
    •   
    • 否则,如果project.json / * .deps.json有引用   Microsoft.NETCore.App,表示它是为特定内容构建的   框架版本,我们尝试加载该版本
    •   
    • 否则,我们选择   最大安装版本
    •   
  •   

所以对你的问题最简单的答案是将该变量设置为包含libcoreclr.so的目录,或者只从该目录运行(使其成为当前目录)。