Skip to content

v4.0.0 #487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 164 commits into from
Dec 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
8c4e989
UnitsNet: 4.0.0-alpha1
angularsen Sep 27, 2018
4baa18e
JsonNet: 4.0.0-alpha1
angularsen Sep 27, 2018
6cfc4c8
Merge remote-tracking branch 'angularsen/master' into v4
tmilnthorp Sep 28, 2018
3cb3efd
Removing obsolete quantity units
tmilnthorp Sep 27, 2018
6752b26
Removing equality methods/operators that do not accept a relative/abs…
tmilnthorp Sep 27, 2018
f59e55a
Removing nullable methods from quantity classes as well as extension …
tmilnthorp Sep 24, 2018
71c0b1f
ParseUnit(string, string) needs to be split in code generators. The .…
tmilnthorp Sep 28, 2018
40e5223
Merge branch 'RemoveEquality' into RemoveObsoleteMethods
tmilnthorp Sep 28, 2018
c5fb076
Merge branch 'RemoveNullableMethods' into RemoveObsoleteMethods
tmilnthorp Sep 28, 2018
fde5ede
Merge branch 'SplitParseUnitForObsoletion' into RemoveObsoleteMethods
tmilnthorp Sep 28, 2018
3c09292
Merge branch 'RemoveObsoleteUnits' into RemoveObsoleteMethods
tmilnthorp Sep 28, 2018
c32c9d2
Removing obsolete methods
tmilnthorp Sep 28, 2018
84e93db
Merge remote-tracking branch 'origin/master' into v4
angularsen Sep 28, 2018
794777d
Merge remote-tracking branch 'tmil/RemoveObsoleteMethods' into v4
angularsen Sep 28, 2018
c64a697
Changing target frameworks to .NET standard 2.0 and .NET 4.0 (#488)
tmilnthorp Sep 28, 2018
f42b491
appveyor: Remove environment.api_key
angularsen Sep 28, 2018
4d48000
appveyor: Publish nuget on v4 branch
angularsen Sep 28, 2018
4b6acb4
UnitsNet: 4.0.0-alpha2
angularsen Sep 28, 2018
77cb361
JsonNet: 4.0.0-alpha2
angularsen Sep 28, 2018
a1ba3b9
Fix script to bump suffix version
angularsen Sep 28, 2018
1db7ac7
Do not use suffix in assembly version
angularsen Sep 28, 2018
5a5d663
UnitsNet: 4.0.0-alpha3
angularsen Sep 28, 2018
7455471
JsonNet: 4.0.0-alpha3
angularsen Sep 28, 2018
ab5e33f
Log msbuild live to AppVeyor and to log file
angularsen Sep 28, 2018
ebeaa6c
Fix some warnings about missing xmldoc
angularsen Sep 28, 2018
5e8ac05
Ignore thousands of warnings about no xml doc
angularsen Sep 28, 2018
407e72b
Fix SingularName for some units in VolumeFlow (#494)
tmilnthorp Sep 28, 2018
93c79dd
Attempt to fix AppVeyor logger for WRC
angularsen Sep 28, 2018
d2d3794
Remove == and != operators of Duration
angularsen Sep 28, 2018
622bb33
Fix minor warnings and code issues
angularsen Sep 28, 2018
108ae7c
Fix unused param in Length2dTests
angularsen Sep 28, 2018
b5cf639
Remove static methods of UnitSystem
angularsen Sep 28, 2018
5202adc
Make IsFallbackCulture private
angularsen Sep 28, 2018
e1c3adf
Try to fix deploy in v4 branch
angularsen Sep 28, 2018
4f48637
Add caching and other seemingly useful options
angularsen Sep 28, 2018
7f1107c
Change deploy to branch release/v4
angularsen Sep 28, 2018
ed9561a
Remove all number extension methods
angularsen Sep 28, 2018
e9060d6
Remove generated code for number extensions
angularsen Sep 28, 2018
6521156
Remove/fix test cases
angularsen Sep 28, 2018
134d075
Fix code issues flagged by R#
angularsen Sep 28, 2018
a0ab229
Update README with v4 changes
angularsen Sep 28, 2018
67f2629
Merge pull request #498 from angularsen/v4-readme
tmilnthorp Oct 1, 2018
e8644e0
Merge pull request #497 from angularsen/v4-remove-number-extensions
tmilnthorp Oct 1, 2018
0e3dba3
Use FallbackCulture rather than re-defining en-US
tmilnthorp Oct 1, 2018
cece5fb
Throw ArgumentException if constructed with Undefined value
tmilnthorp Oct 1, 2018
0aab57b
Merge pull request #496 from angularsen/v4-remove-unitsystem-static
tmilnthorp Oct 1, 2018
f2650dc
QuantityValue: Do not allow NaN value
angularsen Oct 1, 2018
fb099e4
Revert "QuantityValue: Do not allow NaN value"
angularsen Oct 1, 2018
5d24432
Remove all TODOs in code
angularsen Oct 1, 2018
f677ec1
Remove Length2d (#501)
angularsen Oct 1, 2018
4d17f15
QuantityValue: Do not allow NaN value
angularsen Oct 1, 2018
f23d389
Also throw on infinity values and add tests
angularsen Oct 1, 2018
83db4ec
Fix xmldoc error
angularsen Oct 1, 2018
02ae423
Merge pull request #502 from angularsen/v4-throw-on-nan
tmilnthorp Oct 2, 2018
c84aadd
Remove extension methods (#505)
tmilnthorp Oct 3, 2018
9a134f5
Do not throw in TryXXX methods in UnitConverter
tmilnthorp Oct 3, 2018
2c39cbf
Implementing TryParse methods to not do try/catch. (#507)
tmilnthorp Oct 5, 2018
2aa6847
Don't use try/catch for Tryparse in UnitSystem (#508)
tmilnthorp Oct 8, 2018
ff76c27
Updating language version to C# 7.3 to allow for Enum constraints (#509)
tmilnthorp Oct 9, 2018
3c0b22a
Simplify Parse/TryParse methods
tmilnthorp Oct 10, 2018
1bf14a8
Splitting UnitSystem class into more focused classes
tmilnthorp Oct 11, 2018
79ce236
tmilnthorp Oct 11, 2018
f9c6790
tmilnthorp Oct 11, 2018
b9f5698
Adding generic IQuantity interface for .NET Framework targets (#512)
tmilnthorp Oct 11, 2018
eba720e
tmilnthorp Oct 12, 2018
1ada74a
tmilnthorp Oct 12, 2018
4a67832
tmilnthorp Oct 12, 2018
6d86563
tmilnthorp Oct 12, 2018
463c63c
Merge remote-tracking branch 'angularsen/master' into v4
tmilnthorp Oct 12, 2018
6af3595
Merge branch 'v4' into UnitSystemSplit
tmilnthorp Oct 12, 2018
2d9e9c2
tmilnthorp Oct 12, 2018
e429c29
tmilnthorp Oct 12, 2018
53ba68d
tmilnthorp Oct 12, 2018
8dd5866
tmilnthorp Oct 12, 2018
b7523d2
tmilnthorp Oct 12, 2018
c2881b4
Merge pull request #511 from tmilnthorp/UnitSystemSplit
angularsen Oct 13, 2018
46ff4e8
UnitsNet: 4.0.0-alpha4
angularsen Oct 14, 2018
320263c
JsonNet: 4.0.0-alpha4
angularsen Oct 14, 2018
f914132
Ignore generated code except Length, Information, Level (#517)
angularsen Oct 14, 2018
74e54cf
Use instance of UnitAbbrevationsCache in test
angularsen Oct 13, 2018
be26999
Remove weird tests
angularsen Oct 13, 2018
632d6af
UnitParser: Minor cleanup
angularsen Oct 13, 2018
485d028
Merge branch 'v4-fix-tests' into v4
angularsen Oct 14, 2018
86b2efc
Stricter parsing (#516)
angularsen Oct 15, 2018
c5c6e51
Merge generator scripts for WRC and NetFramework (#520)
angularsen Oct 15, 2018
17acea8
tmilnthorp Oct 15, 2018
283c6b6
tmilnthorp Oct 15, 2018
a110555
tmilnthorp Oct 15, 2018
7cfca07
Remove internal parse methods (#521)
angularsen Oct 15, 2018
1c02a3d
Merge pull request #523 Replace GetHashCode implementation to match l…
angularsen Oct 15, 2018
f3c90ed
tmilnthorp Oct 16, 2018
21d8459
Fixing BaseUnits to not throw exception for undefined units. The Leng…
tmilnthorp Oct 16, 2018
0830706
Adding base/derived check to BaseDimensions
tmilnthorp Oct 16, 2018
8fe2088
Merge remote-tracking branch 'angularsen/v4' into SIUnitSystem
tmilnthorp Oct 16, 2018
812dcfb
tmilnthorp Oct 16, 2018
53aafef
tmilnthorp Oct 16, 2018
423ec39
Pruning generated tests
tmilnthorp Oct 16, 2018
5f625cb
tmilnthorp Oct 16, 2018
98fce99
Merge pull request #526 from tmilnthorp/PruneGeneratedTests
angularsen Oct 16, 2018
466f68a
tmilnthorp Oct 16, 2018
876f31f
Merge pull request #524 from tmilnthorp/SIUnitSystem
angularsen Oct 16, 2018
f1afdd8
Merge branch 'v4' into Dimensionless
tmilnthorp Oct 17, 2018
a187b58
tmilnthorp Oct 17, 2018
8ca0738
tmilnthorp Oct 17, 2018
b2c0097
tmilnthorp Oct 17, 2018
a3d0435
Cleaning up some unused code and adding ValueTuple support to make un…
tmilnthorp Oct 17, 2018
49026b2
tmilnthorp Oct 17, 2018
4f50c03
Merge pull request #528 from tmilnthorp/Dimensionless
angularsen Oct 17, 2018
355f82f
Merge pull request #529 from tmilnthorp/CodeCleanup
angularsen Oct 17, 2018
40a551e
tmilnthorp Oct 22, 2018
b27ab41
Merge pull request #531 from tmilnthorp/IQuantityTAdditions
angularsen Oct 23, 2018
799bfcc
Merge remote-tracking branch 'angularsen/master' into v4
tmilnthorp Oct 31, 2018
30363ce
Delete Vector2/3
angularsen Nov 2, 2018
9c43523
Merge remote-tracking branch 'angularsen/master' into v4
tmilnthorp Nov 2, 2018
a05a86e
Removing unit conversion from ToString methods. ToUnit must be called…
tmilnthorp Nov 3, 2018
875ca71
UnitsNet: 4.0.0-alpha5
angularsen Nov 4, 2018
b4e317d
Merge remote-tracking branch 'origin/master' into v4
angularsen Nov 4, 2018
619b524
Update test apps to work with v4 (#549)
angularsen Nov 4, 2018
f8b0b1a
Enable SourceLink and add back generated code (#548)
angularsen Nov 6, 2018
b958303
Sign all packages and remove .Signed packages (#539)
tmilnthorp Nov 6, 2018
2b4821b
Fix typo in header (#554)
angularsen Nov 6, 2018
f4d2551
Regenerate code
angularsen Nov 8, 2018
f752062
Adding equality methods/operators back (#558)
tmilnthorp Nov 8, 2018
5151ce1
Merge remote-tracking branch 'origin/master' into v4
angularsen Nov 8, 2018
03680d1
Regenerate code
angularsen Nov 8, 2018
b0361ba
Normalize Temperature arithmetic (#550)
angularsen Nov 8, 2018
9afd143
Delete UnitsNet.Common.props
angularsen Nov 8, 2018
6f67afb
Regenerate code
angularsen Nov 8, 2018
99a8a50
Fix build warning in JSON lib
angularsen Nov 8, 2018
84668fb
UnitsNet: 4.0.0-beta1
angularsen Nov 8, 2018
badd2ee
JsonNet: 4.0.0-beta1
angularsen Nov 8, 2018
2161082
Remove symbols nuget packages
angularsen Nov 8, 2018
c815ba9
Add back missing SourceLink
angularsen Nov 9, 2018
f777e28
Remove nunit binaries
angularsen Nov 9, 2018
721f165
Use wildcards in WRC project
angularsen Nov 9, 2018
6a81983
Move/rename testapps to Samples dir
angularsen Nov 9, 2018
80b518f
Remove unused solutions AllTargets and TestApps
angularsen Nov 9, 2018
37cad34
Fix nuget hint paths in sample apps
angularsen Nov 9, 2018
ed1420f
Remove old unused R# file
angularsen Nov 9, 2018
e6e3400
Set verbosity minimal for Samples build script
angularsen Nov 9, 2018
a1473d2
Regenerate certs for UWP apps
angularsen Nov 9, 2018
10b0b52
Fix solution configuration for UWP apps
angularsen Nov 9, 2018
f7c2011
Merge branch 'v4-move-testapps-to-samples' into v4
angularsen Nov 9, 2018
bda8300
Upgrade all to latest stable nugets
angularsen Nov 9, 2018
a9d94e7
Fix compile errors
angularsen Nov 9, 2018
08f0aee
Upgrade Console app from netcore1 to 2.1
angularsen Nov 9, 2018
88eb0be
Upgrade all to UnitsNet 4.0.0-beta1
angularsen Nov 9, 2018
89192da
Fix compile errors
angularsen Nov 9, 2018
885f724
Upgrade WpfMVVMSample to net471 and fix runtime exceptions
angularsen Nov 9, 2018
3c91775
Merge branch 'v4-upgrade-samples-nugets' into v4
angularsen Nov 9, 2018
b075ff3
Upgrade UnitConverter.Wpf to net471
angularsen Nov 9, 2018
e211e13
README: Update link to UnitConverter.Wpf
angularsen Nov 9, 2018
f28d009
Publish nugets on v4 branch instead of release/v4
angularsen Nov 11, 2018
71bc0a8
Revert "Normalize Temperature arithmetic (#550)"
angularsen Nov 16, 2018
0826b75
Merge remote-tracking branch 'origin/master' into v4
angularsen Nov 16, 2018
e5ccbcd
JsonNet: 4.0.0-beta2
angularsen Nov 16, 2018
23af7a9
UnitsNet: 4.0.0-beta2
angularsen Nov 16, 2018
831efcc
Improve clean script, add test script
angularsen Nov 16, 2018
85dea04
fixup! Merge remote-tracking branch 'origin/master' into v4
angularsen Nov 16, 2018
9b23a8e
appveyor: Do not publish symbols packages
angularsen Nov 16, 2018
db3caa9
Revert "Publish nugets on v4 branch instead of release/v4"
angularsen Nov 16, 2018
2555377
Merge branch 'master' into v4
angularsen Dec 10, 2018
ab6bd32
Fix negative FeetInches and StonePounds with negative values #574
tmilnthorp Dec 14, 2018
1e4eef0
Merge remote-tracking branch 'origin/master' into v4
angularsen Dec 16, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 2 additions & 20 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,9 @@
*.filters text eol=crlf
*.vcxitems text eol=crlf


#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

#*.xproj merge=binary
#*.props merge=binary
#*.filters merge=binary
#*.vcxitems merge=binary

# C#
*.cs diff=csharp
*.cs diff=csharp
*.g.cs linguist-generated

# Powershell
*.ps1 text eol=crlf
Expand Down
17 changes: 17 additions & 0 deletions Build/Test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$root = Resolve-Path $PSScriptRoot/..

[int]$exitCode = 0

# When this change is made available, we can possibly simplify below with: `dotnet test MySolution.sln`
# Run tests only for test projects by smadala · Pull Request #1745 · Microsoft/vstest
# https://github.com/Microsoft/vstest/pull/1745
Get-ChildItem -Path $root -Recurse -Filter "*Tests*.csproj" | % {
$projectFilePath = $_.FullName
$projectName = [IO.Path]::GetFileNameWithoutExtension($projectFilePath)
$reportFilePath = [IO.Path]::GetFullPath("$root/TestResults/$projectName.xml")
dotnet test $projectFilePath --logger "trx;LogFileName=$reportFilePath"
if ($LASTEXITCODE) { $exitCode = $LASTEXITCODE }
}

Write-Host -ForegroundColor Green "All tests run."
exit $exitCode
24 changes: 16 additions & 8 deletions Build/build-functions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ function Update-GeneratedCode {

function Start-Build([boolean] $skipUWP = $false) {
write-host -foreground blue "Start-Build...`n---"
dotnet build --configuration Release "$root\UnitsNet.sln"

$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.msbuild.log"

$appVeyorLoggerDll = "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
$appVeyorLoggerNetCoreDll = "C:\Program Files\AppVeyor\BuildAgent\dotnetcore\Appveyor.MSBuildLogger.dll"
$appVeyorLoggerArg = if (Test-Path "$appVeyorLoggerNetCoreDll") { "/logger:$appVeyorLoggerNetCoreDll" } else { "" }

dotnet build --configuration Release "$root\UnitsNet.sln" $fileLoggerArg $appVeyorLoggerArg
if ($lastexitcode -ne 0) { exit 1 }

if ($skipUWP -eq $true)
Expand All @@ -37,11 +44,14 @@ function Start-Build([boolean] $skipUWP = $false) {
}
else
{
$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.WindowsRuntimeComponent.msbuild.log"
$appVeyorLoggerArg = if (Test-Path "$appVeyorLoggerDll") { "/logger:$appVeyorLoggerDll" } else { "" }

# dontnet CLI does not support WindowsRuntimeComponent project type yet
# msbuild does not auto-restore nugets for this project type
write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using MSBuild15 instead"
& "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release /t:restore
& "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release
& "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release $fileLoggerArg $appVeyorLoggerArg
if ($lastexitcode -ne 0) { exit 1 }
}

Expand All @@ -56,7 +66,7 @@ function Start-Tests {
)

# Parent dir must exist before xunit tries to write files to it
new-item -type directory $testReportDir 1> $null
new-item -type directory -force $testReportDir 1> $null

write-host -foreground blue "Run tests...`n---"
foreach ($projectPath in $projectPaths) {
Expand All @@ -68,7 +78,7 @@ function Start-Tests {
# https://github.com/xunit/xunit/issues/1216
push-location $projectDir
# -nobuild <-- this gives an error, but might want to use this to avoid extra builds
dotnet xunit -configuration Release -framework netcoreapp1.1 -xml $reportFile -nobuild
dotnet xunit -configuration Release -framework netcoreapp2.0 -xml $reportFile -nobuild
if ($lastexitcode -ne 0) { exit 1 }
pop-location
}
Expand All @@ -79,9 +89,7 @@ function Start-Tests {
function Start-PackNugets {
$projectPaths = @(
"UnitsNet\UnitsNet.csproj",
"UnitsNet\UnitsNet.Signed.csproj",
"UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj",
"UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.Signed.csproj"
"UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj"
)

write-host -foreground blue "Pack nugets...`n---"
Expand All @@ -91,7 +99,7 @@ function Start-PackNugets {
}

write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using nuget.exe instead"
& $nuget pack "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" -Symbols
& $nuget pack "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"

write-host -foreground blue "Pack nugets...END`n"
}
Expand Down
4 changes: 0 additions & 4 deletions Build/clean.bat

This file was deleted.

31 changes: 25 additions & 6 deletions Build/clean.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
# Don't allow using undeclared variables
Set-Strictmode -version latest

$root = "$PSScriptRoot\.."
$artifactsDir = "$root\Artifacts"
if (test-path $artifactsDir) {
write-host -foreground blue "Delete Artifacts dir"
rm -r -fo $artifactsDir -ErrorAction Continue
Write-Host -Foreground Blue "Delete dirs: bin, obj"

[int]$deleteCount = 0
[array]$failedToDeleteDirs = @()
Get-ChildItem $root -Include bin,obj -Recurse -Force | %{
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $_.FullName
if ($?) { $deleteCount++ }
else {
$failedToDeleteDirs += $_
}
}
write-host -foreground blue "Delete dirs: bin, obj"
ls $root -inc bin,obj -r -fo | ri -r -fo -ErrorAction SilentlyContinue

Write-Host -Foreground Green "Deleted $deleteCount folders."

if ($failedToDeleteDirs) {
$failCount = $failedToDeleteDirs.Count
Write-Host ""
Write-Host -Foreground Red "Failed to delete $failCount dirs:"
$failedToDeleteDirs | %{
Write-Host -Foreground Red $_.FullName
}
exit /B 1
}
10 changes: 5 additions & 5 deletions Build/set-version-UnitsNet.Serialization.JsonNet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ Import-Module "$PSScriptRoot\set-version.psm1"

$root = Resolve-Path "$PSScriptRoot\.."
$paramSet = $PsCmdlet.ParameterSetName
$commonPropsFile = "$root\UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.Common.props"
$versionFiles = @($commonPropsFile)
$projFile = "$root\UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj"
$versionFiles = @($projFile)
$projectName = "JsonNet"

# Use UnitsNet.Common.props version as base if bumping major/minor/patch
$newVersion = Get-NewProjectVersion $commonPropsFile $paramSet $setVersion $bumpVersion
$newVersion = Get-NewProjectVersion $projFile $paramSet $setVersion $bumpVersion

Set-ProjectVersion $commonPropsFile $newVersion
Invoke-CommitAndTagVersion $projectName $versionFiles $newVersion
Set-ProjectVersion $projFile $newVersion
Invoke-CommitAndTagVersion $projectName $versionFiles $newVersion
8 changes: 4 additions & 4 deletions Build/set-version-UnitsNet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ Import-Module "$PSScriptRoot\set-version.psm1"

$root = Resolve-Path "$PSScriptRoot\.."
$paramSet = $PsCmdlet.ParameterSetName
$commonPropsFile = "$root\UnitsNet\UnitsNet.Common.props"
$projFile = "$root\UnitsNet\UnitsNet.csproj"
$winrtAssemblyInfoFile = "$root\UnitsNet\Properties\AssemblyInfo.WindowsRuntimeComponent.cs"
$winrtNuspecFile = "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec"
$versionFiles = @($commonPropsFile, $winrtAssemblyInfoFile, $winrtNuspecFile)
$versionFiles = @($projFile, $winrtAssemblyInfoFile, $winrtNuspecFile)
$projectName = "UnitsNet"

# Use UnitsNet.Common.props version as base if bumping major/minor/patch
$newVersion = Get-NewProjectVersion $commonPropsFile $paramSet $setVersion $bumpVersion
$newVersion = Get-NewProjectVersion $projFile $paramSet $setVersion $bumpVersion

Set-ProjectVersion $commonPropsFile $newVersion
Set-ProjectVersion $projFile $newVersion
Set-AssemblyInfoVersion $winrtAssemblyInfoFile $newVersion
Set-NuspecVersion $winrtNuspecFile $newVersion
Invoke-CommitAndTagVersion $projectName $versionFiles $newVersion
10 changes: 7 additions & 3 deletions Build/set-version.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ function Invoke-CommitAndTagVersion(
}

function Set-ProjectVersion([string] $file, [string] $version) {
Write-Host "$file -> $version"
$assemblyVersion = $version -replace "(\d+)(?:\.\d+)+.*", '$1.0.0.0'
Write-Host "$file -> $version (AssemblyVersion $assemblyVersion)"
(Get-Content $file) -replace '<Version>.*?</Version>', "<Version>$version</Version>" | Set-Content $file
(Get-Content $file) -replace '<AssemblyVersion>.*?</AssemblyVersion>', "<AssemblyVersion>$assemblyVersion</AssemblyVersion>" | Set-Content $file
}

function Set-AssemblyInfoVersion([string] $file, [string] $version) {
# Strip out any suffix: "4.0.0-alpha1" => "4.0.0"
$version = $version.Split('-')[0]
Write-Host "$file -> $version"
(Get-Content $file) -replace 'Assembly(File)?Version\(".*?"\)', "Assembly`$1Version(`"$version`")" | Set-Content $file
}
Expand Down Expand Up @@ -107,7 +111,7 @@ function BumpSuffix([string] $oldSuffix) {
# Example:
# -alpha => -alpha2
# -alpha1 => -alpha2
$match = [regex]::Match($oldSuffix, '^-(\w+)(\d+)?$');
$match = [regex]::Match($oldSuffix, '^-([a-zA-Z]+)(\d+)?$');
$oldSuffix = $match.Groups[1].Value
$numberGroup = $match.Groups[2]

Expand Down Expand Up @@ -150,4 +154,4 @@ function Resolve-Error ($ErrorRecord=$Error[0])
}
}

export-modulemember -function Get-NewProjectVersion, Set-ProjectVersion, Set-AssemblyInfoVersion, Invoke-CommitAndTagVersion, Set-NuspecVersion
export-modulemember -function Get-NewProjectVersion, Set-ProjectVersion, Set-AssemblyInfoVersion, Invoke-CommitAndTagVersion, Set-NuspecVersion
Loading