更改版本号SED.exe

时间:2018-06-19 18:19:06

标签: .net batch-file sed

我正在使用以下脚本替换AssemblyInfo.cs中的内部版本号

[assembly: AssemblyInformationalVersion("1.0.0.0")] -> [assembly: AssemblyInformationalVersion("1.0.0.Build_Number")]

但是我想这样做:

[assembly: AssemblyInformationalVersion("1.0.0.0")]->[assembly: AssemblyInformationalVersion("major.minor.build_number.revision")]

请让我知道是否有人使用过SED,这是我第一次使用它,所以有关表达式术语的信息较少。

@ECHO OFF

SET SRC=%1

IF "%~1"=="" GOTO :error
IF "%BUILD_NUMBER%"=="" GOTO :notset
IF NOT EXIST "%SRC%" GOTO :notfound

SED -i "s^\(Assembly\(Informational\|File\)Version(\d34[0-9]\+\.[0-9]\+\.[0-9]+\.\)\+^\1%BUILD_NUMBER%^" "%SRC%"

IF %ERRORLEVEL% NEQ 0 GOTO :failed

GOTO :eof

:notset
echo {0e}WARNING: BUILD_NUMBER environment variable not set, performing no action{#}{\n}
EXIT /b 0

:failed
echo {0c}ERROR  : Failed to process command{#}{\n}
EXIT /b 1

:notfound
echo {0c}ERROR  : Source '%1' not found{#}{\n}
EXIT /b 1

:error
echo {0c}ERROR  : Source not specified{#}{\n}
EXIT /b 1

0 个答案:

没有答案