title: PowerShell - Get Version from .csproj file
body: <p>I'm learning PowerShell. Right now, I'm trying to get the <code>Version</code> element value from a .csproj file. The .csproj file's XML looks like this:</p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk"&gt;
  
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;netcoreapp2.1&lt;/TargetFramework&gt;
      &lt;Version&gt;1.2.3&lt;/Version&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="MyLibrary" Version="3.2.1" /&gt;
    &lt;/ItemGroup&gt;
  
  &lt;/Project&gt;
  </code></pre>
  
  <p>In an attempt to get the <code>Version</code> element value from this XML, I've written the following PowerShell script:</p>
  
  <pre><code>$xml = [xml](Get-Content ./MyApp.csproj)
  
  Write-Host "xml: " $xml
  
  $version = $xml.Project.PropertyGroup.Version
  
  Write-Host "version: $version"
  </code></pre>
  
  <p>When I run this script, I see the following:</p>
  
  <pre><code>xml:
  
  version:
  </code></pre>
  
  <p>Notice that neither the project XML, nor the version gets written. At first, I thought I was referencing the .csproj incorrectly. I intentionally removed the "j" at the end and an error was thrown. For that reason, I'm assuming that I'm properly loading the .csproj content. However, I believe I'm not parsing the XML properly in my PowerShell script. </p>
  
  <p>How do I get the <code>Version</code> from the .csproj value in the PowerShell script?</p>