Visual Studio Code Not Finding/Using .Net 3.1 or Mono - c#

I have a new Ubuntu 20.04.2 LTS install.
I have installed:
Visual Studio Code 1.73.0
.net 3.1 using this link here https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#install-the-sdk
mono 6.12.0.182
For my project, I need to use .net 3.1. To do this in visual studio code, I have to use Mono (from what I read).
When I try to run the project, it does not show .net 3.1 or mono in the select box.
Anyone know how to fix this so VS code will allow me to use .net 3.1 or mono to run my .net 3.1 app?
one#work ...IS.custom-forms/frontend/widgets (core/EFB-1931/address-widget)
% which dotnet
/usr/bin/dotnet
one#work ...IS.custom-forms/frontend/widgets (core/EFB-1931/address-widget)
% dotnet --version
3.1.424

I verified the following workflow on a fresh VM with Ubuntu 20.04 LTS and with VS Code installed from Ubuntu Software (GUI).
Installing the .NET 3.1 SDK
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y dotnet-sdk-3.1
Sanity check
dotnet --info
Output
.NET Core SDK (reflecting any global.json): Version: 3.1.425
Commit: ca553b8af8
Runtime Environment: OS Name: ubuntu OS Version: 20.04 OS
Platform: Linux RID: ubuntu.20.04-x64 Base Path:
/usr/share/dotnet/sdk/3.1.425/
Host (useful for support): Version: 3.1.31 Commit: 0e404aa9b8
.NET Core SDKs installed:
3.1.425 [/usr/share/dotnet/sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.App 3.1.31
[/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.31
[/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Installing Mono
Ref https://www.mono-project.com/download/stable/.
sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-devel
Creating test app and launching VS Code
dotnet new mvc -n "TestProject" -au None
cd TestProject
code .
From the Extensions tab, install: C# for Visual Studio Code (powered by OmniSharp).
Go to settings (Ctrl+,). Search for "use modern net", uncheck the checkbox.
Open a terminal window (Ctrl+`) and close VS Code.
Open project again (from Ubuntu terminal):
code .
You should see the following output in the terminal window.
You can either select "Yes" on the notification or click "Generate C# Assets for Build and Debug" from the debug tab.
Select ".NET 5+ and .NET core" from the debugger dropdown.
Open Startup.cs from the Explorer tab and add a breakpoint.
Hit F5.
Q&A
When I try to run the project, it does not show .net 3.1 or mono in the select box.
Anyone know how to fix this so VS code will allow me to use .net 3.1 or mono to run my .net 3.1 app?
.NET 3.1 is included under the .NET core part of ".NET 5+ and .NET core". Chances are the C# dependencies and/or the package for Mono (ref screenshot) were not set up correctly. If you follow the workflow on a fresh install, you should be able to set the dependencies straight before attempting your actual project.

Related

I can't run dotnet ef on linux mint

My setup:
-- Linux --
Distributor ID: Linuxmint
Description: Linux Mint 21
Release: 21
Codename: vanessa
-- Dotnet SDK--
6.0.402 [/home/gilmar/.dotnet/sdk]
-- Dotnet Runtime --
Microsoft.AspNetCore.App 6.0.10 [/home/gilmar/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.10 [/home/gilmar/.dotnet/shared/Microsoft.NETCore.App]
-- Dotnet Tools --
ID do Pacote Versão Comandos
---------------------------------------
dotnet-ef 6.0.10 dotnet-ef
I have trouble when I try to run the command dotnet ef. When I do it, returns the message below:
You must install .NET to run this application.
App: /home/gilmar/.dotnet/tools/dotnet-ef
Architecture: x64
App host version: 6.0.10
.NET location: Not found
Learn about runtime installation:
https://aka.ms/dotnet/app-launch-failed
Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=linuxmint.21-x64&apphost_version=6.0.10
I modified my file .bashrc adding the lines below:
export PATH="$PATH:$HOME/.dotnet"
export PATH="$PATH:$HOME/.dotnet/tools/"
The folders in my directory:
gilmar#hp ~ $ whereis dotnet
dotnet: /home/gilmar/.dotnet/dotnet
gilmar#hp ~ $ whereis dotnet-ef
dotnet-ef: /home/gilmar/.dotnet/tools/dotnet-ef
I can run normally dotnet restore, dotnet new, dotnet build, etc, but I can't run dotnet ef
I tried:
dotnet ef
dotnet-ef
dotnet dotnet-ef
dotnet dotnet ef
I installed dotnet using the script from Microsoft at https://dot.net/v1/dotnet-install.sh
Anyone can help me?
Thanks.
I had the same problem, I tried the same commandes and the solution was to redelete everything and reinstall it then don't forget the :
export PATH="$PATH:$HOME/.dotnet" export
PATH="$PATH:$HOME/.dotnet/tools/"
that solved the problem for me !

How to fix "No .NET SDKs were found." error--VSCode

I'm trying to setup a backend on my local computer I have installed the v6 dotnet everything is installed but when i run dotnet run
I get this error
The command could not be loaded, possibly because:
* You intended to execute a .NET application:
The application 'run' does not exist.
* You intended to execute a .NET SDK command:
No .NET SDKs were found.
Download a .NET SDK:
https://aka.ms/dotnet-download
Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
dotnet --info
PS C:\Users\Az\bazaar-online\Server\Src\BazaarOnline.API> dotnet --info
global.json file:
Not found
Host:
Version: 6.0.7
Architecture: x86
Commit: 0ec02c8c96
.NET SDKs installed:
No SDKs were found.
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.7 [C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.7 [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
Download .NET:
https://aka.ms/dotnet-download
Learn about .NET Runtimes and SDKs:
https://aka.ms/dotnet/runtimes-sdk-info
I searched a lot but i didn't find anything useful.
reinstalled everything tried v3 but didn't fix anything
I have installed these files.
dotnet-hosting-6.0.7-win
dotnet-runtime-6.0.7-win-x64
dotnet-sdk-6.0.302-win-x64
Ok This fixed the problem for me
I went to the C:\Program Files (x86)\dotnet
and deleted everthing in the folder
and than vscode recognized the dotnet sdk.
The command could not be loaded, possibly because:
You intended to execute a .NET application:
The application 'myapp.dll' does not exist.
You intended to execute a .NET SDK command:
No .NET SDKs were found.
Download a .NET SDK:
https://aka.ms/dotnet-download
Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
use this commands
1.sudo apt remove dotnet*
2.sudo apt remove aspnetcore*
3.sudo rm /etc/apt/sources.list.d/microsoft-prod.list
4.sudo apt update
5.sudo apt install dotnet-sdk-6.0
I just had this same issue when I wanted to install a new template dotnet new -i "Falco.Template::*". Simply reinstalling the dotnet 6 SDK solved it for me.

How to install .NET Core on aarch64 architecture Debian

I'm new to Linux and want to code some C# on Linux for school. The problem is I don't know how to install C#. I already read the instructions from Microsoft, but I couldn't get it to work.
'arm64' is the Debian port name for the 64-bit Armv8 architecture, referred to as 'aarch64' in upstream toolchains. The snapd daemon and tooling that enables snap packages is available for arm64 architecture in Debian.
To install snapd:
sudo apt update
sudo apt install snapd
Either log out and back in again or restart your system to ensure that snap's paths are updated correctly. After this install the core snap in order to get the latest snapd:
sudo snap install core
C# is open source and cross platform now that Microsoft has released a version of .NET Core. To install .NET Core in Debian open the terminal and type:
sudo snap install dotnet-sdk --classic
sudo snap alias dotnet-sdk.dotnet dotnet # to run dotnet-sdk type dotnet
The instructions from Microsoft seem to assume that you are running Visual Studio Code on Windows, so they frequently don't work at all on Linux. The following instructions were tested on a Debian-based system (Ubuntu 20.04). I ran a few C# console apps for test purposes, but let's start with a simple one-line C# console app. Run these commands to build and run an example C# Hello World console app from the terminal:
cd ~
mkdir C#_Projects
cd C#_Projects
mkdir HelloWorld
cd HelloWorld
dotnet new console
dotnet build --output ./build_output
dotnet ./build_output/HelloWorld.dll
Results of dotnet ./build_output/HelloWorld.dll
Hello, World!

dotnet core 3.1.0 not found on Raspberry Pi

I created a "Hello World" app and now I'm trying to run it on a Raspbarry Pi.
When I select "Self-containt" in publish, all files are copied to the Raspberry and I can execut the "Hello World" app.
But when I select "Framework-dependant" and publish the app to the Raspberry, I get an error message when I want to run it:
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.
- No frameworks were found.
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=arm&rid=raspbian.10-arm
But when I check the installed versions:
pi#raspberrypi:~/Desktop/ConsoleAppRaspberryPi1 $ dotnet --list-sdks
3.1.302 [/home/pi/dotnet/sdk]
[1] Exit 127 - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App
[2]- Done framework_version=3.1.0
[3]+ Done arch=arm
pi#raspberrypi:~/Desktop/ConsoleAppRaspberryPi1 $ dotnet --list-runtimes
Microsoft.AspNetCore.App 3.1.6 [/home/pi/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.6 [/home/pi/dotnet/shared/Microsoft.NETCore.App]
So I have a 3.1.0 SDK and a 3.1.6 Microsoft.NETCore.App runtime.
In Visual Studio dotnet core 3.1 is selected as target framework.
So why I'm not able to run it on the raspberry. Is a dotnet-core app targeting 3.1 not capable to run un a 3.1.6 runtime?
Can I compile it to run on core 3.1.6? Or should core 3.1 be able to run on runtime 3.1.6? 3.1 is the newest version I can find in Visual Studio installer.
Installing the dotnet runtime to /usr/share/dotnet solved the problem for me. Now it's possible to publish as Framework-dependant.

dotnet Core on ARM Cortex-A5 - "Illegal Instruction"

I have an Atmel dev kit, with an ARM Cortex-A5 processor in it. I have an application written for dotnet core that I need to run on it. I have successfully got Ubuntu 16.04 running on it (which I set up from these instructions).
As a comparison point, I've tried setting up and running a "hello world" dotnet example on a Raspberry Pi - this works fine. But, using the same steps on the Atmel board it always crashes with Illegal Instruction, and no further information.
I have downloaded the armhf binary for dotnet from the download page: https://github.com/dotnet/core-setup/, and have tried both the 2.0.5 stable release and the 2.1.0 preview, both give the same result.
I've made the simple example from the Microsoft website, then prepared it for Linux-ARM on my host machine with dotnet publish -r linux-arm. When I move the output to the dev board and try to run it, I get this:
$ dotnet --info
Host (useful for support):
Version: 2.1.0-preview2-26226-02
Commit: 40177995a6
.NET Core SDKs installed:
No SDKs were found.
The.NET Core runtimes installed:
Microsoft.NETCore.App 2.1.0-preview2-26226-02 [/home/ubuntu/dotnet/shared]
$ dotnet myApp.dll
Illegal instruction
Is there something I need to do for dotnet core on this ARM device? Or is this a bug that I should file?

Categories

Resources