cs-script icon indicating copy to clipboard operation
cs-script copied to clipboard

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

Open sken130 opened this issue 2 years ago • 1 comments

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.

sken130 avatar Oct 27 '22 08:10 sken130

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

oleg-shilo avatar Oct 27 '22 13:10 oleg-shilo

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

sken130 avatar Nov 04 '22 03:11 sken130

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.

oleg-shilo avatar Nov 04 '22 06:11 oleg-shilo