0
調用的時候,我有以下PowerShell的命令從PowerShell中直接調用時工作完全正常:替換字符串不工作從CMD
Get-ChildItem -r -include 'AssemblyInfo.cs' `
| foreach-object { $a = $_.fullname; (get-content $a) `
| foreach-object { $_ -replace '((\[assembly:\sAssemblyVersion\(")(\d\.\d\.\d\.\d)("\)\]))', '$1[assembly:AssemblyInformationalVersion("$3-alpha")]' } `
| Out-File $_.fullname }
然而,從CMD叫(我們Buildservers進程在cmd中運行)時它不會引發錯誤,但它也簡化版,替換字符串如預期(它可以從任何CMD窗口轉載):
PowerShell -Command "(Get-ChildItem -r -include 'AssemblyInfo.cs') | foreach-object { $a = $_.fullname; (get-content $a) | foreach-object { $_ -replace '((\[assembly:\sAssemblyVersion\(")(\d\.\d\.\d\.\d)("\)\]))', '$1[assembly:AssemblyInformationalVersion("$3-alpha")]' } | Out-File $_.fullname }"
我逃脫引號的標誌嘗試四周,命令中使用and
&`但它沒有幫助。
我錯過了什麼?
謝謝你,夥計! – nozzleman