dotnet command is not found in my Mac m1 terminal - c#

I have downloaded .net5 from official website, but dotnet command isn't recognised by my terminal.
Here's what I have found after some research-
my dotnet folder is present in /usr/local/share/dotnet
I used this command but it didn't work sudo ln -s /usr/local/share/dotnet /usr/local/bin/dotnet
now whenever I enter dotnet in terminal it shows zsh: permission denied: dotnet
I also tried this command and it didn't work sudo ln -s /usr/local/share/dotnet /usr/bin/dotnet
now whenever I enter dotnet in terminal it shows zsh: command not found: dotnet
when I open my .cs file in vscode it shows error as 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.
here's a screenshot for reference
What should I do :(

Had the same(ish) issue after installing .NET 6 broke my current .NET 5 installation.
I fixed it by:
1. removing all files of the current dotnet installation.
This is done by deleting the dotnet folder located in /usr/local/share/
(Navigate there using Finders 'go to' feature, or just delete it using the terminal)
2. reinstalling the dotnet sdk
download from https://dotnet.microsoft.com
3. adding a symlink to the current dotnet executable.
sudo ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin/
ℹ Note that the path to the dotnet executable is different from what you tried. Seems like a subfolder was added (/x64) at some point.

I was having issues today with this on my MacBook Air M1. Saw that lot of people were suggesting to use
sudo ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin/
However, this didn't work for me. I looked in the /usr/local/share/dotnet/x64/dotnet dir, and the x64/ dir was not there. Which means that linkng was not going to happen.
So my solution was to take out the x64/ from the path from the command. Then I ran the dotnet command to verify. This worked for me.

Somehow I did not had the access to share folder, but you can grant access to the local user.
The dotnet is located in /usr/local/share/dotnet/dotnet on ARM64
So be sure to symbolic link the path right.
Also sudo dotnet if running terminal inside Visual Studio Code

Related

Can't locate SDK - VSC

My initial error, in fact, comes from Unity that when I open a script (C#) from it to Visual Studio Code, it opens the code without "auto-completing" my lines of code, which makes learning more difficult.
To solve this problem, I used several tutorials, but none helped. That's why I decided to solve another problem that always appears when I open the Microsoft App, which is "The .NET Core SDK cannot be located: A valid dotnet installation could not be found.".
I installed the dotnet 6.0.44 version on my linux (zorin os 16.2) from commands on the official website and the OS identified it. However, no matter what I do, Visual Studio does not recognize it, not even in the terminal does it find it .
command contradiction
Dotnet version
obs:
Already re-installed SDK
I've had the same error on Zorin OS and other Ubuntu based distributions,
you have to install the SDK by this command:
$ sudo apt-get update && sudo apt-get install -y dotnet-sdk-7.0
If this gives you any errors, read the documentation here.
You can view your installed SDKs by executing
$ dotnet --list-skds

Installed Dotnet tools give error "Could not execute because the specified command or file was not found." on Ubuntu WSL2

I'm working on an api in .net core 5 in wsl2 and I followed all the documentation to install the entity framework core tools.
when i run
dotnet tool list -g
it prints
Package Id Version Commands
--------------------------------------
dotnet-ef 5.0.7 dotnet-ef
but when i run
dotnet ef
or any of its child commands, I get this
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-ef does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
now, i've looked in my path and it looks like when i ran
dotnet tool install --global dotnet-ef
it installed it under my C drive instead of inside wsl2 which I think might be the problem but I don't understand why running that within ubuntu would install it into my windows directories but this is the line from my path
/mnt/c/Users/ethan/.dotnet/tools
so i guess my question is, is the issue that it unstalled under my windows directories and if so how do i either force it to install on ububtu or change my path and if not what is happening.
i found this post:
Cannot find command 'dotnet ef'
and running
export PATH="$PATH:$HOME/.dotnet/tools/"
makes dotnet ef work until i start a new terminal session so i wanted to double check the right way to make this a permanent fix, according to this article i found https://astrobiomike.github.io/unix/modifying_your_path the best way to handle it is just to add it to your bash_profile or zshrc so thats what i did

Issues "getting started" with Blazor

I'm trying to "get started" with Blazorfollowing Microsoft's guidelines,
I've installed the .NET Core 3.0 Preview SDK as indicated,
but then I try to run the command
dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.0.0-preview5-19227-01
respectively from terminal and powershell both as admin and not,
getting this error:
Did you mean to run dotnet SDK commands? Please install dotnet SDK from:...
I proceeded anyway installing Visual Studio Preview (with Blazor Extension)
to be able to run the command form the Visual studio terminal,
but I'm simply getting this error:
Command "dotnet" is not valid.
Looks like doesn't recognize the installed SDK (3.0 or previous),
any idea how can I solve the issue? thanks in advance
I imagine if you've got multiple of the same executable in your path then it can't resolve which one you're trying to call.
Try manually using the full path to the .NET Core 3.0 SDK dotnet.exe in a command line e.g.
"C:\Program Files\dotnet\dotnet.exe" new -i Microsoft.AspNetCore.Blazor.Templates::3.0.0-preview5-19227-01 (you can use dotnet --version to find the version of the exe if you're unsure which is which)

dotnet cli command make nothing in cmd after install dotnet core 2.0

I have install and repair dotnet sdk 1.1 and dotnet sdk 2.0 preview with visual studio preview,
Now when I type any command CLI, I have no result.
PS C:\Codes\Anna\src\Web\test> dotnet new
PS C:\Codes\Anna\src\Web\test>
I have test to run with administrator but this not working.
Or with this command
PS C:\Codes\Anna\src\Web\test> dotnet --info
PS C:\Codes\Anna\src\Web\test>
My path is :
PS C:\Windows\system32> (get-command dotnet).Path
C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\dotnet.exe
The path is wrong. C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1\dotnet.exe is only used to run compiled .Net Core 1.0 applications. You want to use C:\Program Files\dotnet\dotnet.exe, which will let you run the SDK commands, like dotnet new.
I don't know how did the wrong dotnet.exe get into your PATH. Are you sure you installed the SDK, and not just the runtime?
If you think it could be a bug in the installer, you might consider reporting it at the dotnet/core-setup repo.

Adding an assembly reference in Visual Studio Code

I'm just working on a web project in VS code. I'm used to using the full blown IDE, but I'm developing for Linux, so I'm trying to see if I can accomplish the same things in VS code.
Basically it's gotten to a point where I need to add System.Web so I can use stuff from there, but I'm struggling to find how to do it. Usually I'd just right click the solution and go Add assembly reference, and all the .NET assemblies would be there.
I've found this answer, and I've added "System.Web.Http.Common": "4.0.20126.16343" to my project.json file. I can't find the dnu restore command though. I've read that it's deprecated, but can't find solid info on how to either install it or use its replacement if so. Is anyone able to help me?
EDIT: Sorry, I should mention I'm using Mono.
dnu-restore is now dotnet-restore. You can find the help here
And if you're still using the rc1.0 version the details on dnu-restore is https://github.com/aspnet/Home/wiki/DNX-Utility.
If you are on Windows right now:
In case .net core is not installed in your machine follow the guidelines here
To have the CLI's anyway, you'd need .net core SDK which can be found here
Open VS2015 Developer command prompt or your command prompt in administrator mode (preferably)
To create a new app: dotnet new
To run an existing app: dotnet restore and then dotnet run
If you are on an Ubuntu right now:
To add the package source for Ubuntu 14.04:
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
sudo apt-get update
And for Ubuntu 16.04:
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
sudo apt-get update
Then you can install it using:
sudo apt-get install dotnet-dev-1.0.0-preview2-003121
The new .NET Core SDK restore command is dotnet restore
To install the latest .NET Core SDK (Preview 2 version) and add any asssembly reference in Visual Studio Code, please refer to my post at How to add System.Data and System.Timers assembly references in Visual Studio Code 1.8?

Categories

Resources