使用PowerShell开发者命令提示符构建解决方案。

huangapple go评论61阅读模式
英文:

Use PowerShell developer command prompt to build solution

问题

如何在PowerShell脚本中使用开发人员PowerShell命令提示符Launch-VsDevShell.ps1来编译解决方案?

我希望在开发人员控制台的环境中进行编译
当运行此脚本时,我可以访问所有的环境变量

当我从脚本中启动Launch-VsDevShell.ps1时,我无法看到在执行Launch-VsDevShell.ps1后使用给定参数启动msbuild的选项。

我希望以参数的方式启动Launch-VsDevShell.ps1,类似于这样

& "C:\Program Files\Microsoft Visual Studio22\Professional\Common7\Tools\Launch-VsDevShell.ps1" -arglist

当使用直接的msbuild.exe时,我使用以下代码

$arglist = "$workfolder\build$sln /m /nr:false /bl:$workfolder\Logs\binarylog_$date_$sln.binlog /nologo /flp:errorsonly;LogFile=$msbuildlogErr"

$resbuild = Start-Process $msbuild -ArgumentList $arglist -PassThru

我找不到任何示例。

英文:

How do use the developer powershell command prompt Launch-VsDevShell.ps1 in powershell script to compile solution ?

I want to compile inside the environment of the developer console
when runing this script i get all environment variable accessible

when i launch the Launch-VsDevShell.ps1 from script i dont have see option to add parameters to start msbuild after the execution of the Launch-VsDevShell.ps1 with given parameters.

i wish to strta the Launch-VsDevShell.ps1 with argumets .
somthing like this

& "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\Tools\Launch-VsDevShell.ps1" -arglist

when using direct msbuild.exe i use the follwoing code

        $arglist = "$workfolder\build$sln /m  /nr:false /bl:$workfolder\Logs\binarylog_$date_$sln.binlog /nologo  /flp:errorsonly;LogFile=$msbuildlogErr"
        
        $resbuild = Start-Process $msbuild -ArgumentList $arglist -PassThru

i couldn't find any example

答案1

得分: 1

Source the file, which will set all environment variables, then compile using msbuild as usual:

. "C:\Program Files\Microsoft Visual Studio22\Professional\Common7\Tools\Launch-VsDevShell.ps1"
msbuild /path/to/solution.sln
英文:

Source the file, which will set all environment variables, then compile using msbuild as usual:

. "C:\Program Files\Microsoft Visual Studio22\Professional\Common7\Tools\Launch-VsDevShell.ps1" 
msbuild /path/to/solution.sln

huangapple
  • 本文由 发表于 2023年3月1日 16:20:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/75601104.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定