Taking Visual Studio build and publish events to the next level

2017: Why is this post so popular? It’s always one of the highest viewed posts on my site and I’ve never understood why. When you’re done reading, please leave a comment letting me know.

I just integrated Visual Studio’s web project publish command with Zapier  so I can send build events to Slack.

That’s a twofer, folks. I just killed two birds with one really awesome stone.

Seriously, the possibilities here will blow your mind, especially given how easy it is to make it happen.

First, I’ll explain how I hooked into the publish event. If you’re more interested in the Zapier part, feel free to skip to the next section.

The web project publish event

Hooking into the Visual Studio 2013 web project publish event isn’t the most obvious thing in the world. In fact, I couldn’t easily find anything on the bings to show me how to do it.

Just to clarify, by “Visual Studio 2013 web project publish event”, this does not have anything to do with a ClickOnce publish. What  I mean is that I want to perform some special upon completion of the process that executes whenever you right-click on a web project and select “Publish…”. I.E….

To achieve the desired outcome is simple once you know what to do. Just place this somewhere near the bottom of your .csproj file (inside <project></project>):

$(DestinationAppRoot)  is the name of the publish profile you selected. That’ll come in handy in the second part of this post.

Publish and build events with Zapier

This part was mind-numbingly easy.

If you’re not familiar with Zapier, it’s a service that “connects the web apps you use to easily move your data and automate tedious tasks….. Connect the apps you use to easily move data between them.” 300+ apps at the time of this writing, by the way. It’s similar to IFTTT except more business oriented in my opinion.

You can’t appreciate how awesome this is until you learn more about Zapier. Please, if you really haven’t heard of Zapier, take time to go look at the Zapier site now and come back when you’re super excited.

In my case, I want to send a Visual Studio publish event to Zapier so I can forward it to Slack.

To do this, we’re going combine the publish event instructions above with Zapier’s ability to catch webhooks.

All you need is curl (easily installed with Chocolatey here) and a Zapier account.

I’m not going to go into all of the details of setting up a webhook event in Zapier… The Zapier website makes that very easy.

Instead, I’ll show you the magic…

And here’s the magic…

Here’s how I’ve configured Zapier to send the “Action” parameter above to Slack:

And it works…

As you can imagine, this Zapier integration via curl could really be done anywhere in Visual Studio, including before/after build events, for example.

just made this work in Visual Studio and I’m super pumped about the possibilities! I could literally have my publish events flash the lights in my house via Homeseer…