Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何构建从Windows PowerShell或PowerShell ISE调用的Visual Studio 2019 C#解决方案命令行_C#_Visual Studio_Powershell_Command Line_Build - Fatal编程技术网

如何构建从Windows PowerShell或PowerShell ISE调用的Visual Studio 2019 C#解决方案命令行

如何构建从Windows PowerShell或PowerShell ISE调用的Visual Studio 2019 C#解决方案命令行,c#,visual-studio,powershell,command-line,build,C#,Visual Studio,Powershell,Command Line,Build,如果我为VS2019启动Developer PowerShell,我可以构建我的C#解决方案,并在devenv进程退出时返回控制权 $argsList = "/build Debug mysolution.sln" $process = Start-Process devenv.exe -ArgumentList $argsList -PassThru -Wait if ($process.ExitCode -eq 0) { Write-Host "comp

如果我为VS2019启动Developer PowerShell,我可以构建我的C#解决方案,并在devenv进程退出时返回控制权

$argsList = "/build Debug mysolution.sln"
$process = Start-Process devenv.exe -ArgumentList $argsList -PassThru -Wait
if ($process.ExitCode -eq 0) {
    Write-Host "completed"
} else {
    Write-Host "failed"
}
我希望能够从Windows 2016 server PowerShell或PowerShell ISE执行相同的操作,以便调试更复杂的脚本。首先,VisualStudio二进制文件不在路径中,但困扰我的是,devenv进程在启动进程后退出而不返回控制权

$devenvPath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe"
$argsList = "/build Debug mysolution.sln"
$process = Start-Process $devenvPath -WorkingDirectory . -ArgumentList $argsList -PassThru -Wait
if ($process.ExitCode -eq 0) {
    Write-Host "completed"
} else {
    Write-Host "failed"
}
  • 如何从“常规”PS调用VisualStudio Power shell,该shell附带为构建作业加载的额外模块和设置的路径
  • 如何将生成输出重定向到PS窗口-传递给启动进程的NoNewWindow不会执行此操作。不过,我可以使用“devenv/Out file”选项重定向到文件
  • 我做错了什么,devenv退出了,但脚本并没有回来,或者在很长一段时间后才出现

  • “开发者PowerShell”开发者只是一个文件链接。看看目标,你会看到加载的模块,等等。3。)你能更具体一点吗?你有什么行为?您如何看待“退出”过程?另外,
    start process
    应立即返回process对象。你的“剧本不回来”到底在哪里?当传递-Wait标志直到进程结束时,可以尝试重新表述maybestart进程被阻塞。这允许确保构建工件准备就绪,所以我继续下一步。问题是,在第二种情况下,即使在devenv进程结束后,控件也不会返回到脚本。