从Visual Studio 2015开始基于WSL bash的构建 [英] Kicking off a WSL bash-based build from Visual Studio 2015

查看:83
本文介绍了从Visual Studio 2015开始基于WSL bash的构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用Windows Linux子系统(WSL)来查看我的Linux Makefile&基于arm-none-eabi-gcc的微控制器项目将在Windows中本地"构建.令我惊讶的是,该工具链和基于Linux的开发工具首次安装并运行完美,而无需对Makefile进行任何修改.

I recently started using the Windows Subsystem for Linux (WSL) to see if my Linux Makefile & arm-none-eabi-gcc based microcontroller project would build "natively" in Windows. To my surprise, the tool chain and Linux based development tools installed and worked perfectly on first go, without any modifications to the Makefile.

因此,我想到了尝试在Linux中使用IDE功能在Visual Studio中使用IDE功能进行所有代码编辑的过程. WSL中提供的bash环境.

So that got me thinking to try doing all my code editing in Visual Studio using the IDE features while doing the actual build in the Linux & bash environment provided in WSL.

不幸的是,在我的Visual Studio项目的NMake选项中指定构建命令行"时,放入"C:\Windows\System32\bash.exe build.sh"无效,因为:

Unfortunately, when specifying a "Build Command Line" in the NMake options for my Visual Studio project, putting in "C:\Windows\System32\bash.exe build.sh" doesn't work because:

'C:\Windows\System32\bash.exe' is not recognized as an internal or external command, operable program or batch file.

'C:\Windows\System32\bash.exe' is not recognized as an internal or external command, operable program or batch file.

这对我来说很奇怪,因为我指定了完整路径并且找不到WSL bash可执行文件,并且尝试将其添加为外部工具"似乎也不起作用,因为可执行文件未显示尽管能够看到同一目录中的其他可执行文件,但仍在选择窗口中显示.

This is strange to me because I specified the full path and it couldn't find the WSL bash executable, and also attempting to add it as an "External Tool" doesn't seem to work because the executable doesn't show up in the selection window despite being able to see other executables in the same directory.

一些与主题无关的意见:如果Microsoft可以使Visual Studio和WSL无缝地协同工作,那么我很可能会从基于Ubuntu的虚拟机安装程序切换到基于WSL的开发环境.

Some off topic opinion: If Microsoft can make Visual Studio and WSL work together seamlessly then I would likely switch from my Ubuntu virtual machine setup for a WSL based development environment.

推荐答案

您必须执行以下操作:

Nmake不是64位应用程序,因此当它尝试使用Windows实用程序和system32时,WoW64会诱使它在其他位置查看.

Nmake is not a 64-bit application, so when it tries to use Windows utilities and system32, WoW64 tricks it into looking in a different location.

从32位应用程序启动它的方式是:

The way you have to launch it from a 32-bit application is:

%windir%\sysnative\bash.exe

但是,您的命令也格式错误.您将需要这样做:

However, your command is also malformed. You will need to do it like this:

%windir%\sysnative\bash.exe -c "sh build.sh"

或者也许

%windir%\sysnative\bash.exe -c "./build.sh"

如果DriveFS权限允许执行.

if DriveFS permissions allow execution.

否则它将尝试在您的Linux用户的$ PATH中作为命令执行build.sh.

otherwise it will attempt to execute build.sh as a command in your linux user's $PATH.

来源: https://github.com/Microsoft/BashOnWindows/issues/870

这篇关于从Visual Studio 2015开始基于WSL bash的构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆