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

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.

Related

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

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.

On Mac M1 machine - Not able to run EF core Migrations Add ,Update in Asp.Net Core 3.1

I have recently got a Mac M1, I have to build a Microservice based Web API application on Asp.net Core using EF & SQL Server.
I added EntityFrameworkCore(5.0.11) through NuGet Package successfully. The sdk & runtime installed details on my Mac is:
.NET SDKs installed:
- 6.0.101
.NET runtimes installed:
- Microsoft.AspNetCore.App 6.0.1
- Microsoft.NETCore.App 6.0.1
Firstly , I was not able to install SQL Server 2019 on Mac but after searching I found a solution for that by installing SQL Edge on Docker & connecting to Azure Data Studio and it's working fine.
Now the problem is I am not able to run EFcore migration add initial, Update Database through Entity Framework. I searched everywhere but whenever I am executing these command, I am getting following error:
Build started... Build succeeded. It was not possible to find any
compatible framework version The framework 'Microsoft.AspNetCore.App',
version '3.1.0' (arm64) was not found.
- The following frameworks were found: 6.0.1
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.AspNetCore.App&framework_version=3.1.0&arch=arm64&rid=osx.12-arm64.
I did install the above framework but that is x64. And still EF command are not working and I am not able to update the database.
Is there any solution for this? Does EFCore work on Mac M1 machines?
The reason is that ef tool is not able to find the correct arch for now.
A workaround is to force ef tool to use the latest runtime found on your machine.
export DOTNET_ROLL_FORWARD=LatestMajor
export the above env var and run dotnet ef xxx again.
Update
This fixes the problem permanently:
dotnet tool uninstall dotnet-ef -g
dotnet tool install dotnet-ef -a arm64 -g
You can also install EF tool locally
CD to your source directory and do this:
dotnet new tool-manifest
dotnet tool install dotnet-ef
In this way, it works with the .Net 5/6 arm64.
There's a bug in the arm64 version installer that references the x64 version of EF Core.
Try to install proper SDK version manually from this link.
You need to use the sdk version for your cli,.NET 5 and below installs in a different directory and from your output looks like you cli points to .NET 6. You should install the ef tools locally like so
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local dotnet-ef --version 5.0.15
then,
/usr/local/share/dotnet/x64/dotnet ef migrations add initialCreate -s ../API -o Migrations
You can shorten the path by using this article https://dev.to/smiththe_4th/use-multiple-net-sdk-cli-commands-on-mac-m1-64j

VSCode autocompletion for C# on Ubuntu

I am trying to setup an environment to code a Unity projet on my Ubuntu 20.04 computer.
I want to use VSCode to write my C# code. As required, I installed .NET SDK 5.0.201.
So, I tried to run some code but VSCode does not seem to recognize my .NET installation. Every time I open VSCode, I get the following message :
The .NET Core SDK cannot be located. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path.
And (the main problem), I do not have auto-completion on my C# code.
I don't really understand what is the problem here. .NET is correctly recognized in my terminal (both ubuntu terminal and terminal inside VSCode)
>> dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.201
Commit: a09bd5c86c
Runtime Environment:
OS Name: ubuntu
OS Version: 20.04
OS Platform: Linux
RID: ubuntu.20.04-x64
Base Path: /snap/dotnet-sdk/116/sdk/5.0.201/
Host (useful for support):
Version: 5.0.4
Commit: f27d337295
.NET SDKs installed:
5.0.201 [/snap/dotnet-sdk/116/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.4 [/snap/dotnet-sdk/116/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.4 [/snap/dotnet-sdk/116/shared/Microsoft.NETCore.App]
What am I missing here ?
EDIT
The C# extension can't load either and give me the following message :
The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/path/to/my/project/Assembly-CSharp.csproj'.
/path/to/my/project/Assembly-CSharp.csproj
/home/me/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1180,5): Error: The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
I finally found the answer !
In VSCode setting, I configured
"omnisharp.useGlobalMono": "always"
Instead of
"omnisharp.useGlobalMono": "auto"
And it did the trick

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.

Can't create a web app with .NET Core 3.1 on Visual Studio (Mac)

I'm brand new to Visual Studio IDE and learning C#. I'm following Microsoft's Web apps/Razor Pages Tutorial and i've already installed Visual Studio and dotnet 3.1
I'm attempting to start a new project but for some reason I can't seem to click the "create" button. Nothing happens. I am able to create a project with 3.0 but this causes some versioning issues with eventual packages that I'll be installing.
Here's information on my dotnet versioning:
dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.1.100
Commit: cd82f021f4
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.15
OS Platform: Darwin
RID: osx.10.15-x64
Base Path: /usr/local/share/dotnet/sdk/3.1.100/
Host (useful for support):
Version: 3.1.0
Commit: 65f04fb6db
.NET Core SDKs installed:
3.0.101 [/usr/local/share/dotnet/sdk]
3.1.100 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
And here is where the project creation is halted:
Visual Studio Mac will only support .net core 3.1 with the new version 8.4.
You can switch the update channel to preview and do the updates. After installing the preview updates the creation of projects with .net core 3.1 works for me.
What I've done as a workaround is create the project as dotnet core 3.0. And then simply edit the csproj files to target 3.1:
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

Categories

Resources