用Powershell转换批处理命令,找到文件并创建参数。

在一个 cmd 窗口,我搜索一个特定的文件,然后把它传递到一个可执行文件中。findstr …

 cmd /r dir /s /b RunnerUnitTest.dll | findstr /r bin\\ > tests_list.txt
 cmd /r for /f %f in (tests_list.txt) do vstest.console.exe "%f"

You can do something like this without an intermediate file, since

will return a

object for files, and

objects for directories (both of which are derived from

):

What this will do is recursively search for all files found named

with parent folders

and

, and then for each file returned (I’ve added a

to ensure we only get one assembly back but this is optional) pass the full path to the assembly to the

解决方案:

folder won’t be returned at all for execution consideration.Get-ChildItemAs an FYI, piping with FileInfo works much in the same way as it does with other shells like DirectoryInfo or FileSystemInfo, but it supports passing around complex objects instead of strings. As a general rule, you can pipe any output on the

Get-ChildItem -Recurse bin\Debug\RunnerUnitTest.dll | Select-Object -First 1 | Foreach-Object {
  vstest.console.exe $_.FullName
}

output streamRunnerUnitTest.dll to other cmdlets or save the output to variables. DebugRedirection operatorsbin work similarly as well.Select-Object -First 1第一个命令寻找文件,它找到了两个。vstest.console.exe

RunnerUnitTest/bin/Debug/RunnerUnitTest.dll。obj


RunnerUnitTest/obj/Debug/RunnerUnitTest.dll|然后它将其缩小到一个(路径中的bin),并将其粘贴到一个文件中。BashRunnerUnitTest/bin/Debug/RunnerUnitTest.dll。cmd第二行把这个输出作为参数传到一个可执行文件中。顺便说一下,这是为gitlab运行程序准备的。 在cmd窗口中,我搜索一个特定的文件,然后将其传递到一个可执行文件中。我想用PowerShell重做,但作为新手,我不知道该怎么做。 cmd r dir s b RunnerUnitTest.dll

给TA打赏
共{{data.count}}人
人已打赏
解决方案

反序列化嵌套的Json C#

2022-4-22 22:00:14

解决方案

获取firebase子值

2022-4-22 22:00:16

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索