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

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

问题描述

我最近开始使用适用于 Linux 的 Windows 子系统 (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.

这让我想到尝试使用 IDE 功能在 Visual Studio 中进行所有代码编辑,同时在 Linux 中进行实际构建.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:WindowsSystem32ash.exe build.sh" 并没有工作是因为:

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

'C:WindowsSystem32ash.exe' 未被识别为内部或外部命令,可运行的程序或批处理文件.

这对我来说很奇怪,因为我指定了完整路径,但它找不到 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%sysnativeash.exe

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

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

%windir%sysnativeash.exe -c "sh build.sh"

或许

%windir%sysnativeash.exe -c "./build.sh"

如果 DriveFS 权限允许执行.

if DriveFS permissions allow execution.

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

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天全站免登陆