title: Edit js file in postbuild event
body: <p>I have post build events set up already for copying files for me dependent on ConfigurationName and want to be able to set an "environment variable" in a config (js) file on client side of an angular application to allow debug info to be visible or not dependent upon environment running application in. </p>
  
  <p>To this end I've created a powershell script (ReplaceText.ps1):</p>
  
  <pre><code>function replace-file-content([String] $path, [String] $replace, [String] $replaceWith)
  {
  (Get-Content $path) | Foreach-Object {$_ -replace $replace,$replaceWith} | Out-File $path
  }
  </code></pre>
  
  <p>and added this line to the post build event of my web project.</p>
  
  <pre><code>if "$(ConfigurationName)"=="LIVE" (powershell -File "$(ProjectDir)Tools\ReplaceText.ps1" "$(ProjectDir)app\application.config.js" "DEBUG" "LIVE")
  </code></pre>
  
  <p>which I was hoping to change the word "DEBUG" to "LIVE" when built against LIVE build configuration in my application.config.js file which contains this line:</p>
  
  <pre><code>$provide.constant('currentEnv', 'DEBUG');
  </code></pre>
  
  <p>Build succeeds but no changes occur on my file. Can anyone identify where I'm going wrong?</p>
  
  <p>I do know I could do this sort of stuff with Gulp or another task runner BTW, but was trying to do it without bringing in another dependency and just use VS post build events &amp; PS. :)</p>
  
  <p>Cheers</p>