MSBuild Deploy Integration

Here's an MSBuild target to notify Rollbar of a publish. Requires RollbarSharp web.config entries, and git on your PATH.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="NotifyRollbarOfDeploy" AfterTargets="MSDeployPublish">
    <XmlPeek XmlInputPath="$(_PackageTempDir)\web.config"
             Query="//appSettings/add[@key='Rollbar.AccessToken']/@value">
      <Output TaskParameter="Result" ItemName="RollbarAccessToken" />
    </XmlPeek>
    <XmlPeek XmlInputPath="$(_PackageTempDir)\web.config"
             Query="//appSettings/add[@key='Rollbar.Environment']/@value">
      <Output TaskParameter="Result" ItemName="RollbarEnvironment" />
    </XmlPeek>
    <Exec Command="git log -1 --format=%%H" ConsoleToMSBuild="true" EchoOff="true" WorkingDirectory="$(ProjectDir)\..">
      <Output TaskParameter="ConsoleOutput" PropertyName="GitSHA" />
    </Exec>
    <Exec Command="git config user.email" ConsoleToMSBuild="true" EchoOff="true" WorkingDirectory="$(ProjectDir)\..">
      <Output TaskParameter="ConsoleOutput" PropertyName="GitEmail" />
    </Exec>

    <Message Text="Rollbar.AccessToken: @(RollbarAccessToken)" Importance="Normal" />
    <Message Text="Rollbar.Environment: @(RollbarEnvironment)" Importance="Normal" />
    <Message Text="Git SHA: $(GitSHA)" Importance="Normal" />
    <Message Text="Rollbar: $(GitEmail) deployed @(RollbarEnvironment) revision $(GitSHA)" Importance="High" />
    <Exec Command="@powershell -NoProfile -ExecutionPolicy unrestricted -Command &quot;(new-object net.webclient).UploadString('https://api.rollbar.com/api/1/deploy/', 'access_token=@(RollbarAccessToken)&amp;environment=@(RollbarEnvironment)&amp;revision=$(GitSHA)&amp;local_username=$(GitEmail)')&quot;" EchoOff="true" />
  </Target>
</Project>

Thanks to @barake for putting this together originally as a gist.