August 29, 2024

C# on linux -- installing Visual Studio Code

I did this once a year ago. However, a disk died on my Fedora system. I did a full Fedora reinstall on a new disk and never did reinstall VS-Code. So here we go.

It tip up front -- install "dotnet" first. This comes from the Fedora package system (see below under "Get .NET"), then install visual studio Code. This is not essential, but I think will smooth things out.

Just like the last time, the following link offers a download of Visual Studio Code for Linux

And there are a variety of resources to learn about it. I download the current file and get 1.92.2 rather than 1.77.1 It is somewhat bigger (143M rather than 120M).
I do this:
su
#dnf install code-1.77.1-1680651749.el7.x86_64.rpm
dnf install code-1.92.2-1723661076.el8.x86_64.rpm

Indeed after I do this I can type "code" at the command line and it launches. It is version 1.92 as per July, 2024. It tells me it cannot find "dotnet" and also tells me it cannot find the .NET Core SDK. It offers a button to "Get the SDK" which sounds good to me (it indicates "Source: C#" alongside this button.) Once I click the button it tells me that it needs dotnet to do this. It fires up a website to download the .NET SDK

Get .NET

This has a list of packages (including Fedora 40). As per their instructions, I do this:
su
dnf install dotnet-sdk-8.0
Much to my surprise, this works. It installs 10 packages, pulling them from the regular Fedora package repositories.
And now I can type "dotnet" at the command line as before my disk crash.
As per their instructions, I do:
tom@trona:/u1/home/tom$ dotnet --list-sdks
8.0.108 [/usr/lib64/dotnet/sdk]
tom@trona:/u1/home/tom$ dotnet --list-runtimes
Microsoft.AspNetCore.App 8.0.8 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.8 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
tom@trona:/u1/home/tom$
They told me that if I install the SDK, I will also get the runtimes and won't have to install them separately.

I restart code. It is talking about "ionide" and has rediscovered some F# project from before my disk crash. It shows me "Program.fs". Using locate, shows me:

/u1/home/tom/C#/FirstIonideProject/Program.fs
/u1/home/tom/C#/fsample/src/App/Program.fs
I should watch their instructional videos.

I did this to get past my old mess:

cd /u1/home/tom/C#
mv FirstIonideProject/ XXX
code
Now it comes up clean giving me a welcome screen with a nice greeting, start buttons, and links to Walkthroughs. This is better.

Extensions

On the left edge of VS-code is an icon that looks like 4 squares with one of the four moving off to the northeast. I click on this and get offered a big list of extensions. It shows a bunch that are already installed (many begin with .NET Core). And C# Dev Kit and C# Base language support are already installed.

Then it has some that it calls "recommended". Right away "Vim" catches my eye. I select this and info about it fills the main screen, and includes an "install" button. This could not be easier. It seems to take less than 1 second. It also suggests "GitLens", but I will hold off on that.

Walkthroughs

The first is "Get Started with VS Code". I choose "light modern" as a color scheme. Next under language extensions (it offers Python, Go, PHP, Ruby), I admire various options, but do nothing. In settings, I bump the editor font size from 14 to 20.

Ctrl-Shift-P is the "command palette" and promises to be useful

Ctrl-K Ctrl-O lets me pick a folder (I go to /home/tom/c-sharp)

But when I am done with these walkthroughs, I am stuck looking at a file in the c-sharp directory I selected and it does not think it is a project.

Help -- Welcome seems to get back to the welcome screen with walkthroughs. The next is "get started with C# Dev Kit.

Introductory videos

After thrashing around some, I decided that I would be well served to slow down and take the time to watch these introductory videos. I have started watching the first and it is not very good. It is not planned or well organized, they just sort of jump in, fool around, and tell you some things along the way.

C# development and Microsoft sign in

I have the C# Dev kit installed as an extension, but apparently it won't work until I activate it: It is not clear how a person really should get this started. I thrashed around with VS Code until I found the C# Dev Kit welcome page and it had a linke to "Connect account". It gives me a button that says "Connect" and when I click that, it launches my browser and takes me to a Microsoft site asking me to log in.

This whole process is buggy as hell. I can login and then it tells me "you can close this page", which I do, but this terminates the whole process. I login again and get some notification from my browser that it cannot reach 127.0.0.1 (i.e. localhost). Of course I can ping 127.0.0.1 -- maybe it expects port 80 to respond? (I discover later it is trying port 39501, but perhaps this changes every time?)

Now I go all the way back to VS Code and try the Connect button again and it tells me that the software is licensed to me under an individual license. So apparently I am "connected" now, despite the confusing nonsense that went on in the browser. All is well that ends well I guess.


Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org