|
6 | 6 | .EXAMPLE
|
7 | 7 | Set new version.
|
8 | 8 | powershell UpdateAssemblyInfo.ps1 1.2.3.4
|
9 |
| - |
| 9 | +
|
10 | 10 | .NOTES
|
11 | 11 | Author: Andreas Gullberg Larsen
|
12 | 12 | Date: May 2, 2014
|
@@ -40,37 +40,38 @@ function Get-VersionFromNuspec ([string] $nuspecFilePath) {
|
40 | 40 | }
|
41 | 41 |
|
42 | 42 | #-------------------------------------------------------------------------------
|
43 |
| -# Description: Sets the AssemblyVersion and AssemblyFileVersion of |
| 43 | +# Description: Sets the AssemblyVersion and AssemblyFileVersion of |
44 | 44 | # AssemblyInfo.cs files.
|
45 | 45 | #
|
46 | 46 | # Author: Andreas Larsen
|
47 | 47 | # Version: 1.0
|
48 | 48 | #-------------------------------------------------------------------------------
|
49 |
| -function Update-AssemblyInfoFiles ([string] $libName) { |
| 49 | +function Update-AssemblyInfoFiles ([string] $nuspecFilePath, [string] $assemblyInfoFilePath) { |
50 | 50 |
|
51 |
| - [Version]$version = Get-VersionFromNuspec "$root\Build\$libName.nuspec" |
| 51 | + [Version]$version = Get-VersionFromNuspec "$root\$nuspecFilePath" |
52 | 52 |
|
53 | 53 | $assemblyVersionPattern = 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
|
54 | 54 | $fileVersionPattern = 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
|
55 | 55 | $assemblyVersion = 'AssemblyVersion("' + $version + '")';
|
56 | 56 | $fileVersion = 'AssemblyFileVersion("' + $version + '")';
|
57 |
| - |
58 |
| - Get-ChildItem "$root\$libName\Properties" | Where { $_.PSChildName -match "^AssemblyInfo\.cs$"} | ForEach-Object { |
| 57 | + |
| 58 | + Get-ChildItem "$root\$assemblyInfoFilePath" | ForEach-Object { |
59 | 59 | $filename = $_.Directory.ToString() + '\' + $_.Name
|
60 | 60 | $filename + ' -> ' + $version
|
61 |
| - |
| 61 | + |
62 | 62 | (Get-Content $filename -Encoding UTF8) | ForEach-Object {
|
63 | 63 | % {$_ -replace $assemblyVersionPattern, $assemblyVersion } |
|
64 | 64 | % {$_ -replace $fileVersionPattern, $fileVersion }
|
65 | 65 | } | Set-Content $filename -Encoding UTF8
|
66 |
| - } |
| 66 | + } |
67 | 67 | }
|
68 | 68 |
|
69 | 69 | try {
|
70 | 70 | "Updating assembly info to version: $setVersion"
|
71 | 71 | ""
|
72 |
| - Update-AssemblyInfoFiles "UnitsNet" |
73 |
| - Update-AssemblyInfoFiles "UnitsNet.Serialization.JsonNet" |
| 72 | + Update-AssemblyInfoFiles "Build\UnitsNet.nuspec" "UnitsNet\Properties\AssemblyInfo.cs" |
| 73 | + Update-AssemblyInfoFiles "Build\UnitsNet.WindowsRuntimeComponent.nuspec" "UnitsNet\Properties\AssemblyInfo.WindowsRuntimeComponent.cs" |
| 74 | + Update-AssemblyInfoFiles "Build\UnitsNet.Serialization.JsonNet.nuspec" "UnitsNet.Serialization.JsonNet\Properties\AssemblyInfo.cs" |
74 | 75 | }
|
75 | 76 | catch {
|
76 | 77 | $myError = $_.Exception.ToString()
|
|
0 commit comments