Closed AlGantori closed 2 years ago
The problem you are experiencing is caused by the fact that your code is passing the compiler option /define
, which is invalid for the compiler engine that is the default for the current cs-script. Thus the engine you are using is dotnet.exe
but it does not accept /define
switch so it complains.
You can fix it by either dropping the that switch (//css_co /define:CS_SCRIPT
). CS_SCRIPT
will be defined unconditionally anyway.
Or you can switch to the old engine that is csc.exe.
You can control the engine with the //css_engine
directive.
//css_args /ac
//css_ng csc
Hi, thanks for the pointer removing the /define fixed that complaint. I found the main CSScript DOC/HELP here: https://github.com/oleg-shilo/cs-script/wiki
Info about compiler engines selection here: https://github.com/oleg-shilo/cs-script/wiki/Choosing-Compiler-Engine
Info about CLI arguments here: https://github.com/oleg-shilo/cs-script/wiki/CS-Script---Command-Line-Interface
My script is not running yet, I have the following next issue:
Could not load file or assembly 'System.Windows.Extensions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
By file-linking the same script file into a VS2019 solution I am able to run the exact same script inside Visual Studio without any errors.
Initially I thought the error above "Could not load file or assembly 'System.Windows.Extensions" had to do with the script imports, but after some wrestling I managed to re-reference the OFFICE and PowerPoint interop DLLs from Office 2013. Compiling and running worked fine under Visual Studio thereafter.
However, under VSCode / CSScript it compiles OK but the error above remains. Let me know if you have any ideas. Thank you.
It may have something to do with the .NET5 bridge mode for loading .NET Framework assemblies.
As a very naive fix try to put on top //css_winapp
switch. it will let the engine to do assembly probing in the windows desktop assemblies folder.
If it does not help then share with me the hello world script that exhibits this problem and I will have a look.
Thank you, that switch //css_winapp made it run without errors
All my projects target .NET 4.5.2 if that has anything to do with it??? (something I was forced the years to do, if my brain peanuts are right, I tried to target the lowest version).
Yes, it is directly related. //css_winapp
is a switch that forces .NET Core runtime to redirect the execution to the .NET Framework CLR, which is responsible for running windows applications.
And since you are actually targeting .NET Framework (4.5.2) the switch is what you need. BTW
Now trying to work in VSCode, the script was working a couple years ago.
That's all I get in the terminal, I can't tell which line(s) it's not happy with, let me know what you think. Thank you.
My scripts starts something like this