forked from FlaUI/FlaUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdjustConfig.ps1
36 lines (29 loc) · 1.44 KB
/
AdjustConfig.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$newVersion = "0.6.2"
$newConfiguration = "Release"
function Main() {
ReplaceVersion
ReplaceConfiguration
}
function ReplaceVersion {
RegexReplaceTextInFile "CreateArtefacts.ps1" "(?<=\`$version = `").*?(?=`")" $newVersion
RegexReplaceTextInFile "src\FlaUInspect\FlaUInspect.nuspec" "(?<=<version>).*?(?=</version>)" $newVersion
ReplaceAssemblyVersion "src\FlaUI.Core\Properties\AssemblyInfo.cs" $newVersion
ReplaceAssemblyVersion "src\FlaUI.UIA2\Properties\AssemblyInfo.cs" $newVersion
ReplaceAssemblyVersion "src\FlaUI.UIA3\Properties\AssemblyInfo.cs" $newVersion
ReplaceAssemblyVersion "src\FlaUInspect\Properties\AssemblyInfo.cs" $newVersion
}
function ReplaceConfiguration {
RegexReplaceTextInFile "CreateArtefacts.ps1" "(?<=\`$configuration = `").*?(?=`")" $newConfiguration
RegexReplaceTextInFile "src\FlaUInspect\FlaUInspect.nuspec" "(?<=src=`"bin\\).*?(?=\\)" $newConfiguration
}
function ReplaceAssemblyVersion($assemblyFile, $version) {
RegexReplaceTextInFile $assemblyFile "(?<=AssemblyVersion\(`").*?(?=`"\))" $version
RegexReplaceTextInFile $assemblyFile "(?<=AssemblyFileVersion\(`").*?(?=`"\))" $version
RegexReplaceTextInFile $assemblyFile "(?<=AssemblyInformationalVersion\(`").*?(?=`"\))" $version
}
function RegexReplaceTextInFile($file, $from, $to) {
$content = [System.IO.File]::ReadAllText($file)
$content = $content -replace $from, $to
[System.IO.File]::WriteAllText($file, $content)
}
Main