How to change default dnx version is Visual Studio Code? - mono

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?

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

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.

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

Related

How to set the default MSVC compiler version when multiple versions exist for same toolset version

I have multiple versions of MSVC C++ build tools for the same toolset(v142) installed using Visual studio build tools. How can I set the default or preferred version of the MSVC compiler. Is there a registry or environment variable for setting this in Windows or with Cmake?
Cmake picks up the latest version and I want it to use older version for some builds. CMake does seem to have a -T parameter for toolset but in my case both versions are for toolset v142.
Please note that I do not have or intend to use Visual Studio IDE for this since I am dealing with command line builds for CI purposes.
You can pass the required version via CLI:
$ cmake ... -T v142,version=14.24
See also CMAKE_GENERATOR_TOOLSET variable.

cmake windows x64 builds

Is there a way to use the cmake gui to specify a x64 build, since by default cmake on windows creates a 32-bit Visual Studio solution.
From the command line, folks say to do this:
C:\projectx\build> cmake ..\make -G "Visual Studio 10 Win64"
but how do I get to the command line arguments from the cmake windows gui?
see:
http://www.saoe.net/blog/778/
How to build x86 and/or x64 on Windows from command line with CMAKE?
cmake -G Ninja on windows specify x64
The only way I have found to do this, is to wipe the output folder, and then it lets you select Visual Studio 10 Win64 when you first configure the cmake project. Make sure you choose the correct item in the dropdown.
You can specify it during the first configure process.
After that, if you want to change the machine type you need to delete the cache with the "Delete Cache" command in the "File" menu and start the configure process again.
This will happen if you run cmake in a x64 Native Tools Command Prompt for VS 2019 for the first time (otherwise delete build folder).

npm cannot find SDK version from global.json

I'm in the thick of trying to get up-to-speed on asp.net core / npm / react using this as a base project template:
https://github.com/jonmcquade/aspnetcore-react-redux#local-no-docker
I originally ran into troubles once trying this command:
dotnet build -c Release -o ./app
The error I was seeing:
A compatible SDK version for global.json version: [2.1.0] from
[global.json] was not found Did you mean to run dotnet SDK commands?
Please install dotnet SDK from:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
I had the specific versions in the documentation installed and I have installed the latest versions, both x64 and x86 platforms.
I now also get this error running the npm install command or the dotnet --version command, yet I have SDKs installed.
It feels like the machine configuration has become broken somehow. I seem to have gotten into a bit of a version pickle trying to get the dotnet build command working and now even NPM isn't working.
Global.json is:
{
"sdk": { "version": "2.1.0" }
}
And the .csproj file contains:
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeFrameworkVersion>2.1.0-preview1-26216-03</RuntimeFrameworkVersion>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<IsPackable>false</IsPackable>
<AssemblyName>FlightSearch</AssemblyName>
<RootNamespace>FlightSearch</RootNamespace>
<ApplicationIcon>ClientApp\favicon.ico</ApplicationIcon>
<Authors>Jon McQuade</Authors>
<Company>ACME Freelancing, Inc.</Company>
<StartupObject></StartupObject>
<Product>Flight Search</Product>
<Description>ASP .NET Core 2.1 MVC SPA with React and Redux</Description>
<RepositoryUrl>http://github.com/jonmcquade/aspnetcore-react-redux</RepositoryUrl>
<PreserveCompilationContext>true</PreserveCompilationContext>
<TypeScriptToolsVersion>2.8</TypeScriptToolsVersion>
<OutputType>Exe</OutputType>
<Version>2.1</Version>
</PropertyGroup>
What am I missing to get this working?
Are there some machine configuration issues that I can check? Maybe environment variables? I've tried running a repair using the installers but this doesn't address the issue.
The global.json specifies the SDK version of .NET Core that is being used to build your application. This has little to do with the .NET Core Runtime version that you want to run your application with.
Your application is a netcoreapp2.1, so you are running the .NET Core 2.1 Runtime. The earliest SDK Version for that is 2.1.300.
Since that is the latest .NET Core version, you actually don’t need to use a global.json at all: Just delete the file from your project and the tooling should use the latest version which is 2.1.300-rc1 on your machine.
If you're running into this issue on OSX you can fix the issue thusly:
which dotnet
ls + the output from the previous command
You should now see something like:
/usr/local/share/dotnet/dotnet
The directory that has your dotnet binary should also have a directory called sdk, so for the above example you can run ls /usr/local/share/dotnet/sdk, which should output a directory with your current version number. In my case that is 2.1.403 (there may be a better way to get the version number, but I was unable to run dotnet --version without specifying the correct sdk)
If I now open the global.json file in my app's root directory and change the sdk version to "2.1.403-osx-gs-x64", I should now be able to run dotnet command such as dotnet run from within my project.
Just make sure the required SDK version is installed in your machine. On your error, it's .NET core 2.1.0. You don't need the global.json file anymore.

Using cmake with nmake x64

I use cmake to generate a NMake file, everything goes fine.
I use the x64 toolsets (without Visual Studio, only the SDK), so I type nmake, but it generate a x86 build and not a x64 build.
Do you know why ? and how to force nmake to target x64 ?
Thanks
Just to share, use the following to force the x64 platform. Use this command prompt command.
VsDevCmd.bat -host_arch=amd64 -arch=amd64
Both -host_arch and -arch are mandatory !

Upgrading ASP.NET 5 from beta-4 to beta-5

Upgraded ASP.NET5 from beta-4 to beta-5 following the instructions on Microsoft's site:
http://blogs.msdn.com/b/webdev/archive/2015/06/30/asp-net-5-beta5-now-available.aspx
Got ton's of compile errors (1900+) like I was missing core .NET stuff (System.Object not defined, etc). I followed the solution posted at this other similar question: Error Upgrading from ASP.NET 5 Beta 4 to Beta 5 But this did not resolve the issue. I now get errors that the following runtime could not be found: dnx-clr-win-x86.1.0.0-beta5
If I run the command "dnvm list" I get the following output:
Active Version Runtime Architecture
------ ------- ------- ------------
1.0.0-beta4 clr x64
1.0.0-beta4 clr x86
1.0.0-beta4 coreclr x64
1.0.0-beta4 coreclr x86
* 1.0.0-beta6-12254 clr x86
1.0.0-beta6-12254 coreclr x86
So dnvm upgrade skipped over beta5 and went straight to beta6, but it appears some things are still looking for beta5. Is there a way to force dvnm to install beta5?
I've attempted to run the command:
dnvm install 1.0.0-beta5
Which results in the error:
'dnx-clr-win-x86.1.0.0-beta6-12254' is already installed.
Notice it says beta6 for the error! Perhaps it's being used as an alias for beta5 or it's just not possible to install earlier versions?
dnvm installs from the release feed by default. We've branched for beta6 and beta5 is not longer on that feed.
To solve the issue, set the DNX_FEED variable:
set DNX_FEED=https://nuget.org/api/v2
dnvm install 1.0.0-beta5
PS: I've opened a bug to track this. It would be nice to have a regular argument to specify the feed.