码迷,mamicode.com
首页 > 其他好文 > 详细

使用Visual C ++和Open Folder自定义环境

时间:2018-08-14 15:44:46      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:syn   二进制   msbuild   sub   names   end   嵌入   std   运行   

使用Visual C ++和Open Folder自定义环境

来源 https://blogs.msdn.microsoft.com/vcblog/2016/10/05/bring-your-c-codebase-to-visual-studio-with-open-folder/

 

Visual Studio 2017中称为“ 打开文件夹 ” 的新功能完全支持C ++。 如果你有一个基于CMake的项目,请看一下这篇文章,描述我们的Visual Studio为CMake简化的“开放文件夹”体验如果您的项目正在使用其他构建系统,请继续阅读。

安装产品时,请确保安装其中一个C ++工作负载,例如“使用C ++进行桌面开发”或“使用C ++进行游戏开发”。

之后,您只需运行“打开文件夹”命令并选择要浏览的文件夹(从文件 > 打开 > 文件夹快速启动)或从命令提示符直接启动devenv.exe <foldername>

技术分享图片

阅读C ++代码

打开文件夹后,解决方案资源管理器将立即显示该文件夹中的文件,您可以在编辑器中打开任何文件。在后台,Visual Studio将开始索引文件夹中的C ++源代码。

您现在可以访问阅读和浏览C ++代码的所有Visual Studio功能(例如,查找所有引用,转到符号,Peek定义,语义着色和突出显示,类视图,调用层次结构等等)。

技术分享图片

编辑C ++代码

所有这些C ++浏览和导航服务都可以工作,而无需像以前的Visual Studio版本那样创建任何Visual C ++项目(通过“ 从现有代码创建项目”向导)。

当您从项目中创建,重命名或删除源文件时,您不必再担心更新Visual C ++项目 - Visual Studio将依赖于文件夹结构并根据需要监视磁盘上的更改。此外,当您编辑代码时,Visual Studio的IntelliSense将继续更新并帮助您获取源中的最新信息。

技术分享图片

在编辑代码时,您还可以使用Visual Studio支持C ++的所有重构功能,例如重命名符号,提取功能,移动定义位置,更改签名,转换为原始字符串文字等。

技术分享图片

自定义C ++配置设置

默认情况下,VS将为IntelliSense和浏览提供两种C ++配置:Debug和Release。这些配置与VS 2015中引入单文件智能感知功能提供的配置一致

根据项目的不同,您可能需要使用有关源代码的更多信息来自定义这些配置,例如其他包含路径,其他定义或编译器开关。为此,在根文件夹中创建一个名为CppProperties.json的文件 - 该文件将有助于配置C ++ IntelliSense和浏览。

CppProperties.json:

1
2
3
4
6
7
8
9
10
11
12
13
{
  "configurations": [
    {
      "name": "Windows x64",
      "includePath": [ "include" ],
      "defines": [ "_DEBUG" ],
      "compilerSwitches": "/std:c++14",
      "intelliSenseMode": "msvc-x64",
      "forcedInclude": [ "pch.h" ],
      "undefines": []
    }
  ]
}

以下属性可用于给定配置:

  • name:是将在C ++配置下拉列表中显示的配置名称
  • includePath:应在include路径中指定的文件夹列表(映射到/ I表示大多数编译器)
  • 定义:应定义的宏列表(映射到大多数编译器的/ D)
  • compilerSwitches:指定一个或多个可影响IntelliSense行为的附加开关
  • forcedInclude:指定要自动包含在每个编译单元中的标头(映射到MSVC的/ FI或clang的-include)
  • undefines:要定义的宏列表(映射到/ U表示MSVC)
  • intelliSenseMode:指定要使用的IntelliSense引擎。您可以为MSVC或Clang指定体系结构特定的变体:
    • msvc-x86(默认值)
    • MSVC-64
    • msvc -arm
    • 窗户 - 铛 - 86
    • 窗户 - 铛 - 64
    • Windows的铛臂

此文件支持包含路径和其他属性值的环境变量扩展语法为$ {env.FOODIR}以扩展环境变量%FOODIR%。

您还可以访问此文件中的内置宏:

  • $ {workspaceRoot} - 提供工作空间文件夹的完整路径
  • $ {projectRoot} - 放置CppProperties.json的文件夹的完整路径
  • $ {vsInstallDir} - 安装VS 2017运行实例的文件夹的完整路径

例如,如果您的项目有一个包含文件夹,并且还包含Windows.h和Windows SDK中的朋友(这很常见),您可能希望使用以下内容更新配置文件:

CppProperties.json

1
2
3
4
6
7
8
9
10
11
12
13
14
15
16
17
{
  "configurations": [
    {
      "name": "Windows",
      "includePath": [
        // local include folder
        "${workspaceRoot}\\include",
        // Windows SDK and CRT headers
        "${env.WindowsSdkDir}include\\${env.WindowsSDKVersion}\\ucrt",
        "${env.NETFXSDKDir}\\include\\um",
        "${env.WindowsSdkDir}include\\${env.WindowsSDKVersion}\\um",
        "${env.WindowsSdkDir}include\\${env.WindowsSDKVersion}\\shared",
        "${env.VCToolsInstallDir}include"
      ]
    }
  ]
}

注意:%WindowsSdkDir%和%VCToolsInstallDir%未设置为全局环境变量,因此请确保从定义这些变量的“VS 2017开发人员命令提示符”启动devenv.exe。

技术分享图片

提示:通常,错误列表窗口是查看由于缺少包含而导致的任何IntelliSense错误的良好起点 - 将其内容过滤为“仅限IntelliSense”,错误代码为E1696:

技术分享图片

您可以在CppProperties.json文件中创建任意数量的配置,并可以从标准工具栏中的C ++配置下拉列表轻松切换它们

CppProperties.json

1
2
3
4
6
7
8
9
10
11
12
{
  "configurations": [
    {
      "name": "Windows",
      ...
    },
    {
      "name": "with EXTERNAL_CODECS",
      ...
    }
  ]
}

技术分享图片

构建C ++项目

通过直接在IDE中将它们作为任务运行,您可以在当前工作空间中的文件上自动构建脚本或任何其他外部操作。您可以通过右键单击文件或文件夹来配置新任务,然后选择“ 自定义任务设置 ”。

技术分享图片

这将在工作区中隐藏的.vs文件夹下创建一个新文件tasks.vs.json,以及一个可以自定义的新任务。

技术分享图片

默认情况下,可以从解决方案资源管理器中的文件的上下文菜单执行任务。对于每个任务,您将在上下文菜单的底部找到一个新条目。

Tasks.vs.json

1
2
3
4
6
7
8
9
10
11
12
{
  "version": "0.2.1",
  "tasks": [
    {
      "taskName": "Echo filename",
      "appliesTo": "makefile",
      "type": "command",
      "command": "${env.COMSPEC}",
      "args": ["echo ${file}"]
    }
  ]
}

技术分享图片

就像CppProperties.json一样,在tasks.vs.json中,您可以使用语法$ {env.VARIABLE}来使用环境变量。

此外,您可以在任务属性中使用内置宏:

  • $ {workspaceRoot} - 提供工作空间文件夹的完整路径(例如“C:\ sources \ hello”)
  • $ {file} - 提供选择运行此任务的文件或文件夹的完整路径(例如“C:\ sources \ hello \ src \ hello.cpp”)
  • $ {relativeFile} - 提供文件或文件夹的相对路径(例如“src \ hello.cpp”)
  • $ {fileBasename} - 提供没有路径或扩展名的文件名(例如“hello”)
  • $ {fileDirname} - 提供文件的完整路径,不包括文件名(例如“C:\ sources \ hello \ src”)
  • $ {fileExtname} - 提供所选文件的扩展名(例如“.cpp”)

您还可以自己指定可在任务属性中使用的其他用户宏,例如下面示例中的$ {outDir}:

Tasks.vs.json

1
2
3
4
6
7
8
9
10
11
12
13
14
15
{
  "version": "0.2.1",
  "outDir": "${workspaceRoot}\\bin",
  "tasks": [
    {
      "taskName": "List outputs",
      "appliesTo": "*",
      "type": "command",
      "command": "${env.COMSPEC}",
      "args": [
        "dir ${outDir}"
      ]
    }
  ]
}

通过将给定任务的“contextType”指定为“ build ”,“ clean ”或“ rebuild ”,您可以连接可以从上下文菜单调用的Build,Clean和Rebuild的VS内置命令。

Tasks.vs.json

1
2
3
4
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
  "version": "0.2.1",
  "tasks": [
    {
      "taskName": "makefile-build",
      "appliesTo": "makefile",
      "type": "command",
      "contextType": "build",
      "command": "nmake"
    },
    {
      "taskName": "makefile-clean",
      "appliesTo": "makefile",
      "type": "command",
      "contextType": "clean",
      "command": "nmake",
      "args": ["clean"]
    }
  ]
}

技术分享图片

您可以通过在“applyTo”字段中指定其名称来为任何文件或文件夹创建任务。但是要创建更多通用任务,您可以使用文件掩码。例如:

  • “applyTo”:“*” - 任务可用于工作区中的所有文件和文件夹
  • “applyTo”:“* /” - 任务可用于工作区中的所有文件夹
  • “applyTo”:“*。cpp” - 任务可用于工作空间中扩展名为.cpp的所有文件
  • “applyTo”:“/ *。cpp” - 任务可用于工作空间根目录中扩展名为.cpp的所有文件
  • “applyTo”:“src / * /” - 任务可用于“src”文件夹的所有子文件夹
  • “applyTo”:“makefile” - 任务可用于工作空间中的所有makefile文件
  • “applyTo”:“/ makefile” - 任务仅在工作空间根目录中的makefile上可用

调试C ++二进制文件

要在Visual Studio中开始调试,您需要在解决方案资源管理器中导航到可执行文件。然后右键单击,选择“ Debug ” - 这将立即启动此可执行文件的调试会话。

或者,您可以在任务定义中指定输出二进制文件(通过“输出”)。一旦你这样做,如果你选择源文件作为启动项(右键单击,“ 设置为启动项”)或只需右键单击源文件并选择“ 调试 ” ,这个二进制文件将在调试器下自动启动

Tasks.vs.json

1
2
3
4
6
7
8
9
10
11
12
13
{
  "version": "0.2.1",
  "tasks": [
    {
      "taskName": "makefile-build",
      "appliesTo": "makefile",
      "type": "command",
      "contextType": "build",
      "command": "nmake",
      "output": "${workspaceRoot}\\bin\\hellomake.exe"
    }
  ]
}

技术分享图片

如果要自定义程序的参数,请选择“ 调试和启动设置 ”。这将创建一个新的launch.vs.json文件,其中包含有关所选程序的信息。

技术分享图片

要指定其他参数,只需将它们添加到“args”JSON数组中,如下例所示

launch.vs.json:

1
2
3
4
6
7
8
9
10
11
12
{
  "version": "0.2.1",
  "defaults": {},
  "configurations": [
    {
      "type": "default",
      "project": "CPP\\7zip\\Bundles\\Alone\\O\\7za.exe",
      "name": "7za.exe list content of helloworld.zip",
      "args": [ "l", "d:\\sources\\helloworld.zip" ]
    }
  ]
}

技术分享图片

保存此文件后,“调试目标”下拉列表中的新条目将可用,您可以选择它以启动调试器。通过编辑launch.vs.json文件,您可以为任意数量的可执行文件创建任意数量的调试配置。如果现在按F5,调试器将启动并命中您可能已设置的任何断点。现在可以使用所有熟悉的调试器窗口和功能。

技术分享图片

下一步是什么

立即下载Visual Studio 2017并尝试“打开文件夹” - 不再需要创建VS项目和解决方案文件以在VS中提高工作效率。

我们正在继续努力使这种体验变得更好。在即将发布的版本中,您将看到我们增强了C ++浏览和导航的工作方式,并支持更多的调试器类型,最终与我们基于MSBuild的项目功能达到平等。您的反馈对于告知我们的后续步骤非常重要,所以请不要犹豫,分享。我们在听!

 

使用Visual C ++和Open Folder自定义环境

来源 https://blogs.msdn.microsoft.com/vcblog/2017/11/02/customizing-your-environment-with-visual-c-and-open-folder/

自从我们发布了打开C ++代码文件夹的支持以来,社区一直在要求对其构建和编辑环境进行更多控制。为此,我们在最新版本的Visual Studio 2017中添加了使用CppProperties.json自定义环境的新方法

这个新的自定义表面使您可以使用更多种类的工具,编写更简洁的CppProperties文件,并具有类似于MSBuild的强大的每配置自定义。下面的主题扩展了原始C ++ Open Folder帖子中描述的几个概念如果您不熟悉编辑CppProperties.json,Launch.vs.json和Tasks.vs.json,则可能需要先阅读该帖子。

这篇文章是我们之前关于为CMake项目定制环境的帖子的配套文件,所以如果您已经阅读过,那么您可能会发现其中一些内容将是相似的,因为我们努力保持体验的一致性。关于如何使用特定于配置的变量,最重要的区别在于“Launch.vs.json和Tasks.vs.json怎么样”。

CppProperties.json中的新功能

这种新灵活性的核心在于项目的CppProperties.json文件,它来自两个新概念:

  1. 能够使用“inheritEnvironments”属性全局或按配置继承一组默认环境变量。
  2. 通过定义“环境”块,可以全局或按配置定义自定义环境变量及其值。

将这些新概念与使用“$ {env.VAR}”语法在CppProperties.json,launch.vs.json和tasks.vs.json中使用环境变量的现有功能相结合,为创建丰富的开发环境提供了强大的机制。

让我们从一个快速示例开始,说明如何使用此功能:

1
2
3
4
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
三十
31
32
33
34
35
36
37
38
{
  // The "environments" property is an array of key value pairs of the form
  // { "EnvVar1": "Value1", "EnvVar2": "Value2" }
  "environments": [
    {
      "INCLUDE": "${workspaceRoot}\\src\\includes"
    }
  ],
 
  "configurations": [
    {
      "inheritEnvironments": [
        // Inherit the MSVC 32-bit environment and toolchain.
        "msvc_x86"
      ],
      "name": "x86",
      "includePath": [
        // Use the include path defined above.
        "${env.INCLUDE}"
      ],
      "defines": [ "WIN32", "_DEBUG", "UNICODE", "_UNICODE" ],
      "intelliSenseMode": "msvc-x86"
    },
    {
      "inheritEnvironments": [
        // Inherit the MSVC 64-bit environment and toolchain.
        "msvc_x64"
      ],
      "name": "x64",
      "includePath": [
        // Use the include path defined above.
        "${env.INCLUDE}"
      ],
      "defines": [ "WIN32", "_DEBUG", "UNICODE", "_UNICODE" ],
      "intelliSenseMode": "msvc-x64"
    }
  ]
}

为了解压缩这个,这个例子定义了使用Microsoft的Visual C ++工具链构建的两个配置。x86的第一个构建(因为它继承了“msvc_x86”环境),而另一个构建了x64。它还定义了两个配置使用的环境变量“INCLUDE”(第6行)。

请记住,可以为所有配置,每个配置或两者全局定义“环境”(第4行)和“inheritEnvironments”(第12行和第25行)属性。在上面的示例中,“INCLUDE”变量将是全局变量,“inheritEnvironment”属性将仅适用于每个单独的配置。

今天有以下环境:

  • 使用MSVC(msvc_x86)定位x86 Windows
  • 使用MSVC(msvc_x64)定位x64 Windows
  • 使用64位MSVC(msvc_x64_x86)定位x86 Windows
  • 使用64位MSVC(msvc_x64_x64)定位x64 Windows

此外,如果安装Linux Workload,则可以使用以下环境远程定位 Linux和WSL:

  • 远程目标x86 Linux(linux_x86)
  • 远程定位x64 Linux(linux_x64)
  • 远程目标ARM Linux(linux_arm)

特定于配置的环境变量最后被评估,因此它们会覆盖全局变量。以下示例说明了注释中的覆盖行为:

1
2
3
4
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
三十
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{
  // The "environments" property is an array of key value pairs of the form
  // { "EnvVar1": "Value1", "EnvVar2": "Value2" }
  "environments": [
    {
      "INCLUDE": "${workspaceRoot}\\src\\includes"
    }
  ],
 
  "configurations": [
    {
      "inheritEnvironments": [
        // Inherit the MSVC 32-bit environment and toolchain.
        "msvc_x86"
      ],
      "name": "x86",
      "includePath": [
        // Use the include path defined above.
        "${env.INCLUDE}"
      ],
      "defines": [ "WIN32", "_DEBUG", "UNICODE", "_UNICODE" ],
      "intelliSenseMode": "msvc-x86"
    },
    {
      // The "environments" property is an array of key value pairs of the form
      // { "EnvVar1": "Value1", "EnvVar2": "Value2" }
      "environments": [
        {
          // Append 64-bit specific include path to env.INCLUDE.
          "INCLUDE": "${env.INCLUDE};${workspaceRoot}\\src\\includes64"
        }
      ],
 
      "inheritEnvironments": [
        // Inherit the MSVC 64-bit environment and toolchain.
        "msvc_x64"
      ],
      "name": "x64",
      "includePath": [
        // Use the include path defined above.
        "${env.INCLUDE}"
      ],
      "defines": [ "WIN32", "_DEBUG", "UNICODE", "_UNICODE" ],
      "intelliSenseMode": "msvc-x64"
    }
  ]
}

如果需要为构建环境声明大量变量,然后对每个配置仅对它们进行少量修改,则此覆盖行为可能会大大压缩项目的CppProperties.json文件。

那么Launch.vs.json和Tasks.vs.json呢

如果您想知道是否可以在CppProperties.json文件之外使用这些变量,答案是肯定的!您在CppProperties.json中声明的所有环境变量也可以在launch.vs.jsontasks.vs.json中使用。只需将相同的“$ {env.VarName}”语法嵌入到任务或启动配置中的任何属性值中。宏语法将扩展为其实际值,如第16行所示。

1
2
3
4
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
  "version": "0.2.1",
  "tasks": [
    {
      "taskName": "build-helloworld",
      "appliesTo": "*.cpp",
      "contextType": "build",
      "type": "launch",
      "command": "${env.comspec}",
      "workingDirectory": "${workspaceRoot}",
      // Use environment from selected configuration, you can omit this
      // to only use globally defined variables instead.
      "inheritEnvironments": [ "${cpp.activeConfiguration}" ],
      "output": "${workspaceRoot}\\bin\\helloworld.exe",
      "args": [
        "build.bat ${env.BUILD_ARGS}"
      ]
    }
  ]
}

如果环境变量的值是特定于配置的,那么当您在任务或启动配置中包含此任务时,将使用当您尝试运行任务或调试程序时当前所选配置的值:

1
"inheritEnvironments":  [ "${cpp.activeConfiguration}" ]

如果不包括此项,则只有全局定义的变量可用。

您声明的环境变量也将由任务启动的进程继承。另一方面,正在调试的程序不会自动继承构建环境。下面的示例显示了如何将环境变量显式传递给已启动的进程。

1
2
3
4
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
  "version": "0.2.1",
  "defaults": {},
  "configurations": [
    {
      "type": "native",
      "name": "helloworld.exe",
      // Use environment from selected configuration, you can omit this
      // to only use globally defined variables instead.
      "inheritEnvironments":  [ "${cpp.activeConfiguration}" ],
      "project": "bin\\helloworld.exe",
      "args": [
        // Use arguments defined in CppProperties.json.
        "${env.PROG_ARGS}"
      ] ,
      "env": "var1=${env.var1}\u0000var2=hardcodedvalue"
    }
  ]
}

您可以在第14行看到可以引用CppProperties.json文件中定义的变量。第17行的“\ u0000”是用于分隔变量的空字符。

高级功能

那些有敏锐眼光的人可能已经注意到“environment”和“inheritEnvironments”是CppProperties.json语法中的数组。可以从多个环境声明和继承。对于典型的构建方案,您不太可能希望从多个环境继承,但在某些情况下您可能希望声明多个环境块。这个的主要用例是声明一些可以在任何CppProperties,Launch或Tasks JSON中引用但不希望添加到构建环境本身的变量 - 例如,不会由生成的构建过程继承。

以下示例显示了如何完成创建自定义命名空间:

1
2
3
4
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
三十
31
32
33
34
35
36
37
38
{
  // The "environments" property is an array of key value pairs of the form
  // { "EnvVar1": "Value1", "EnvVar2": "Value2" }
  "environments": [
    {
      "INCLUDE": "${workspaceRoot}\\src\\includes"
    },
    {
      // "namespace" is a reserved key that lets you put variables
      // in namespaces other than $env.
      "namespace": "special",
      // SpecialVar will not be added to the environment.
      "SpecialVar": "special"
    }
 
  ],
 
  "configurations": [
    {
      "inheritEnvironments": [
        // Inherit the MSVC 32-bit environment and toolchain.
        "msvc_x86"
      ],
      "name": "x86",
      "includePath": [
        // Use the include path defined above.
        "${env.INCLUDE}"
      ],
      "defines": [
        // You can use alternative namespaces (such as special defined above)
        // just like "${env.VAR}"
        "${special.specialVar}",
        "WIN32", "_DEBUG", "UNICODE", "_UNICODE"
      ],
      "intelliSenseMode": "msvc-x86"
    }
  ]
}

您可以使用语法“$ {special.SpecialVar}”在任何CppProperties,Launch或Tasks JSON文件中访问“SpecialVar”,如第32行所示。

向我们发送反馈

要试用最新和最好的C ++功能并给我们一些早期反馈,请下载并安装最新的  Visual Studio 2017 Preview一如既往,我们欢迎您的反馈。您可以通过电子邮件发送电子邮件至visualcpp@microsoft.com,通过  Twitter @visualcMicrosoft Visual Cpp的 Facebook  发送任何评论

如果您在使用Visual Studio 2017时遇到其他问题,请通过报告问题告诉我们  ,安装程序和IDE本身都可以使用。有关建议,请通过UserVoice告知我们  

 

Visual Studio中的远程任务

来源 https://blogs.msdn.microsoft.com/vcblog/2017/10/23/remote-tasks-in-visual-studio/

We have introduced a new capability to run remote tasks in Visual Studio 2017 15.5 Preview 2.  This capability allows you to run any command on a remote system that is defined in Visual Studio’s Connection Manager. Remote tasks also provide the capability to copy files to the remote system. This feature is added when you install the Linux development with C++ workload . If you want to learn more about the Open Folder capability in general read https://aka.ms/openfolder/cpp.

To get started with this create a file main.cpp in a folder on your PC, add the source below to it and open the folder in VS.

#include 

int main()
{
	std::cout << "Hello" << std::endl;
}

To get Linux IntelliSense for this file go to the menu Project > Edit Settings > CppProperties.json. Modify the file so it just has one entry like the below.

{
  "configurations": [
    {
      "inheritEnvironments": [
        "linux_x64"
      ],
      "name": "Linux-x64",
      "includePath": [
        "${env.INCLUDE}"
      ],
      "defines": [
        
      ]
    }
  ]
}

In the Solution Explorer right click main.cpp and choose Configure Tasks. In the tasks.vs.json file that opens modify the task as follows. This task will copy the directory to the remote machine specified, then run “g++ main.cpp” in the directory specified.

{
  "version": "0.2.1",
  "tasks": [
    {
      "taskName": "Build",
      "appliesTo": "main.cpp",
      "type": "remote",
      "contextType": "build",
      "command": "g++ main.cpp",
      "remoteMachineName": "ubuntu",
      "remoteCopyDirectory": "~/sample",
      "remoteCopyMethod": "sftp",
      "remoteWorkingDirectory": "~/sample/hello",
      "remoteCopySourcesOutputVerbosity": "Verbose"
    } 
  ]
}

You can run this task by right clicking main.cpp in the Solution Explorer and selecting Build. The Output window will show the file copy results. There is no output from this compile command, unless you have an error.

The field type is where we can change the context of the type to run on the remote machine, command is what will be executed there. The context type build places this command into that area of the context menu for the file the task applies to. The field remoteMachineName needs to match a defined connection in the Visual Studio Connection Manager. You can find that in the Quick Launch (Ctrl+Q) by typing Connection Manager, or under Tools > Options > Cross Platform > Connection Manager. Note that you can specify different directories for where to copy files vs where to run commands with the fields remoteCopyDirectoy and remoteWorkingDirectory. When the files are copied they are copied into a folder of the same name as the folder you have open in Visual Studio at the location specified. By default commands are executed in your home directory on the remote system. You can also specify the method you want to use for copying, sftp, rsync or none to disable. The rsync method is recommended for large projects. The remoteCopySourcesOutputVerbosity option is not necessary but is useful to know about if you are trying to diagnose an issue.

You can do anything you like with remote tasks of course. To run the output of our first command above, add another task after the one above.

    {
      "taskName": "Run",
      "appliesTo": "main.cpp",
      "type": "remote",
      "command": "./a.out",
      "remoteMachineName": "localhost",
      "remoteWorkingDirectory": "~/sample/hello",
      "remoteCopySourcesOutputVerbosity": "Verbose"
    }

This task will show up as “Run” at the bottom of the context menu when you select main.cpp in the Solution Explorer. When executed, after you have compiled, you should see “Hello” in the output window.

What’s next

Download the Visual Studio 2017 Preview, install the Linux C++ Workload, and give it a try with your projects.

This is a very simple example of this new feature. We look forward to hearing about how you are using it in your projects.

The best way to reach us is via our GitHub hosted issue list, directly via mail at vcpplinux-support@microsoft.com or find me on Twitter @robotdad.

 

==================== End

 

使用Visual C ++和Open Folder自定义环境

标签:syn   二进制   msbuild   sub   names   end   嵌入   std   运行   

原文地址:https://www.cnblogs.com/lsgxeva/p/9474853.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!