-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet is not able to run programs compiled with csc #90080
Comments
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov Issue DetailsDescriptionrunning
returns
But running
I can run my program correctly, no matter if it's been generated, by csc, dotnet, or any other C# compiler. Reproduction StepsTry to run a C# program not generated by dotnet ./Program.exe Expected behaviorIt should be able to at least run the program, no questions asked. Actual behaviorError asking for runtimeconfig.json Regression?Using the Known WorkaroundsNo response ConfigurationNo response Other informationAditionally, dotnet is only able to run the executable if it has .exe or .dll extension, which again is not an issue found in the mono interpreter.
|
dotnet requires $ csc -version
4.6.0-3.23259.8 (c3cc1d0c)
# compile code with physical file
$ csc Program.cs -nologo -out:Program.exe
# csc now also supports reading code from stdin
$ csc - -nologo -out:Program.exe <<EOF
using System;
Console.WriteLine("Hello World!");
EOF
$ csc_run Program.exe
Hello World! |
Thank you @am11, that script is great, and it should certainly be the way dotnet behaves by default. I'm the author of compiler.nvim, which allows building C# programs with csc (for projects without a csproj file), or dotnet (for projects with a .csproj file). And when compiling with csc, I'm currently forced to include the mono JIT compiler as dependency, so the user is able able to run the program (which is currently abandonware). This shouldn't be necessary. Dotnet should at least try to find the necessary .NET version to run, as the mono JIT has been doing successfully for many years. |
That would be nice if dotnet fallback to the default configurations to enable this scenario. @elinor-fung, what do you think about changing the default behavior, or supporting the existing SDK option @Zeioth, in the meanwhile, you may want to generate the runtimeOptions in json like |
The .exe alone does not have sufficient information to reliably identify necessary version to run. We do not want to introduce an experience where the host guesses a version and then the program fails sometime later with cryptic error because of it requires a newer version. dotnet/designs#296 is related to this. |
@jkotas In that case adding an option to The most important case of use is being able to run the executable generated by |
Building of binaries for modern .NET is meant to be done by calling |
I was proposing to reuse
Well, there is clearly a demand to do things faster for IDEs and other continuous build pipeline scenarios where |
There is nothing that guarantees that the current runtime is sufficient for the app.exe. You are right that the runtime does not need to guess in this case, but the experience when the current runtime is not sufficient to run the app.exe is still poor.
If people believe that they can do better and want to ship what msbuild does for them, they need to duplicate it on their own.
This does not look like a problem with msbuild. It looks like a problem with crossgen2 and with how godbolt invokes it. |
By forcing the user to do You write a If we cannot achieve this, it's gonna impact the language adoption. |
This is what dotnet/designs#296 proposal that I have linked above is trying to address. |
I'd rather not add anything on the host side that just tries to use the latest runtime installed. It'd have no idea if that version is what is needed, there are other dependencies, it uses other shared frameworks, etc. I think we should stick with dotnet/designs#296 for this experience. |
Fair enough. I guess folks into unix-y tools would appreciate this kind of experience, but if it too complicated to implement (with reasonable limitations), then it's probably not worth it.
I think in that case, application will fail to run and user will get similar experience when there is an unavailable or incompatible version specified in Once upon a time, we implemented dotnet/roslyn@f4f3aa7, and I very much wanted to compile and run code from stdin (like native and many platform compilers support), but after the Roslyn episode, I couldn't find a way to hook that into SDK and msbuild (for one, System.Commandline was missing stdin support and then there was MSBuild's requirement of physical file). Ever since, I have that csc alias in my portable .profile file. Working like a charm for a handful of .NET releases (at least for simple stuff). 🙂 |
Closing as not planned. dotnet/designs#296 is the closest proposal for this experience. |
Description
running
returns
But running
mono Program.exe
I can run my program correctly, no matter if it's been generated, by csc, dotnet, or any other C# compiler.
Reproduction Steps
Try to run a C# program not generated by
dotnet
using the dotnet interpreter like:Expected behavior
It should be able to at least run the program, no questions asked.
Actual behavior
Error asking for runtimeconfig.json
Regression?
Using the
mono
interpreter.Known Workarounds
No response
Configuration
No response
Other information
Aditionally, dotnet is only able to run the executable if it has .exe or .dll extension, which again is not an issue found in the mono interpreter.
The text was updated successfully, but these errors were encountered: