浏览代码

Simplify powershell command.

Martijn Laan 4 月之前
父节点
当前提交
d58bc8aa18
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      issig.bat

+ 1 - 1
issig.bat

@@ -49,7 +49,7 @@ set publickeyfile=_temp.ispublickey
 ISSigTool.exe export-public-key "%publickeyfile%"
 ISSigTool.exe export-public-key "%publickeyfile%"
 if errorlevel 1 goto failed
 if errorlevel 1 goto failed
 if not exist "%publickeyfile%" goto failed
 if not exist "%publickeyfile%" goto failed
-powershell.exe -NoProfile -Command "& { $filePath = '%targetfile%'; $replacementFilePath = '%publickeyfile%'; $startMarker = \"AllowedPublicKey2Text := '''\"; $endMarker = \"''';//end\"; try { $content = Get-Content -Raw -Path $filePath; $replacementText = Get-Content -Raw -Path $replacementFilePath; [string] $pattern = '(?s)' + [regex]::Escape($startMarker) + '.*?' + [regex]::Escape($endMarker); if ($content -match $pattern) { $replacement = $startMarker + \"`r`n\" + $replacementText + \"`r`n\" + $endMarker; $newContent = $content -replace $pattern, $replacement; $utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($false); [System.IO.File]::WriteAllText($filePath, $newContent, $utf8NoBomEncoding); Write-Host 'Embedded key.'; } else { Write-Host 'Markers not found.'; exit 1; } } catch { Write-Error ('Error: ' + $_.Exception.Message); exit 1; } }"
+powershell.exe -NoProfile -Command "$filePath = '%targetfile%'; $replacementFilePath = '%publickeyfile%'; $startMarker = \"AllowedPublicKey2Text := '''\"; $endMarker = \"''';//end\"; try { $content = Get-Content -Raw -Path $filePath; $replacementText = Get-Content -Raw -Path $replacementFilePath; [string] $pattern = '(?s)' + [regex]::Escape($startMarker) + '.*?' + [regex]::Escape($endMarker); if ($content -match $pattern) { $replacement = $startMarker + \"`r`n\" + $replacementText + \"`r`n\" + $endMarker; $newContent = $content -replace $pattern, $replacement; $utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($false); [System.IO.File]::WriteAllText($filePath, $newContent, $utf8NoBomEncoding); Write-Host 'Embedded key.'; } else { Write-Host 'Markers not found.'; exit 1; } } catch { Write-Error ('Error: ' + $_.Exception.Message); exit 1; }"
 if errorlevel 1 goto failed
 if errorlevel 1 goto failed
 del "%publickeyfile%"
 del "%publickeyfile%"
 if errorlevel 1 goto failed
 if errorlevel 1 goto failed