【问题标题】:Building Linux C++ with VSTS使用 VSTS 构建 Linux C++
【发布时间】:2018-05-24 20:00:14
【问题描述】:

我正在尝试使用 VSTS 为 Linux 构建 C++ 应用程序。构建由 Docker 容器模板定义,Agent 队列为 Hosted Linux。

跑步时,我得到 [错误]未处理:未找到与 /opt/vsts/work/1/s/**/Dockerfile 匹配的 Docker 文件。

如何创建错误消息请求的 Docker 文件?

【问题讨论】:

    标签: c++ linux docker azure-devops


    【解决方案1】:

    该错误表示工作文件夹中不存在Dockerfile文件,您可以将Dockerfile文件包含在源代码管理中并映射到代理(获取构建定义的来源)

    有别人共享的Docker镜像,例如:madduci/docker-ubuntu-cpp,CMake生成的文件会在build文件夹下,如果你只需要build C++项目,可以参考这些步骤(CMakeLists.txt位于存储库的根目录中):

    1. 添加 Docker 任务(操作:Run a Docker command;命令:run -v $(Build.SourcesDirectory):/project madduci/docker-ubuntu-cpp
    2. 发布构建工件(发布路径:$(Build.SourcesDirectory)/build

    如果需要构建 docker 镜像,需要创建 Dockerfile。

    【讨论】:

    • 谢谢。我只需要构建 C++ 项目。我添加了Run a Docker commandrun -v $(Build.SourcesDirectory)/LinuxConsoleApplication madduci/docker-ubuntu-cpp,并在存储库的根目录中创建了一个CMakeLists.txt 文件。但是我得到Status: Downloaded newer image for madduci/docker-ubuntu-cpp:latest CMake Error: The source directory "/project" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. Error: could not load cache。想法?
    • 使用 run -v $(Build.SourcesDirectory)/LinuxConsoleApplication:/project madduci/docker-ubuntu-cpp 代替,它会将 $(Build.SourcesDirectory)/LinuxConsoleApplication 中的文件复制到 docker 容器的项目文件夹中。注意:CMakeLists.txt 位于 LinuxConsoleApplication 文件夹下。
    • @EricaC 现在结果如何?你解决了这个问题吗?
    • 是的!太感谢了。我很感激。由于建议不要在 cmets 框中回复谢谢,因此我没有发布答案...我不同意此政策...
    【解决方案2】:

    当 Docker 任务设置为构建映像时,您可以选择指定 Docker 文件:

    **/Dockerfile 表示该任务将在您的存储库中搜索名为 Dockerfile 的文件并使用该文件构建映像。

    您收到的错误意味着找不到此文件。您可以找到一些 Dockerfiles here in the Docker documentation 的示例。 This blog 描述了如何构建在 Linux 容器上运行的 C++ 应用程序

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-28
      • 1970-01-01
      相关资源
      最近更新 更多