0

I would like to compile myProgram.cs into myProgram.exe.

I know the C:\Windows\Microsoft.NET\Framework64\<version number>\csc.exe file exists that is just doing that, but it is not using the latest framework version. AFAIK, starting from .NET 5.0, C# uses dotnet.exe build to compile.

However, this command requires a C# project *.csproj as an input, while I want to compile only a single file.

I have found this related topic, but it seems to have only answers concerning Linux. I do not have a csc.exe file under C:\Program Files\dotnet\sdk\7.0.203\Roslyn\bincore or elsewhere in the SDK.

Where could the csc.exe be located? Or what command would be its equivalent for C# running on .NET 5.0+?


I tried to find all my csc.exe using Everything, but I can't seem to find a relevant one. It's worth nothing that I do have a few csc.exe files under specific software paths like:

  • C:\Program Files\Unity\Hub\Editor\2020.3.30f1\Editor\Data\MonoBleedingEdge\lib\mono\4.5\csc.exe
  • C:\Program Files\JetBrains\JetBrains Rider 2021.3.3\tools\MSBuild\Current\Bin\Roslyn\csc.exe
  • C:\Users\\Perforce\\Engine\Binaries\ThirdParty\Mono\Linux\lib\mono\4.5\csc.exe

Perhaps I could use these csc.exe instances as a workaround, but it does not solve the issue.

I also tried to use dotnet build, but I cant find a way to compile a single CS file with it.

I have found this related topic, but it doesn't solve my issue, since I am

  1. Using Windows instead of Linux
  2. Not seeing any scs.exe file a the specified path
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Reelie
  • 3
  • 3

0 Answers0