ASP.NET MVC 6 Project cannot find DNX Run time - asp.net

When I try to build the project the error I get is as follows..
The Dnx Runtime package needs to be installed. See output window for more details
I have tried running both
dnvm upgrade
dnvm upgrade -r CoreClr
And when I run
dnvm list
I can see the run time installed which matches my project properties.
I have also tried the solution outlined here;
http://www.sblackler.net/2015/05/02/Up-And-Running-With-DNX-DNVM-DNU/
Anyone have any ideas what else I can try? Is there a way to explicitly point my project to the run time in the .dnx folder of my
C:\Users\<Username>\.dnx
folder?

If you are using the command line, you need to make sure that you also do dnvm use <version/label>.
On dnvm list, you'll see labels to the right, or you can use a specific version.
dnvm use default will use the default label.
dnvm use 1.0.0-beta4 will use the beta4 runtime specifically. (assuming you have it installed).

This might be a bit late, but better late than never ;)
clean up your dnx runtimes in C:\Users\USERNAME\.dnx and run dnvm upgrade. This should reinstall the latest runtimes. Or just use dnvm install <version> to install the ones you require.
Next, make sure your project references the right dnx runtime package in global.json depending on your preferences.
"sdk": {
"version": "1.0.0-beta7",
"runtime": "clr",
"architecture": "x86"
}
Check project properties to point to the specific runtime of your choice.
Also try and keep your dependencies in the same beta version to avoid anomalies.

Related

How to tell Visual Studio Code compiled from source where to find sqlite module?

I am building the Visual Studio Code from the source checked out from the git repository:
git clone https://github.com/microsoft/vscode
I am building using:
export NODE_OPTIONS=--max_old_space_size=2048
./scripts/npm.sh install --arch=armhf
./scripts/code.sh
I am using node 10.16.3 on a Raspberry PI 4, using Raspbian buster
There were no errors during build.
The installation downloads a precompiled version of electron on the first run.
However each time I try and run code, it starts but with an error:
[storage state.vscdb] open(): Unable to open DB due to Error: Cannot find module '../build/Release/sqlite
If I look in node_modules/vscode-sqlite3/build/Release/
I can see:
sqlite3.a
sqlite.a
It is unclear to me why electron/vscode cannot find this library. I would be greatful for any pointers on how to tell the runtime where to look for the modules.
On inspecting the build scripts and after many painful experiments, I've found and solved the 2 problems leading to this error.
The fact that .a static libraries are left behind hinted that some settings in the binding.gyp, config.gpy and/or makefiles are wrong, as Native Node Modules are normally dynamic libraries with an .node extension. One conditional line in the binding.gyp file under vscode-sqlite3 seems to the the culprit:
...
["target_arch=='arm'", {"type": "static_library"}]
...
Disable that line (by removing it or changing 'arm' to something else) and then run:
node-gyp configure
to regenerate the config.gpy file(s) under the build directory. Then build the module with:
node-gyp build
A sqlite.node will be generated in build/Release.
Unfortunately, the latest electron ABI version rarely matches that of the Node.js version. In my configuration, the electron ABI version is 72 (v6.0.12) but the latest stable Node version is for ABI 64. Therefore we have to do an electron-rebuild to update the sqlite.node to match the electron version.
To do this, you would have to first install electron-rebuild (yarn add electron-rebuild) then run electron-rebuild by giving supplying explicitly the version number of the electron binary that vscode downloaded:
electron-rebuild -v 6.0.12 -m /home/dev/vscode -o vscode-sqlite3
Of course you would have to state the version number of your particular version of electron you are building for.
(Please look up electron-rebuild --help for the meaning of the options. It takes a while to rebuild the binary module...)
The resulting sqlite.node can then be moved into the build/Release/. directory under the vscode project directory. Voila, we have a working latest version VS-Code for Raspbian!

DotNet CLI Tool fails with "No executable found matching command "dotnet-migrate-2017"

I am trying to use migrate-2017 to migrate some csproj files to the new more concise vs2017 project format. I installed the tool from https://github.com/hvanbakel/CsprojToVs2017 using the command:
dotnet tool install --global Project2015To2017.Migrate2017.Tool
When I try to use it I get this:
C:\projects\Trilogy\Main>dotnet migrate-2017 wizard
No executable found matching command "dotnet-migrate-2017"
However, it appears to exist....
C:\projects\Trilogy\Main>dotnet tool list -g
Package Id Version Commands
------------------------------------------------------------------------
project2015to2017.migrate2017.tool 4.0.0 dotnet-migrate-2017
The global.json looks fine....
C:\projects\Trilogy\Main>type global.json
{
"sdk": {
"version": "2.1.602"
}
}
And so does the version:
C:\projects\Trilogy\Main>dotnet --version
2.1.602
I'm using dotnet CLI tools for the first time, so what obvious thing am I missing?
I don't think you're missing anything, but here's a few things to try:
Does running dotnet-migrate-2017 work (no dotnet required first)?
Does the tool exist under %userprofile%\.dotnet\tools?
Have you tried restarting the command prompt to force refresh your %PATH%?
Have you tried uninstalling and reinstalling the package?

How to restore an ASP.NET Core project with Ubuntu

Recently, I created an asp.net core project using Visual Studio Code on Windows and pushed it to GitHub. When I cloned the repo from GitHub and attempted to do a dotnet restore on the project on Ubuntu, an error message stating there was no project.json file was returned. Can anyone point me to a resource that will show me how to properly restore a .net core project from a Linux machine? Thanks!
So it seems like on each of your machines you are running different versions of the .net core SDK.
A big caveat with what you are trying to do. Are you trying to use Project Rider from Jetbrains on Linux? This only works with project.json (As of the time of this post) so be wary of that.
Now there are two ways to do this. If you are wanting the very latest on Linux and don't care about using Rider, then you can go here : https://github.com/dotnet/core/blob/master/release-notes/download-archive.md and download the latest release for both Linux and Windows, install on both and you should be good to go.
If you do care about using Rider or you aren't ready to be strapped in for the wild ride of the latest release. Then you can do the following.
Find what version of the SDK you have on linux by typing into a terminal the following :
dotnet --version
This will spit out what version you have on linux. Go here and download the same version for windows and install it on your windows machine (https://github.com/dotnet/core/blob/master/release-notes/download-archive.md).
Now BEFORE you create a project, create a solution folder and create a file in it called global.json. Inside that put the following :
"sdk": {
"version": "1.0.0-preview2-003131"
}
Where the SDK version matches what you got from your linux terminal. Now create a folder for your project inside the solution folder. Run "dotnet new -t web" or a similar command to create your project. It will inspect the SDK version of the global.json and create a project with the tooling that matches. You should then be able to shift this project around any machine that has the same SDK installed, even if it also has the latest SDK's also.
If you do not create the global.json, it defaults to the latest version (Atleast on Windows).
Read a bit more about it here : http://dotnetcoretutorials.com/2017/02/17/developing-two-versions-net-core-sdk-side-side/

VS Code, OmniSharp: Project has these unresolved references:

I'm trying out Asp.Net Core and MVC 6 running on Mac OS X. After I've updated and installed everything it seems to be working pretty good. I can run a website with 'dnx web' that's been generated by Yeoman.
OmniSharp starts correctly but displays this message,
[INFORMATION:OmniSharp.Dnx.DnxProjectSystem] Project /Users/myname/AspNetCoreProjects/test1/project.json has these unresolved references: Microsoft.AspNet.Diagnostics, Microsoft.AspNet.IISPlatformHandler, Microsoft.AspNet.Mvc, Microsoft.AspNet.Mvc.TagHelpers, Microsoft.AspNet.Server.Kestrel, Microsoft.AspNet.StaticFiles, Microsoft.AspNet.Tooling.Razor, Microsoft.Extensions.Configuration.FileProviderExtensions, Microsoft.Extensions.Configuration.Json, Microsoft.Extensions.Logging, Microsoft.Extensions.Logging.Console, Microsoft.Extensions.Logging.Debug
I've tried to run 'dnu restore' several times. And it seems to succeed. It writes a lock file and so on. But for some reason OmniSharp / VS Code doesn't seem to find any references (except my own classes) at all.
It feels like I'm having the same problem described here,
http://tech.genericwhite.com/visual-studio-2015-net-5-rc1-dnu-restore-asp-dot-net-missing
But that didn't work for me.
Any idea is very helpful!
To start, install the runtime:
//to install coreclr
dnvm install latest -r coreclr -a coreclr-latest
//to install the clr
dnvm install latest -a mono-latest
dnvm alias default [coreclr-latest | mono-latest] //depends on what you installed
dnvm use default
Let me know the output of ls -l ~/.dnx/runtimes/dnx-{your_coreclr_version}/bin | grep dn once you've ran those commands.
This is what your runtimes folder should look like:
I'm also writing a 5 five part tutorial on how to use ASP.NET Core along with with JSPM, TypeScript, etc as the frontend. If you don't care much for that you can take a look at the backend part (part 3) here:
http://ahoycoders.com/2016/03/29/jspm-with-systemjs-es6-angularjs-typescript-and-asp-net-core-part-3-backend/
This part focuses on installing and running ASP.NET Core on MacOS.
Let me know how it goes :)
EDIT: One thing I forgot to mention, before running dnu restore again remove "dnx451": {}, from your project.json
EDIT2: Make sure you install the coreclr option. From your post it seems you want to use ASP.NET Core

.NET versions in ASP.NET 5

In the new ASP.NET 5 projects, there are multiple ways / places to control the .NET versions:
In global.json
In Project -> Properties, Application tab, Solution DNX SDK Version (this is the same as the global.json)
In Project -> Properties, Debug tab, Use Specific Runtime
In Package Manager Console, using dnvm list
In a normal console in the application root, using dnvm list
Which of these are the same (apart from the first two) and what do they all do?
The dnx in global.json is only used by VS. No one else uses it and if you run the application outside of VS, there is no guarantee that it'll use that version.
The dnx used to run a particular application is set in two ways:
Either pass the full path to a particular dnx. E.g: C:\dnx\dnx.exe . run
The dnx on the PATH resolved according to your OS' PATH resolution (we don't control that).
When you run dnvm use <version>, that particular version is added to the path and it will be used by that particular process and it's child processes. If you run dnvm use -p <version>, that version of dnx is added to the user's PATH in addition to the process' PATH.
For VS, if no version is specified in global.json by default it uses the dnx under the default alias. The default alias is updated when you run dnvm upgrade or dnvm use -p

Resources