oleg-shilo / cs-script

C# scripting platform
http://www.cs-script.net
MIT License
1.57k stars 234 forks source link

Can we compile script into console application executable using csc or roslyn engines? #314

Closed sken130 closed 1 year ago

sken130 commented 1 year ago

I tried "C:\cs-script\netcore\cs-script.win.v4.4.7.0\cscs.exe" -e -engine:csc "MyScript.cs" but if MyScript.cs contains //css_co -nullable:enable -warnaserror:nullable, then it gives error MSB1001: Unknown switch.

This makes me think it is not using the csc engine to compile the script into execute file.

oleg-shilo commented 1 year ago

Correct. It is because csc.exe cannot build exe so the building assembly is tunnelled to dotnet.exe engine instead.

https://github.com/oleg-shilo/cs-script/blob/8edd2d3cc18caf76ad59535fe16a035fc8cdb8eb/src/cscs/CodeDom/Proxies.cs#L97-L101

Though despite having a good reason for this behaviour it must be reflected in the documentation but it's not. The code has been updated and the enhancement will be available in the very next release

sken130 commented 1 year ago

Thanks for the update. Also, I suggest mentioning the same thing in this wiki: https://github.com/oleg-shilo/cs-script/wiki/CS-Script---Command-Line-Interface

oleg-shilo commented 1 year ago

Yes but only when the release is out. This page is generated from css -? so when the release is out the page will be refreshed as well.