参考文档
官方文档:
https://blogs.msdn.microsoft.com/vcblog/2017/09/14/cmake-support-in-visual-studio-cmake-3-9-linux-targeting-feedback/
https://blogs.msdn.microsoft.com/vcblog/2016/10/05/cmake-support-in-visual-studio/
光看这篇官方文档是不够的。
有1个坑需要填下。
深坑
github 上也有网友遇到的坑:
Input string was not in a correct format.
显示这个错误的总共有4个单子。症状都不一样。也就是该行错误没有报告真正的原因。让人摸不到头脑。
仔细看了下这些单子,发现我遇到的同下面这位,issues 为:
https://github.com/Microsoft/VSLinux/issues/192
意思是说,CMake中有多个project会出现上述错误,然后试着试着发现只有一个project也会出现上述错误。
官方的给的解决方案是 : 你升级到 preview 试试 …
然后这个小伙子用 Version 15.5.0 Preview 2.0 成功了 …
安装 VS2017 专业版 的 Preview 版本
装好后,有个小坑:
默认使用 rsync 同步文件到 Linux 机。
如 阿里云,默认开着的是 sftp 且只开发 22 端口。 因此看情况可以修改 CMakeSetting.json 中的 remoteCopySourcesMethod 字段:
{
"configurations": [
{
"name": "Linux-Debug",
"generator": "Unix Makefiles",
"remoteMachineName": "${defaultRemoteMachineName}",
"configurationType": "Debug",
"remoteCMakeListsRoot": "/var/tmp/src/${workspaceHash}/${name}",
"cmakeExecutable": "/usr/local/bin/cmake",
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"remoteBuildRoot": "/root/projects/CMkaeProject1/${name}",
"remoteInstallRoot": "/root/projects/CMkaeProject1/${name}",
"remoteCopySources": true,
"remoteCopySourcesOutputVerbosity": "Normal",
"remoteCopySourcesConcurrentCopies": "10",
"remoteCopySourcesMethod": "sftp",
"remoteCopySourcesExclusionList": [
".vs",
".git"
],
"rsyncCommandArgs": "-t --delete --delete-excluded",
"remoteCopyBuildOutput": false,
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [
"linux_x64"
]
}
]
}
最后给张图吧: