dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.92k stars 4.02k forks source link

Exe files are not executable on Linux #29529

Open thomasbehr opened 6 years ago

thomasbehr commented 6 years ago

Version Used: Microsoft (R) Visual C# Compiler version 2.7.0.62620 (e873e693)

Steps to Reproduce:

  1. Unzip HelloWorld.zip
  2. Run xbuild or msbuild on Mono 5.0+

Alternatively, change into the src directory and run csc HelloWorld.cs.

Expected Behavior: Executables produced by the C# compiler should have the executable permission set. This is still the behavior when compiling with mcs, but the change to use csc broke this behavior. Since Mono 5 uses csc instead of mcs from xbuild/MSBuild this is hard to work around when using build tools.

Actual Behavior: The executable HelloWorld.exe has the executable permission not set.

marek-safar commented 6 years ago

/cc @marek-safar

jcouv commented 5 years ago

@marek-safar Is the compiler responsible for setting such permissions or the build targets?

marek-safar commented 5 years ago

I am not sure what you mean build targets in this context but considering you can invoke csc directly it should produce runnable output

Nabile-Rahmani commented 4 years ago

I second this.

Recent Mono versions (perhaps beginning with v6) completely delete and rewrite compiled files on incremental compilation now, so my manual chmod +x I used to do gets cleared each time I recompile, so the issue is more jarring.

Making the compiler mark executable files (-target:exe and -target:winexe) as executable improves integration so users can run ./executable from the command-line or double-click to open the program, and link/copy said executable to their PATH and have it seamlessly work without requiring a shell script wrapper or prefixing with the runtime command (dotnet executable / mono executable) (thanks to https://en.wikipedia.org/wiki/Binfmt_misc).