Closed AlGantori closed 4 years ago
Sorry, I'll need some time to get through the info you provided. And answer all your questions one by one.
But something has definitely changed in VSCode. The extension is broken now and it has nothing to do with the extension itself as it has not been changed since Mar 18, 2019. Though unfortunately it's not so uncommon with VSCode. :(
Will have a look tomorrow
I think I have found it.
The problem is quite nasty. It was introduced by the changes in the latest/later version of VSCode. However the problem itself is ultimately caused by the ugly nature of JS runtime, not by the VSCode team changes.
This is what happens:
CS-Scriprt.vscode had this line of code:
let exec = require("child_process").exec;
. . .
process = exec(command);
Note that I missed it and did not use neither var
nor let
, what is of course is totally legal in JS.
It worked in prev versions of VSCode but I am guessing recently VSCode team introduced global variable process
:
Meaning that the extension really messes up with the IDE. And it does it so spectacularly that the instance of IDE being debugged crashes completely. This way (under debugger) I was able to pinpoint the offending code line.
Fixing the declaration as below has done the trick:
let exec = require("child_process").exec;
. . .
var process = exec(command); // it's local variable now
The version v1.5.11 should be OK now
A quick test make it a fix. It looks like you are understanding and doing a great job with all this JS stuff :) I jumped into Ionic framework and TypeScript couple years ago, and I dumped all the promises of Microsoft for cross-platform development just to find more headaches :). On the upside I only have to deal in general with three things HTML, TS and CSS.
May I point out few suggestions.
A
Include the extension version and date somewhere here as it is hard to spot in the extension list.
B Please put a heading into the main GitHub page "Documentation / Help" it's fine if it is just a link to the Wiki, which I did not existed as a tab :) in GitHub. I eventually found the mention to look into the cscs.exe command line help. I was after directives.
So it looks like define/option CS_SCRIPT is not longer around? I doubt it's something I created?
From what I can recall I was using it to switch between debug stepping the script and my assemblies from Visual Studio 2013 then. Also handling things like MessageBox either coming from Winforms or WPF.
For today's run I had the remove the Not/Bang "!" as in:
#if ! CS_SCRIPT
to get it to compile in VSCode.
UPDATE: Never mind, I deleted the crucial line by mistake which I have in my other scripts. After all it is my define.
// -) detect if we are running as a script, then define a main()
//css_co /define:CS_SCRIPT;
Does VSCode pickup the location of CSScript extension from the path?
Is the path something that has to be re-adjusted with every update/revision?
C:\Users\AXM\.vscode\extensions\oleg-shilo.cs-script-1.5.11\bin
Thank you for all the assistance and effort you put into this.
Now, let's answer our questions:
And starting from the next release the changelog will include dates. All is prepared for that: CHANGELOG.md. Good suggestion.
Now available on GitHub: https://github.com/oleg-shilo/cs-script.vscode/blob/master/README.md
Is the path something that has to be re-adjusted with every update/revision? No, the extension deploys the binaries in the corresponding folder on first load. You don't need to do anything about it.
Searching C:\ reveals the following:
Just to give you the context:
#1
is the engine deployed by the VSCode extension and it is the one that VSCode runs with the scripts.#2
is the repository of the VSCode unpacked extensions. This script engine binary is only used as a source for #1
.#3
is the engine deployed by the Notepad++ plugin. Not used by VSCode at all :)Thanks for all the answers and additions. Regarding the path one more clarification is needed. It does not appear the installation/update of the extension adjusts the system env. variable path and since VSCode will use path #1 above, then that's the one I need to manually fix my system path with, it appears stable. This is just in case I need cscs.exe from the command line, really no plan for that.
Sorry about path #3, that was remnants from my first days with CSScript plugin in NPP. I no longer intend to use CSScript from NPP with VSCode being around, so I have deleted manually that plugin.
You may close this issue with this bit of info as it completes the title of this issue. Thanks again.
It does not appear the installation/update of the extension adjusts the system env. variable path and since...
It does not use custom envars it starts the process with an absolute path:
export function user_dir(): string {
let extensionRoot = path.dirname(path.dirname(path.dirname(__dirname)));
let isPortable = path.basename(extensionRoot).toLowerCase() == "data" || path.basename(extensionRoot).toLowerCase() == "code-portable-data";
if (!_user_dir) {
if (isPortable) {
_user_dir = path.join(extensionRoot, 'user-data', 'cs-script.user');
} else {
if (os.platform() == 'win32') { // win
_user_dir = path.join(process.env.APPDATA, 'Code', 'User', 'cs-script.user');
}
else if (os.platform() == 'darwin') { // mac
_user_dir = path.join(process.env.HOME, 'Library', 'Application Support', 'Code', 'User', 'cs-script.user');
}
else { // linux
_user_dir = path.join(process.env.HOME, '.config', 'Code', 'User', 'cs-script.user');
}
}
}
create_dir(_user_dir);
return _user_dir;
}
...
let cscs_exe: string = path.join(user_dir(), "cscs.exe");
let command = build_command(`"${cscs_exe}" "${file}"`);
let p = exec(command);
...
I just wanted to leave you this hint regarding including the version and other release info summary, check out how this extension is doing it. You might be able to do the same, I have no experience authoring extension so you are way ahead of me on this topic.
Last time I missed to notice the version in the sidebar because it was narrow or simply my brain/eyes did not expected it to be there.
Yes the badges is a good idea. They are simply taken form the GitHub page during the publishing. I have updated GitHub so the badges will be available in VSCode with very next release:
https://github.com/oleg-shilo/cs-script.vscode/blob/master/README.md
How to Run CSScript in VSCode
20200215Goals
Extensions Installed?
![image](https://user-images.githubusercontent.com/11699920/74601393-c9b76080-5052-11ea-88e8-279ca858d815.png) >
![image](https://user-images.githubusercontent.com/11699920/74601408-f1a6c400-5052-11ea-9cc1-e783eb525202.png)
![image](https://user-images.githubusercontent.com/11699920/74601415-1307b000-5053-11ea-8d92-8eabb4f45d5b.png)
![image](https://user-images.githubusercontent.com/11699920/74601623-01270c80-5055-11ea-937f-406b1301ea02.png)
but CS-Script has External? Dependencies...Requirements...
The latest Stable Mono release is: 5.12.0 Stable (5.12.0.226)
I am definitely behind...
The latest Stable Mono release is: 6.8.0 Stable (6.8.0.105)
![image](https://user-images.githubusercontent.com/11699920/74601465-96c19c80-5053-11ea-8906-5de7e74b6cb5.png)
ECHO %PATH% >> TMP.TXT
![image](https://user-images.githubusercontent.com/11699920/74601497-ebfdae00-5053-11ea-8a78-1fe33d324465.png)
My real problem is probably CSCS.EXE is NOT on the path
![image](https://user-images.githubusercontent.com/11699920/74601501-f750d980-5053-11ea-9328-1f3117ae0c7f.png)
Perhaps VSCode extension can't do that?
![image](https://user-images.githubusercontent.com/11699920/74601510-0f285d80-5054-11ea-8105-ceb0e82f502b.png)
User Variable
C:\PHP;C:\Ruby22-x64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Chocolatey\bin;C:\Users\AXM\AppData\Roaming\scriptcs;C:\Program Files\Microsoft VS Code\bin;C:\Users\AXM\AppData\Roaming\npm
System Variables
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Program Files\Java\jdk1.7.0_03\bin;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\QuickTime\QTSystem\;%JAVA_HOME%\bin;%ADT_HOME%\tools;%ADT_HOME%\platform-tools;%ANT_HOME%\bin;%GIT_HOME%\cmd;C:\Program Files\Microsoft\Web Platform Installer\;%systemroot%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Mono\bin;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd
Seems like the Path fixed something but not quite CS-Script is still crashing...
![image](https://user-images.githubusercontent.com/11699920/74601520-1cdde300-5054-11ea-9113-a6c0e34cdc9e.png)