I'm trying to enable custom build tasks to use bash to build DocBook-based documentation in Visual Studio 2017. I use built-in Windows Subsystem for Linux in Windows 10. I can launch cmd.exe and run dir
as in MS's examples. However, I need to run make ARGS
in bash and that's where I it fails with:
'"bash"' is not recognized as an internal or external command,
operable program or batch file.
I can run cmd.exe interactively and start bash without any problems. But it fails in Visual Studio. Does VS2017 use some special environment? How to make it run bash via those tasks? I guess that I am missing something very simple and trivial, but I don't understand where to look at.
Essentially, I want to run make all-html
command against the path with my DocBook sources.
Here is a minimal task example:
{
"version": "0.2.1",
"tasks": [
{
"taskName": "Build all-html",
"appliesTo": "*",
"type": "command",
"command": "bash"
}
]
}
The reason the command doesn't naturally find bash
like you would expect is because Visual Studio is a 32-bit program. This means that it won't use the 64-bit cmd.exe when you specify commands.
You can reproduce what Visual Studio is doing by opening a 32-bit command window C:\Windows\SysWOW64\cmd.exe
and trying the bash
command from there.
The solution is to invoke bash.exe
directly via the C:\Windows\Sysnative
virtual folder.
You can find a discussion/explanation of the Sysnative folder and why it is necessary here in the official Bash on Windows GitHub.
Here is an example command that should work for you:
{
"taskName": "print-pwd",
"appliesTo": "*",
"type": "command",
"command": "%WINDIR%\\Sysnative\\bash.exe",
"args": [
"-c",
"pwd"
]
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments