How to change default dnx version is Visual Studio

2019-02-12 02:29发布

问题:

I am not sure if it is possible but I want to change dnx version when dnx . run from Visual Studio Code.

Even if my current dnx version is 1.0.0-beta5-11682 coreclr Visual Studio Code runs with 1.0.0-beta4 mono

Is it possible to change default dnx version of Visual Studio Code?

回答1:

dnvm use VERSION -p

where -p is persistent, you can use without it to set version just for the current session.

example

dnvm use 1.0.0-beta4

or

dnvm use 1.0.0-beta4 -p


回答2:

dnvm use <runtime_version> -r <runtime> -a <architecture> -p

examples:
<runtime_version>: 1.0.0-rc1-update2 etc.
<runtime>: mono, clr, coreclr (optional)
<architecture>: x64, x86 (optional)
-p: makes the results persistent (optional)

Selecting Active:

You have to provide the Runtime version as well, if there are multiple choices for the same name. For example type the following:

dnvm use 1.0.0-beta4 -r mono

If you would have to provide Architecture as well, the following command would apply:

dnvm use 1.0.0-beta4 -r mono -arch <architecture>

where can be "x64" for example, without the quotes.

Setting Default:

dnvm alias default 1.0.0-beta5-11682 -r coreclr -arch x64

Please note that, there were a bug (about May, 2015), in which referring to a CoreClr runtime by alias was not working. I don't know if it's fixed yet, but I guess so. Source: Issue 175 about the bug.



回答3:

You can either set a version in the global.json file (like so https://github.com/OmniSharp/omnisharp-roslyn/blob/master/global.json#L4) or use the combination of dnvm alias and dnvm use. OmniSharp (the C# brain used by VSCode) will first check the global.json file and then go with the default-alias. All the details can be found here: https://github.com/OmniSharp/omnisharp-roslyn/blob/master/src/OmniSharp/AspNet5/AspNet5Paths.cs#L45