Azure DevOps管道如何设置VCVARS64.BAT然后从批处理文件调用msbuild.exe?

发布于 2025-01-26 22:04:08 字数 862 浏览 2 评论 0原文

在本地机器上,我执行 build.bat 打开 x64本机工具命令提示vs vs for 2019 ,然后 build.bath.bat 调用 call < strong> msbuild.exe 。

call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
build.bat

在Azure DevOps管道CMDLine任务中,我该怎么做?

build.bat 呼叫 msbuild.exe 从azure-pipelines.yml cmdline 任务时会失败。

是否有可靠的方法可以找到和调用VCVARS64.BAT,以便找到msbuild.exe?

- task: CmdLine@2
  displayName: 'build.bat calls msbuild'
  inputs:
    script: |
      build.bat

Azure管道错误:

2022-05-06T15:42:53.3802703Z 'msbuild' is not recognized as an internal or external command,
2022-05-06T15:42:53.3803010Z operable program or batch file.

事先感谢您的任何提示或方向。

On a local machine, I execute my build.bat after opening a x64 Native Tools Command Prompt for VS 2019, then build.bat calls msbuild.exe.

call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
build.bat

How can I do same in an Azure DevOps pipeline CmdLine task?

The build.bat call to msbuild.exe fails when called from azure-pipelines.yml CmdLine task.

Is there a reliable method to locate and call vcvars64.bat so that msbuild.exe can be found?

- task: CmdLine@2
  displayName: 'build.bat calls msbuild'
  inputs:
    script: |
      build.bat

Azure pipeline error:

2022-05-06T15:42:53.3802703Z 'msbuild' is not recognized as an internal or external command,
2022-05-06T15:42:53.3803010Z operable program or batch file.

Thanks in advance for any tips or direction.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

握住我的手 2025-02-02 22:04:08

从我的角度来看,使用批处理文件不在DevOps哲学上。相反,您应该将批处理文件分配到步骤,然后使用适当的DevOps步骤。例如,在MSBUILD的情况下,这是 https://learn.microsoft.com/en-us/azure/devops/pipelines/pasks/tasks/build/msbuild?view= azure-devops

但是,如果您需要直接使用MSBUILD,那么您可以使用与本地env中相同的路径,但是通往VS的路径将取决于您在管道中使用的版本(代理池)

From my point of view, using batch file is out of DevOps philosophy. Instead, you should decompile your batch file to steps and then use appropriate DevOps step. for example, in case of msbuild this is https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/msbuild?view=azure-devops

But if you need to use msbuild directly, then you can use paths same like in your local env, but path to VS will depends on what version (agent pool) you using in your pipeline

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文