从 Azure DevOps 管道启动适用于 VS 2019 的开发人员 PowerShell [英] Start Developer PowerShell for VS 2019 from Azure DevOps pipeline

查看:36
本文介绍了从 Azure DevOps 管道启动适用于 VS 2019 的开发人员 PowerShell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经配置了一个 Windows 虚拟机并在那里部署了一个代理来构建我们的代码和运行脚本.

在我们的 VM 中,我们有两种不同风格的 PowerShell 命令提示符:

  1. Windows PowerShell
  2. 适用于 VS 2019 的开发人员 PowerShell.

我们如何从我们的管道 YAML 脚本中启动Developer PowerShell for VS 2019"并在那里执行我们检出的 .ps1 文件?

虽然可以从管道中启动多种 PowerShell 任务,但不确定其中哪一种可以达到目的.它们如下:

  1. Azure PowerShell
  2. PowerShell
  3. 目标机器上的 PowerShell
  4. Service Fabric PowerShell.

以上哪些代表适用于 VS 2019 的开发人员 PowerShell"?

这种特殊风格的 PowerShell 背后的原因是:

  1. 需要一些 .NET Framework 工具 (CorFlags.exe),这些工具只能在Developer PowerShell for VS 2019"中访问,而不能在其他工具中访问.

解决方案

Developer PowerShell for VS 2019 是一个带有导入模块的常规 PowerShell,您可以通过这种方式确切地看到:>

  • 转到开始"菜单并搜索 Developer PowerShell for VS 2019.
  • 右键单击它并打开文件位置 - 您将看到:

  • 现在再次右键单击Developer PowerShell for VS 2019快捷方式和属性.

  • 您将在 位置 中看到使用一些命令运行常规 PowerShell:

    C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -noe -c "&{Import-Module """C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"""; Enter-VsDevShell bc97b47b}"

现在,如果您打开 PowerShell 并在那里运行脚本:

&{Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll";输入-VsDevShell bc97b47b}

您将获得适用于 VS 2019 的 Developer PowerShell,并且 CoreFlags.exe 将起作用:

因此,您需要使用常规 PowerShell 任务(您的选项 2)并在脚本请求时运行上述命令.

注意:您应该完全复制您在属性中看到的命令,在每台机器上它可能会有所不同.

We have configured a windows virtual machine and deployed an agent there to build our code and run scripts.

In our VM we two different flavors of PowerShell command prompt:

  1. Windows PowerShell
  2. Developer PowerShell for VS 2019.

How can we start "Developer PowerShell for VS 2019" from our pipeline YAML script and execute our checked out .ps1 file there?

There are several flavors of PowerShell tasks that can be initiated from the pipeline though and not sure which one of them will serve the purpose. They are the following:

  1. Azure PowerShell
  2. PowerShell
  3. PowerShell on Target Machine
  4. Service Fabric PowerShell.

Which of the above represent "Developer PowerShell for VS 2019"?

The reason behind this specific flavor of PowerShell is:

  1. Need to have some of the .NET Framework Tools (CorFlags.exe) which are only accessible in the "Developer PowerShell for VS 2019" and not in the other one.

解决方案

The Developer PowerShell for VS 2019 is a regular PowerShell with a module imported, you can see exactly what in this way:

  • Go the Start menu and search for Developer PowerShell for VS 2019.
  • Right-click on it and Open file location - you will get this:

  • Now right-click again on the Developer PowerShell for VS 2019 shortcut and Properties.

  • You will see in the location that is run the regular PowerShell with some command:

    C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -noe -c "&{Import-Module """C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"""; Enter-VsDevShell bc97b47b}"

Now, if you open a PowerShell and run the script there:

&{Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"; Enter-VsDevShell bc97b47b}

You will get the Developer PowerShell for VS 2019 and CoreFlags.exe will work:

So, you need to use the regular PowerShell task (your option 2) and run the above command at the begging of the script.

Note: you should copy exactly the command you see in the Properties, in each machine it could be different.

这篇关于从 Azure DevOps 管道启动适用于 VS 2019 的开发人员 PowerShell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆