-
Notifications
You must be signed in to change notification settings - Fork 3
/
Set-Version.ps1
30 lines (20 loc) · 1.17 KB
/
Set-Version.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
$newVersion = Get-Content "versioninfo.txt"
# Use the current directory as the root directory
$rootDirectory = Get-Location
# Get all AssemblyInfo.cs files in the directory and subdirectories
$assemblyInfoFiles = Get-ChildItem -Path $rootDirectory -Recurse -Filter "AssemblyInfo.cs"
$newAssemblyVersion = 'AssemblyVersion("' + $newVersion + '")';
$newFileVersion = 'AssemblyFileVersion("' + $newVersion + '")';
foreach ($file in $assemblyInfoFiles) {
Write-Host "Processing $($file.FullName)"
# Read the contents of the AssemblyInfo.cs file
$assemblyInfoContent = Get-Content $file.FullName
# Update the AssemblyVersion
$assemblyInfoContent = $assemblyInfoContent -replace 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $newAssemblyVersion
# Update the AssemblyFileVersion
$assemblyInfoContent = $assemblyInfoContent -replace 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $newFileVersion
# Write the updated content back to the AssemblyInfo.cs file
Set-Content $file.FullName -Value $assemblyInfoContent
Write-Host "Updated $($file.FullName)"
}
Write-Host "All AssemblyVersion and AssemblyFileVersion updates completed successfully."