Less maintenance. Less work to package during your automated builds. Too easy.
Remember Our Old Friend _PublishedWebsites?
You’ve probably seen the _PublishedWebsites folder when building websites in automated builds. If not you can stop paying attention now.
Still with me? Great! So you know how it packages up everything nicely with content files going where they should with nearly ZERO cost to your build scripts. All you need to do is override the output directory (OutDir) and you get this feature. This behavior is arguably one of the best things that web projects do during automated builds.
So how many of you, like me, just accepted the fact that this was just for web, and not other applications, and went on maintaining your build scripts to package up your other application types? Yeah, me too. Painful…and we looked at complicated ways of solving this problem. There has to be a better way.
Recently David Keaveny came up with an idea to take the Microsoft.Web.targets file (which produces the _PublishedWebsites folder – it is imported by the csproj/vbproj file), change up a couple of variables and rename it to the Microsoft.Application.targets file. When I saw this I thought this was an awesome idea! How come I didn’t think of that? Why didn’t anyone else see the simple solution?
The concept is simple – You add the .targets file to your application. Then you edit the csproj/vbproj file by hand to add in the import for the .targets file.
And you get a nice folder with your application bits nicely packaged for you.
Note: The _PublishedApplications folder ONLY shows up when you override the output directory during an automated build or command line access to building a solution. The rest of the time your builds go to their normal folders (i.e. bin\Debug).
PublishedApplications Is On NuGet
I loved this idea so much I did the work to figure out how to automate the imports part of the idea so it was a simple command to use Microsoft.Application.targets. And this is on NuGet: http://nuget.org/list/packages/publishedapplications
Want A Demonstration?
Why talk when we can just look at a short video that demonstrates this idea?
Special thanks to David Keaveny for this great idea!
03-22-2011 9:23 PM