C
C#10mo ago
MaeFire

❔ csc command not recognized?

I recently started setting up my environment for C# and dotnet for a new laptop. I am using VS Code, and downloaded the C# Dev Kit extension, which includes everything my home PC has. The dotnet command now works, but for some reason csc is not being recognized as a valid cmdlet, so I am unable to compile my .cs files into their executables. I've never had this problem, so I'm not sure where to start to fix this. Feel free to ask for more information, so I can provide screenshots and whatnot.
21 Replies
333fred
333fred10mo ago
Let's start with: why are you trying to use csc directly? You definitely do not want that dotnet build is how you build .NET projects. You don't invoke csc on individual files, that way lies madness
Angius
Angius10mo ago
Feel free to ask for more information
why dotnet commands work
MaeFire
MaeFire10mo ago
It isn't for just .NET projects. Sometimes I just want to build a small program to test output and a simple csc ProgramName.cs works for what I need.
Angius
Angius10mo ago
Use a repl then
MaeFire
MaeFire10mo ago
Or...try to help me fix the problem?
Angius
Angius10mo ago
https://github.com/dotnet/runtime/issues/12713 Use the full path to CSC Or add an alias, or add it to path, or something like that
333fred
333fred10mo ago
Do not use csc. I'm sorry, but this is not a scenario we support In .NET Core/5+, the hello world csc invocation has over 150 arguments csc ProgramName.cs does not work for what you need, and is not intended to work for what you need
MaeFire
MaeFire10mo ago
I never mentioned what I needed, so there are a lot of assumptions going on here, but the question literally is "why is csc not being recognized?" and I'm trying to get it to work. Instead of help, I'm being told "instead, just don't do it". I'm fairly certain you can see how that's a really poor response to the question, right?
Angius
Angius10mo ago
Well, the usual response to "my fork won't fit the outlet, how can I make it fit the outlet" is "don't do it, it's a bad idea"
333fred
333fred10mo ago
I can't say I agree that's a poor response, sorry. We very often get questions that are "how do I do unsupported thing", and the correct response to that is not "here's how you do the unsupported thing" For clarity, I am a member of the C# compiler team. When I say that we don't support this scenario, I mean it literally, the team behind csc does not support this scenario
MaeFire
MaeFire10mo ago
This is... An odd response. While I understand "we don't support it", the question remains "why is it not even being recognized as a command when it should be included in the framework downloaded?"
333fred
333fred10mo ago
Because we don't support it and don't want people getting the idea they should try and directly invoke it 🙂
Angius
Angius10mo ago
It makes perfect sense. It's not meant to be used, so it's not exposed
Aaron
Aaron10mo ago
it is effectively an internal tool to be used by the sdk, aka not for public consumption, so why include it in PATH
333fred
333fred10mo ago
Now, I do agree that a simple "Compile this cs file" thing would be nice to have. I'd love it if we get dotnet file.cs at some point But csc cannot support that
MaeFire
MaeFire10mo ago
In that regard, why does it work on my home computer, but not the laptop?
333fred
333fred10mo ago
And we do not have anything like this built in today You aren't opening the same terminal on your home computer you are on your laptop. On your home computer, you're opening the VS Command Prompt, which puts a number of framework tools on the PATH (Or VS Powershell. Either way, you're not opening the normal terminal) But importantly, the things it puts on your path are the .NET Framework versions of tools, not the .NET Core/5+ versions of tools
MaeFire
MaeFire10mo ago
This actually got me thinking, and I checked my JSON settings, and apparently it reverted my synced changes, so I wasn't utilizing my integrated developer powershell. Problem fixed, and now the command is recognized.
333fred
333fred10mo ago
I would highly recommend not using it for this anyway. Direct invocation of csc may "work" (for some definition of the word) on .NET Framework, but it absolutely will not work for modern versions of .NET. As I mentioned, a simple hello world for modern .NET has literally more than 150 arguments to csc
MaeFire
MaeFire10mo ago
I understand, but I also tried to iterate multiple times that I use it primarily for small programs and non .NET projects.
Accord
Accord10mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts