@@ -88,23 +88,37 @@ function Update-NuspecFileReleaseNotes ([string] $releaseInfo) {
8888 }
8989}
9090
91+ function BumpVersion ([string ] $currentVersion ) {
92+ $versionParts = $currentVersion.split (" ." )
93+ $minor = [Int ]($versionParts [1 ]) + 1
94+
95+ $versionPattern = " (\d)\.(\d)\.(\d)"
96+ $versionReplacePattern = ' $1.' + $minor + ' .$3'
97+
98+ $version = $currentVersion -replace $versionPattern , $versionReplacePattern
99+ return $version ;
100+ }
101+
91102# -------------------------------------------------------------------------------
92103# Parse arguments.
93104# -------------------------------------------------------------------------------
94- $version = $args [0 ]
95- while ($version -notmatch " [0-9]+(\.([0-9]+|\*)){1,3}" ) {
96- if ($version -eq ' /?' ) {
97- Help
98- }
99- else {
100- " About to update the version of nuget package .nuspec and AssemblyInfo.cs files."
101- $version = Read-Host ' Enter new version'
102- }
103- }
105+ # $version = $args[0]
106+
107+ $NuSpecFilePath = " ..\UnitsNet.nuspec"
108+ [ xml ]$nuspecXml = Get-Content - Path $NuSpecFilePath
109+
110+ $currentVersion = $nuspecXml.package.metadata.version
111+ $newVersion = BumpVersion($currentVersion )
112+
113+ $nuspecXml.package.metadata.version = $newVersion
114+ $nuspecXml.Save ($NuSpecFilePath )
115+
116+ " Current version: " + $currentVersion
117+ " New version: " + $newVersion
104118
105119$releaseNotes = Read-Host ' Enter release notes for .nuspec file'
106120
107- Update-AssemblyInfoFiles $version
108- Update-NuspecFiles $version
121+ Update-AssemblyInfoFiles $newVersion
122+ Update-NuspecFiles $newVersion
109123Update-NuspecFileReleaseNotes $releaseNotes
110124
0 commit comments