Bash terminal in Visual Studio dotnet not found - .net-core

I have debian 11 installed in wsl2 on windows 10. I use the dotnet cli tools in visual studio and cmd windows but much prefer the linux syntax. The sdk commands are not exposed to wsl apparently as I get "bash: command dotnet not found" errors. Because WSL is essentially mapping linux commands to windows I don't think I should be installing the dotnet sdk again for linux, but can't really find any confirmation of that. Anyone here doing this who can advise? Just don't want to have to maintain two sets of the dotnet sdk if WSL does not require it.

The sdk commands are not exposed to wsl apparently as I get "bash: command dotnet not found" errors.
That's because WSL does not run Windows executables - it is, after all, a Linux subsystem.
I don't think I should be installing the dotnet sdk again for linux
You have two choices:
Use the Windows subsystem (drop WSL),
install the Linux applications you want to run.

Related

How do I use Visual Studio 2019 to remotely debug a .NetCore application on a Hyper-V Linux VM?

I am attempting to remotely debug a .NetCore application in Ubuntu Linux from Visual Studio 2019 in Windows 10. I can see the remote ipaddress (ping thru command line). I can RDT to the ipaddress. I can successfully transfer files to it via WinSCP.
I created a simple .NetCore "HelloWorld" app and copied onto the Linux VM.
I used the following commands to build and publish:
dotnet build -r linux-x64
dotnet publish --self-contained -r linux-x64
I ran the following command on the Linux VM to ensure that ssh is functional:
sudo apt-get install openssh-server unzip curl
The app is running on Linux.
From VS I try to attach to the process:
I get prompted for logon:
I get the following error:
Is there a step I'm missing somewhere?
Is there a configuration/permissions issue I am unaware of?
Thanks, JohnB
Microsoft has documented debugging a Linux target from a Windows development machine at https://learn.microsoft.com/en-us/visualstudio/debugger/remote-debugging-dotnet-core-linux-with-ssh?view=vs-2022
Unfortunately, using that method, you will need to manually deploy and manually attach the debugger. If you'd like Microsoft to change that, then it would be wise to upvote this issue: https://developercommunity.visualstudio.com/t/Convenient-way-to-add-a-remote-debug-con/917516
A 3rd party developer has created a Visual Studio extension that provides this missing feature to Visual Studio. It can be downloaded from https://github.com/radutomy/VSRemoteDebugger
I had the same problem initially because I didn't enter the connection target in the first screen.
After having entered the correct target myusername#192.168.178.95 in the first screen the second screen did not show up any longer and I got the expected list of processes

'Command not found' when running .NET Core console in Ubuntu on Windows Subsystem for Linux

I have downloaded .NET Core 3 (preview) and I have in Visual Studio 2019 (preview) created a hello world project consisting of class library and a console program. The program runs on Windows.
I have Windows Subsystem for Linux running Ubuntu 16.04 and I install dot net so that dotnet --info returns something (non error). Are there any other steps required?
If I go to my console apps binary folder and then shift+right mouse button click to get the 'Open Linux shell here' menu item and take that option then my Ubuntu window opens in the same directory as the console app executable.
From the bash prompt if I type the executable name (either with or without.exe) and of the correct casing it just reports 'Command not found'.
I am wondering what step I have missed.
The executable name is not a known command to the shell. You need dotnet <EXECUTABLENAME>

Dotnet core 2.1 code build for Linux from Windows machine

I am creating a dotnet core 2.1 mvc application. I use win 10 as development machine but my prod server is Linux. Is it OK to Build it on Windows machine Or should I use a Linux box to build and then deploy on prod? Any execution or references or performance issues I might face?
You cannot build on Windows and deploy the same on to Linux.
For eg: dotnet build --runtime ubuntu.16.04-x64
Look into the following on how to build specific to linux

What is the best way of installing dotnet core on a raspberry pi?

This method
https://blogs.msdn.microsoft.com/david/2017/07/20/setting_up_raspian_and_dotnet_core_2_0_on_a_raspberry_pi/
leaves me with a problem... when I do
pi#raspberrypi:~ $ dotnet --version
I get the following statement... and no version
Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
If I do (as the link suggests) and use this protocol https://www.microsoft.com/net/core#linuxdebian
then when I do the install step
sudo apt-get install dotnet-sdk-2.0.0
then the package is not found.
.NET Core distributions come in two variants. The Runtime and the SDK. dotnet figures out whether you want to use the Runtime or the SDK and dispatches your command to the right place.
The error you see is because --version is an SDK command [1]. dotnet tries to redirect it to the SDK, sees there is not SDK around, and suggests you install it.
If you have a dotnet command that seems to do something, chances are you installed it correctly already!
If you just want to see that dotnet works, try dotnet --info, instead:
$ dotnet --info
Microsoft .NET Core Shared Framework Host
Version : 2.0.0
Build : N/A
For Raspberry Pi devices, only the Runtime is available. The SDK, even if available, would probably be too slow and a bit too resources intensive to provide a good experience. So the suggestion is to use the SDK on another computer (say, Linux on Intel x86_64) to target the raspberry pi runtime (dotnet publish -r linux-arm -c Release) and then copy and run it on Raspberry Pi (dotnet /path/to/published.dll).
[1] I think it is completely silly and wrong. But such is life.

Is it possible to run .NET Core on Raspberry PI?

I've heard that .NET Core could run on Linux and Mac as well. I am currently using Mono on Raspberry PI. Is it possible or will it be possible to run .NET Core on Raspberry PI?
I have managed to run .NET Core 2 app on Raspberry PI 3 with Raspbian.
I have followed https://github.com/dotnet/core/blob/master/samples/RaspberryPiInstructions.md and https://github.com/dotnet/core/issues/447:
On my laptop:
Install .NET Core 2.0 SDK
Run
mkdir helloworld
cd helloworld
dotnet new console
Edit helloworld.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifiers>win-arm;linux-arm</RuntimeIdentifiers>
</PropertyGroup>
</Project>
Run
dotnet publish -r linux-arm
On Raspberry PI 3 with Raspbian:
Run sudo apt-get install libc6 libcurl3 libgcc1 libgssapi-krb5-2 libicu52 liblttng-ust0 libssl1.0.0 libstdc++6 libunwind8 libuuid1 zlib1g
Then copy ./bin/Debug/netcoreapp2.0/linux-arm/publish from my laptop
[Modified permissions of helloworld]
Run ./helloworld
Now you can run dotnet core on Raspberry PI.
In order to do that you need to:
Cross-compile coreclr & corefx (possible on Linux x64 machine)
Extract the dlls without the private and precompiled files to the PI
Copy your app's managed dlls to the PI
Use "corerun" executable to run your app
If you want to skip the above and get a ready made binaries for the Raspberry PI 3 (or even the entire image), you can use my compiled build at:
http://ravendb.net/promo/xmas-win-raspberry-pi
Note:
I was able to do that on Raspberry PI 3, using Headless Ubuntu Server 16.04 and with Ubuntu Mate 16.04. I presume additional steps (i.e. installing additional packages) needed to be done on Raspbian OS and PI 2.
Links for Cross Compilation (on Ubuntu 16.04 x64 machine):
coreclr : https://github.com/dotnet/coreclr/blob/master/Documentation/building/cross-building.md
corefx : https://github.com/dotnet/corefx/blob/master/Documentation/building/cross-building.md
A video I made with "how to" get the binaries (which includes our app):
https://www.youtube.com/watch?v=DPxCVDOUlT8
Now or soon it will be possible because Microsoft announced CoreCLR is available on GitHub.
Today, .NET Core builds and runs on Windows. We will be adding Linux and Mac implementations of platform-specific components over the next few months. We already have some Linux-specific code in .NET Core, but we’re really just getting started on our ports. We wanted to open up the code first, so that we could all enjoy the cross-platform journey from the outset.
I would have made a comment but since i can not i am posting as an answer and i think the accepted answer should be updated.As it is possible now since this checked into coreclr https://github.com/dotnet/coreclr/pull/1210
This was all a community effort although this is still very rough (exception handling and debugging not supported yet) so you would not be able to go far with it as a solution, but eventually it will get there.
Dated: 7/26/2015
Microsoft have made the source to .NET Core available. For an actual Linux or other non Windows implementation you will most likely still use Mono or one of the Xamarin products. As they contain broader support than just the Core functionality. Xamarin are taking the .NET core source and using it to fix holes and bugs in their .NET implementation. Microsoft are making also Visual Studio Mono/Xamarin friendly and it will come with Xamarin's trial/base product for mobile development in a yet to be released version of VS.
See http://tirania.org/blog/
Edit -> Additionally it sounds like Microsoft are doing a free version of Windows 10 for the board. which will also run .Net.
Is it possible or will it be possible to run .NET Core on Raspberry PI?
Not yet AFAIK but CoreCLR has code for at least some versions of the ARM architecture. Raspberry Pi 2 would be a better bet.

Resources