I'm using powershell to update the Version node in a wpf csproj file. Everytime I add the version node (never understood I have to when it's already there), suddenly a list of properties appear.
# My Wpf App
Write-Host "WpfApp Versioning started"
$sourceDir = "C:\Users\me\source\repos\mysolution"
$csprojfilename = $sourceDir +"\myapp\myapp.csproj"
"Project file to update " + $csprojfilename
[xml]$csprojcontents = Get-Content -Path $csprojfilename;
"Current version number is " + $csprojcontents.Project.PropertyGroup.Version + "."
$oldversionNumber = $csprojcontents.Project.PropertyGroup.Version
# https://gist.github.com/bcnzer/f8d50699c5bf7614923bff733662cb1a
if ($csprojcontents.Project.PropertyGroup.name -notmatch "Version")
{
Write-Host "Version is null."
$csprojcontents.Project.PropertyGroup.AppendChild($csprojcontents.ImportNode(([xml]"<Version/>").DocumentElement,$true))
}
Write-Host "Update Version."
$csprojcontents.SelectNodes("/Project/PropertyGroup/Version")[0].InnerText = [version]($ecatBuildNumber)
Write-Host "Save csproj."
$csprojcontents.Save($csprojfilename)
"Version number has been updated from " + $oldversionNumber + " to " + $ecatBuildNumber + "."
Write-Host "WpfApp Versioning Finished"
This is the output I get when using Powershell ISE.
WpfApp Versioning started
Project file to update C:\Users\me\source\repos\mysolution\myapp\myapp.csproj Current version number is 6.0.0.6 . Version is null.
Name : Version LocalName : Version NamespaceURI : Prefix : NodeType : Element ParentNode : PropertyGroup OwnerDocument : #document IsEmpty : True Attributes : {} HasAttributes : False SchemaInfo : System.Xml.XmlName InnerXml : InnerText : NextSibling
: PreviousSibling : Version Value : ChildNodes : {} FirstChild : LastChild : HasChildNodes : False IsReadOnly : False OuterXml : BaseURI
: PreviousText :Name : Version LocalName : Version NamespaceURI : Prefix : NodeType : Element ParentNode : PropertyGroup OwnerDocument : #document IsEmpty : True Attributes : {} HasAttributes : False SchemaInfo : System.Xml.XmlName InnerXml : InnerText : NextSibling
: PreviousSibling : Version Value : ChildNodes : {} FirstChild : LastChild : HasChildNodes : False IsReadOnly : False OuterXml : BaseURI
: PreviousText :Name : Version LocalName : Version NamespaceURI : Prefix : NodeType : Element ParentNode : PropertyGroup OwnerDocument : #document IsEmpty : True Attributes : {} HasAttributes : False SchemaInfo : System.Xml.XmlName InnerXml : InnerText : NextSibling
: PreviousSibling : Version Value : ChildNodes : {} FirstChild : LastChild : HasChildNodes : False IsReadOnly : False OuterXml : BaseURI
: PreviousText :Name : Version LocalName : Version NamespaceURI : Prefix : NodeType : Element ParentNode : PropertyGroup OwnerDocument : #document IsEmpty : True Attributes : {} HasAttributes : False SchemaInfo : System.Xml.XmlName InnerXml : InnerText : NextSibling
: PreviousSibling : Version Value : ChildNodes : {} FirstChild : LastChild : HasChildNodes : False IsReadOnly : False OuterXml : BaseURI
: PreviousText :Name : Version LocalName : Version NamespaceURI : Prefix : NodeType : Element ParentNode : PropertyGroup OwnerDocument : #document IsEmpty : True Attributes : {} HasAttributes : False SchemaInfo : System.Xml.XmlName InnerXml : InnerText : NextSibling
: PreviousSibling : Version Value : ChildNodes : {} FirstChild : LastChild : HasChildNodes : False IsReadOnly : False OuterXml : BaseURI
: PreviousText :Name : Version LocalName : Version NamespaceURI : Prefix : NodeType : Element ParentNode : PropertyGroup OwnerDocument : #document IsEmpty : True Attributes : {} HasAttributes : False SchemaInfo : System.Xml.XmlName InnerXml : InnerText : NextSibling
: PreviousSibling : Version Value : ChildNodes : {} FirstChild : LastChild : HasChildNodes : False IsReadOnly : False OuterXml : BaseURI
: PreviousText :Update Version. Save csproj. Version number has been updated from 6.0.0.6 to 6.0.0.6.
WpfApp Versioning Finished
It's strange. How do I get it to stop doing that?