title: Change BuildNumber using Powershell in Teamcity
body: <p>I am using Powershell script to change BuildNumber in Teamcity:</p>
  
  <pre><code>$projectFile = Resolve-Path ".\\source\\project\\project.csproj"
  $info = (Get-Content $projectFile)
  $matches = ([regex]'&lt;Version&gt;(\S*)&lt;/\Version&gt;).Matches($info)
  $newBuildNumber = $matches[0].Groups[1].Value
  Write-Host "##teamcity[buildNumber '${newBuildNumber}']"
  </code></pre>
  
  <p>The basic idea is to use the version number in C# net core project file as build number. When this script is run, I got the following error msg. </p>
  
  <pre><code>   Unexpected token 'newBuildNumber' in expression or statement.
     [09:11:44][Step 3/8] At 
     C:\TeamCity\buildAgent\temp\buildTmp\powershell4859822141650403163.ps1:5 cha
     [09:11:44][Step 3/8] r:54
     [09:11:44][Step 3/8] + Write-Host "
     [09:11:44][Step 3/8] "
     [09:11:44][Step 3/8]     + CategoryInfo          : ParserError: 
     (newBuildNumber:String) [], ParentC 
     [09:11:44][Step 3/8]    ontainsErrorRecordException
     [09:11:44][Step 3/8]     + FullyQualifiedErrorId : UnexpectedToken
  </code></pre>