私は、アプリケーションでいくつかのSeleniumテストを実行するためにpowershellからnuintコンソールを実行しようとしています。Powershellで最新のフォルダ名を取得しようとしています
PowerShellのcommmandは以下の通りです:
$command = 'D:\tools\NUnitTestRunner\nunit3-console.exe "\\myserver\Drops\MyProj\MyApp_20170214.1\App.Selenium.Tests.dll"'
iex $command
予想通り、この作品。しかし、私が変更したいのはダブル ""です。 MyApp_DATE.DropNumberフォルダが変更されて、新しいApp.Selenium.Test.dllがドロップされるフォルダにリリースがドロップされたときに回帰テストを実行したい。
だから私はパスの下に持っているかもしれ\ MYSERVER \ドロップ\ MYPROJ以下のようなフォルダ\:
MyApp_20170214.1
MyApp_20170214.2
MyApp_20170214.3
MyApp_20170214.4
私はむしろ、それぞれに移動することよりも、動的に最新のフォルダを取得し、コマンドに入れたいです時間とハードコードそれ。
$logFile = "$PSScriptRoot\NunitLog.txt"
$dir = "\\myserver\Drops\MyProj\"
#Go get the latest Folder Name
$latest = Get-ChildItem $dir Where { $_.PSIsContainer } | Sort CreationTime -Descending | Select -First 1
#remove old log file
if(Test-Path $logFile) { Remove-Item $logFile }
"Starting Selenium Tests" | Out-File $logFile -Append
$latest.name | Out-File $logFile -Append
#Start nUnit Console and pass argument which is the latest path to the dll of the tests
#$command = 'D:\tools\NUnitTestRunner\nunit3-console.exe "$latest.name"'
はしかし、それはあなたのコードがDIR &場合、取り込むときの間のパイプがありませんでした
これは私が必要としていたものです - 歓声 –
クール。喜んで:) – TechSpud