Problem - 'dispatch' is not recognized as an internal or external command - c#

When I tried to create dispatch-Model for my bot., I am getting following error - 'dispatch' is not recognized as an internal or external command, operable program or batch file.Before using dispatch command, I installed botdispatch using npm install -g botdispatch. But still I am getting this error.

Can you check your NPM folder to see if there is anything with dispatch there? Assuming you're on Windows, this is typically in AppData\Roaming\npm.
PowerShell:
dir $home\AppData\Roaming\npm
CMD:
dir %homepath%\AppData\Roaming\npm.
If dispatch (dispatch.cmd) is there, then it might be a pathing issue. Check your path variables to make sure that that path is there:
CMD:
echo %path%
PowerShell:
($env:path).Split(';')

So I was having this same issue, it turns out I needed to add the path of the NPM folder C:\Users\xxxxxx\AppData\Roaming\npm to my path for Powershell7.
$env:Path += ";C:\Users\xxxxxx\AppData\Roaming\npm"
Where xxxxxx is your userid. After adding this command to Powershell the npm modules began to work.
If you do not see this path by running this command below, then you need to add it with the one above.
($env:path).Split(';')
All of these should be ran inside of a PS7 window, I ran them with Administrator rights when I launched the Powershell 7 window.

Related

Visual Studio 2019 C# Docker debugging process attach error

I'm trying to debug a Linux container that runs a C#/.NET 6.0 console application from Visual Studio 2019 (version 16.11.10).
When I use Debug / Attach to Process... to connect to my running container and attach to my process, I get the error:
Failed to launch debug adapter. Additional information may be available in the output window.
Unable to find debugger script at '/home/dockeruser/.vs-debugger'
For company security purposes, I'm running my container workloads as user dockeruser, but I can reproduce this when I adjust my Dockerfile to run as user root. The error message changes into
Unable to find debugger script at '/root/.vs-debugger'
Output shows
Unable to find debugger script at '/home/dockeruser/.vs-debugger'.
Initialization log:
Determining user folder on remote system...
Checking for existing installation of debugging tools...
Downloading debugger launcher...
Creating debugger installation folder: /home/dockeruser/.vs-debugger
Copying debugger launcher to /home/dockeruser/.vs-debugger/GetVsDbg.sh
Failed: Failed to copy files.
Unable to find debugger script at '/home/dockeruser/.vs-debugger'.
Failed: Unable to find debugger script at '/home/dockeruser/.vs-debugger'.
The program '[1] dotnet' has exited with code -1 (0xffffffff).
I can work around this by docker exec'ing a bash session on my container and running GetDbgVs.sh as detailed in https://stackoverflow.com/a/68950674/17273131, but its a pain to do - it feels like something is misconfigured.
I've already verified that my windows identity is a member of the windows docker-users group.
While not the answer I wanted, I've got a 1-liner shell workaround that I execute on my container when I want to debug attach with VS2019, once I know my <CONTAINER_NAME>. This may be useful to others with this problem.
docker exec -u root <CONTAINER_NAME> sh -c "apt-get update && apt-get install wget -y"; docker exec <CONTAINER_NAME> sh -c "mkdir -p ~/.vs-debugger; wget https://aka.ms/getvsdbgsh -O ~/.vs-debugger/GetVsDbg.sh; chmod a+x ~/.vs-debugger/GetVsDbg.sh"
The first command installs wget as root
The second command downloads GetVsDbg.sh to ~/.vs-debugger

Windows service not getting uninstalled

I want to uninstall Windows Service from command prompt but that is not working getting below error
'installutil' is not recognized as an internal or external command,
operable program or batch file.
This way I have tried command
D:\backup\WindowsService\WindowsService1\WindowsService1\obj\Debug>installutil -u TestService.exe
D:\backup\WindowsService\WindowsService1\WindowsService1\obj\Debug>installutil -u "TestService.exe"
How can I uninstall service?
After your comment, your issue seems related to %PATH%.
There is no such thing as "installutil" on your Windows. I believe "installutil" has created by you right?
Let's assume that binary resides at C:\Myproject\installutil.exe
There are two ways to execute it.
First:
C:\users\username> cd C:\Myproject
C:\Myproject> .\installutil.exe -u "bla bla bla bla".
Second:
Go to your start menu and search for "environment". Open "Edit the system variables" under "System properties". At the "Advanced" tab, you'll see "Environment Variables". You'll see a variable named "Path". Edit it's value and add your own .exe path at the end.
When you execute "echo %PATH" at command prompt, you should see your binary's folder. Otherwise, command prompt will not be able to find it.
EDIT:
So yeah, there is one such thing called installutil.exe and it can be used by the Developer Command Prompt for Visual Studio.
Command to uninstall service: installutil -u "AirwatchService.exe"
Are you sure you're using the right command prompt? Do you have the absolute path of this binary?
Please check this: https://learn.microsoft.com/en-us/dotnet/framework/tools/installutil-exe-installer-tool

Cannot start Appium server programmatically

I'd like to run an Appium server with default settings from C# like that:
AppiumLocalService appiumLocalService = AppiumLocalService.BuildDefaultService();
appiumLocalService.Start();
I also set the environment variables right before that:
Environment.SetEnvironmentVariable(AppiumServiceConstants.NodeBinaryPath, #"C:\Program Files\nodejs\node.exe");
Environment.SetEnvironmentVariable(AppiumServiceConstants.AppiumBinaryPath,#"C:\Program Files (x86)\Appium\resources\app\node_modules\appium\lib\main.js"
When I am trying to run the code is stopping for 2 minutes, and I get the following exception:
Message: OpenQA.Selenium.Appium.Service.Exceptions.AppiumServerHasNotBeenStartedLocallyException : The local appium server has not been started. The given Node.js executable: C:\Program Files\nodejs\node.exe Arguments: "C:\Program Files (x86)\Appium\resources\app\node_modules\appium\lib\main.js" --port 4723 --address 127.0.0.1.
Time 120000 ms for the service starting has been expired!
I Googled a lot, but I couldn't find the answer for that. I can start Appium manually from console or from Desktop Application without any problem.
Appium Dotnet version: 3.0.0.2
Appium version: 1.11.1
Node.js version: v10.15.1
I appreciate any suggestion/help.
SOLVED:
wrong:
Environment.SetEnvironmentVariable(AppiumServiceConstants.AppiumBinaryPath,#"C:\Program Files (x86)\Appium\resources\app\node_modules\appium\lib\main.js"
Right:
Environment.SetEnvironmentVariable(AppiumServiceConstants.AppiumBinaryPath,#"C:\Program Files (x86)\Appium\resources\app\node_modules\appium\***build***\lib\main.js"
So basicly the last directory is wrong in the path.
I solved my problem as well adding the right path to the PATH variable.
C:\>npm config get prefix
add the prefix to system environment path
Restart
reinstall node.js to the latest version (typical installer)
reinstall appium (by npm install -g appium)
verify appium is able to run with the command: appium

Absolute path in dotnet watch run command doesn't work

To run dotnet core application with specified absolute path we need to run following command:
dotnet run -p C:\foo\bar\Project\Project.csproj
But it seems it doesn't work the same with dotnet watch run:
watch : Could not find a MSBuild project file in 'C:\directory\where\we\execute\command'. Specify which project to use with the --project option.
Running the same command with -project instead of -p doesn't help however...
Dotnet watch help specifies -p or -project parameter anyway:
Microsoft DotNet File Watcher 2.1.1-rtm-30846
Usage: dotnet watch [options] [[--] ...]
Options: -?|-h|--help Show help information
-p|--project The project to watch -q|--quiet Suppresses all output except warnings and errors -v|--verbose
Show verbose output --list Lists all discovered
files without starting the watcher --version Show
version information
Environment variables:
DOTNET_USE_POLLING_FILE_WATCHER When set to '1' or 'true',
dotnet-watch will poll the file system for changes. This is required
for some file systems, such as network shares, Docker mounted
volumes, and other virtual file systems.
DOTNET_WATCH dotnet-watch sets this variable to '1' on all child
processes launched.
Remarks: The special option '--' is used to delimit the end of the
options and the beginning of arguments that will be passed to the
child dotnet process. Its use is optional. When the special option
'--' is not used, dotnet-watch will use the first unrecognized
argument as the beginning of all arguments passed into the child
dotnet process.
For example: dotnet watch -- --verbose run
Even though '--verbose' is an option dotnet-watch supports, the use
of '--' indicates that '--verbose' should be treated instead as an
argument for dotnet-run.
Examples: dotnet watch run dotnet watch test
What's wrong then? Why absolute path to project doesn't work with dotnet watch run while works with dotnet run?
You can resolve this by specifying the -p (or the longer --project) option on the watch command rather than on the run command. In your case, that would be:
dotnet watch -p C:\foo\bar\Project\Project.csproj run
There's a note in the docs that covers this:
You can use dotnet watch --project <PROJECT> to specify a project to watch. For example, running dotnet watch --project WebApp run from the root of the sample app will also run and watch the WebApp project.
I'm not 100% sure, but dotnet watch is looking for file changes in the current directory. So if you use absolute path it must know where should it looks for changes. Of course, such implementation is possible but I just think that nobody thinked about it when implementing watch command
In my case, its just a minor error, you have to enter in the project directory before executing dotnet command, like:
cd yourAppName
dotnet watch run
It'll run

MSBuild exited with code 1 error

I am getting following error when trying to build the solution.
Error The command "
copy "D:\Code\..\libs\xyz_ext.x64.dll" "D:\Code\bin\"
copy "D:\Code\..\libs\xyz.x86.dll" "D:\Code\bin\"
" exited with code 1. C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets 4714
MSBuild exited with code 1 error
First, just as nozzleman comment "is this the real command (including ..) from the post build event" If yes, this is the reason why you got this error. That because build events follow the same syntax as DOS commands, and DOS never supported wildcard * expansion and \..\ in the path by the shell. So you should specify the full path in the command line.
Besides, if you want to copy the file in all the subfolders of Code, you need some way using existing windows tools (cmd.exe), or powershell with wildcard *, for example, powershell:
This is code in the .ps1 file:
Get-ChildItem "D:\Code\*\libs" -Recurse -Include xyz_ext.x64.dll | Copy-Item -Destination D:\Code\bin
Then execute this PS script by post build event:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file D:\Code\Test.ps1
If \..\ is nor the real command from the post build event, just a shorthand expression. You should check the path of this command. According to the error log "code 1 error", it specify that this command is incorrect. And I have checked this command, the syntax of copy is correct, so the problem is the path is not incorrect, you should double check it.

Categories

Resources