The application to execute does not exist
I really do love dotnet-script and its almost perfect integration with Visual Studio Code. But as it is a .Net Core global tool, and VSCode uses file-based task specifications which know nothing of this, things can sometimes break.
I’ve create a simple script for giving me a nice text to share whenever I post a new post to this site. Sure, this can be further automated, but you’ve got to start someplace.
For development I use two different Macs, an iMac at home and a MacBook Pro during my commute. I started coding this on my iMac, but on my ride to work I got this error while trying to debug from VSCode on my MacBook Pro:
The application to execute does not exist: '/Users/sankra/.dotnet/tools/.store/dotnet-script/0.25.0/dotnet-script/0.25.0/tools/netcoreapp2.1/any/dotnet-script.dll'
The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
The program '[41202] dotnet' has exited with code 129 (0x81).
The script ran fine from the shell using dotnet script main.csx
. So what is the cause of this error?
The solution
To enable debugging in VSCode, dotnet-script uses a launch.json
which can look like this:
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Script Debug",
"type": "coreclr",
"request": "launch",
"program": "dotnet",
"args": [
"exec",
"/Users/sankra/.dotnet/tools/.store/dotnet-script/0.25.0/dotnet-script/0.25.0/tools/netcoreapp2.1/any/dotnet-script.dll",
"${file}",
"--",
"../sankra.github.io/"
],
"cwd": "${workspaceRoot}",
"stopAtEntry": true
}
]
}
The path to dotnet-script.dll
looked fine, but it did not exist on disk. Listing the installed dotnet global tools, showed the following:
That explained it, dotnet-script was on an older version on this machine. The solution was to update dotnet-script with:
dotnet tool update dotnet-script -g
Some more smarts on VSCode’s side would’ve been nice, but at least I now know what to do if I encounter this particular error in the future.