DEV Community

Calin Baenen
Calin Baenen

Posted on

How to update my .NET C# compiler (csc)?

So I recently figured my .NET compiler is outdated, seeing as it can't use static imports (using static ...), so I was here to ask, how do I update it?

I tried redownloading .NET, and looking up how to update, but neither of which were really helpful. So can someone explain the steps of updating?

Thanks!
Cheers!

Top comments (14)

Collapse
 
mileswatson profile image
Miles Watson • Edited

You can get the latest .NET SDKs from here: dotnet.microsoft.com/download

Alternatively, you can install visual studio, which should also install the latest SDK.

I recommend using the command “dotnet build” (or run) as opposed to csc, as the dotnet project workflow makes managing dependencies easy (especially when used with Visual Studio).

Collapse
 
baenencalin profile image
Calin Baenen

I tried this (as I thought I've said in the post), but csc.exe in C:\Windows\Microsoft.NET\Framework\<version>\ won't update (as in, a new verson folder won't be added (not the actual file updating)).

How can I get the new version folder, so I can add it to my PATH?

 
baenencalin profile image
Calin Baenen

So, how do I actually use any of that shit?

Primarily;
What happens if I don't make/have a csproj file?
Do I have to do anything with the file when it's generated?
Why the fuck is it always more complicated than just a language and the compiler/interpreter, why is all this bullshit here, when I just want to do something simple (similar concept applies to Java)?

Thread Thread
 
baenencalin profile image
Calin Baenen • Edited

I just generated whatever this bullshit is.

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net5.0</TargetFramework>
    </PropertyGroup>

</Project>
Enter fullscreen mode Exit fullscreen mode

LIKE, WHAT EVEN THE FUCK DOES THAT MEAN!?!?

Collapse
 
ollivuorio profile image
ollivuorio

I've battled the same issue and this is what I found out:

stackoverflow.com/questions/685189...

 
baenencalin profile image
Calin Baenen

So, then how do I use the modern CLI tool(s) (as far as I know, just dotnet) to compile my test.css?

 
baenencalin profile image
Calin Baenen

Can you explain what exactly this does?
I really don't understand, and I can't see why there isn't a dotnet compile <file)s)>.

Thanks for your help.
Cheers.

Thread Thread
 
mileswatson profile image
Miles Watson • Edited

Doing dotnet new console creates a new “console” project in the current directory.

It creates two files - a .csproj and a Program.cs file. The Program.cs file contains your code (you can add as many extra cs files as you want). The .csproj file contains information that helps the compiler understand how to build (aka compile) your project. For example, what libraries to use, what framework to build it for, whether to ignore certain warnings etc. The obj/ folder can be ignored.

In that project directory, you can use the command dotnet run to run your project. Alternatively, you can do dotnet build to compile it, and then you can manually click the exe in the bin folder.

It is worth installing visual studio, as it provides a nice interface to manage all this stuff.

 
baenencalin profile image
Calin Baenen

Why is it built to look like XML, though? Tgat shit is fucking confusing to understand, or remember.

It would have been btter if they made it look like, or be INI/JSON.

Thread Thread
 
baenencalin profile image
Calin Baenen

Can you send me a tutorial on how to use this?

 
baenencalin profile image
Calin Baenen

Uhhh, are you a bot? This is totally irrelevant.

Thread Thread
 
mileswatson profile image
Miles Watson

Don’t interact with them, just report as spam and move on.

Thread Thread
 
baenencalin profile image
Calin Baenen

Where's the "report" button?

Thread Thread
 
mileswatson profile image
Miles Watson

Three dots (top left of comment) -> report abuse.