title: How can I get with PowerShell the project version in Visual Studio?
body: <p>I'm writing a simple <code>PowerShell</code> script for creating <code>NuGet</code> packages on <code>Post-build</code> event. For this I'd like to set the package version automatically to the project version. Currently it's hardcoded in my command:</p>
  
  <pre><code>nuget pack .\MyProject.csproj -properties configuration=release -version 1.0.0 -outputdirectory .\NuGet\Packages
  </code></pre>
  
  <p>Is there a way to change the above command to something like this (pseudo code):</p>
  
  <pre><code>var currentVersion = Get-ProjectVersion();
  nuget pack .\MyProject.csproj -properties configuration=release -version $currentVersion$ -outputdirectory .\NuGet\Packages
  </code></pre>
  
  <p>and then push the package with the same version to the <code>NuGet</code> server?</p>
  
  <pre><code>nuget push .\MyProject.$currentVersion$.nupkg -configfile .\NuGet.config
  </code></pre>