0

PowerShell スクリプトを実行すると、非常に奇妙な動作が発生しました。コマンドのサブコマンドを実行したいtf。この実行可能ファイルは、通常、コンソール アプリケーションとして機能しますが、サブコマンドtf resolveコマンドは、私が見たいダイアログを表示します。

ユース ケース 1b と 2b で何が起こっているのか、PowerShell の達人が説明してくれませんか? それとも、ここで何が問題なのかヒントがありますか?

備考:見つからない場合は、インストールに応じて VS のバージョンを変更してください。VS 2015、PowerShell 4、Windows 8.1 を使用しています。

ユースケース 1a: ダイアログが表示される (すべて問題ありません)

$tfCommand = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\tf.exe"
& $tfCommand resolve

ユース ケース 1b: ダイアログが表示されない (WTF?!)

変更点: STDOUT は変数に保存されます

$tfCommand = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\tf.exe"
$someVariable = & $tfCommand resolve

ユースケース 2a: ダイアログが表示される (すべて問題ありません)

$tfCommand = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\tf.exe"

function callTfResolve($tfCommand) { 
   & $tfCommand resolve 
}

CallTfResolve $tfCommand

ユース ケース 2b: ダイアログが表示されない (WTF?!)

変更:の戻り値はCallTfResolve変数に保存されます

$tfCommand = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\tf.exe"

function callTfResolve($tfCommand) { 
   & $tfCommand resolve 
}

$someVariable = CallTfResolve $tfCommand
4

2 に答える 2

1

コマンド ラインに/promptを追加してみてください。

ダイアログUIで表示

$tfexe = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\TF.exe"
$tfscollection = "http://tfs-isl01:8080/tfs/mepcollection"
$arglist = "workspaces /s:$tfscollection" 
Set-ExecutionPolicy Unrestricted
Start-Process $tfexe -ArgumentList $arglist   -RedirectStandardOutput C:\NewWS.log -RedirectStandardError c:\wserror.log -Wait
$arglist = "workspace /new /permission:Public /prompt"
Start-Process $tfexe -ArgumentList $arglist -RedirectStandardOutput C:\NewWS.log

ダイアログ UI を表示しない

$tfexe = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\TF.exe"
$tfscollection = "http://tfs-isl01:8080/tfs/mepcollection"
$arglist = "workspaces /s:$tfscollection" 
Set-ExecutionPolicy Unrestricted
Start-Process $tfexe -ArgumentList $arglist   -RedirectStandardOutput C:\NewWS.log -RedirectStandardError c:\wserror.log -Wait
$arglist = "workspace /new /permission:Public"
Start-Process $tfexe -ArgumentList $arglist -RedirectStandardOutput C:\NewWS.log

http://www.wintellect.com/devcenter/jrobbins/working-offline-with-tfsに感謝します

これで問題が解決することを願っています

于 2016-05-29T11:32:42.350 に答える