I cannot convert a properly formatted string stored in a variable into a version type. The issue must be with the variable as it works fine if I provide the value manually but I don't know what could be wrong with it. I am new to PowerShell so I'm not sure where to look.
Here's my variable:
Write-Host "$env:BUILD_BUILDNUMBER"
1.0.0.20
Is it really a string? Yes:
($env:BUILD_BUILDNUMBER).GetType().fullname
System.String
Let's convert it into a version:
[version]($env:BUILD_BUILDNUMBER)
Cannot convert value "1.0.0.20" to type "System.Version". Error: "Input string was not in a correct format."
Works just fine when tried manually:
[version]("1.0.0.20")
Any idea what's wrong with my variable? I can't change it as it's provided to me as is.
Thanks!