If you're developing in Visual Studio and not using WebDeploy, you're doing it wrong

One click publishing of your application is easier than ever

By  

Pushing code to a server - test, production, or otherwise - is an error prone hassle. Invariably you forget to update a connection string or push a DLL or include new image resources. True, lots of solutions exist for continuous integration, but they’re not always practical during development.

Back in 2009 when the Web Deployment Tool v1.0 was released, the process of configuring the IIS Server and hooking up your code for publishing was pretty tricky. There were a lot of steps and many people didn't think it was worth the time to configure when they could quickly copy up the source code to the server and just overwrite everything that was there. With subsequent releases, currently at Web Deploy v3.5, the process has become stupid easy.

By getting yourself hooked up with Web Deploy for your Visual Studio project, you gain the ability to publish your code to a server in a single click. Not only that, you can configure your deployment to transform the Web.config files during publish to target the environment you’re deploying to. Things like the debug flag can be automatically disabled. Connection strings can be transformed into the proper QA or PROD strings. Logging can be turned on and so forth. You’ll never forget, or better have to remember, to do these things again during deployments.

The other great part about Web Deploy is that is only publishes the stuff that has changed. It does this by doing a diff on the deployment location vs. your local files. You can preview what will be published, and if you like, selectively choose what will be deployed. It even supports the publishing of database changes, all the way up to entire databases being published.

Getting started is easy. If you’re running a modern IIS server with IIS 7 or above and the .NET Framework v4.0 or above, you can install Web Deploy via the Web Platform Installer program. If you haven’t used the platform installer before, you should get familiar with it. It’s a much needed dependency / package manager for Windows Servers. Once Web Deploy is installed you can configure it for your website.

To do so, simply right click your website node in IIS and choose Deploy -> Configure Web Deploy Publishing

On the configuration screen, the only item you should be concerned with (unless you know what you’re doing) is the first field which sets the user permissions for publishing. This can be set to the developer accounts which have permission to publish (you can perform this action multiple times for multiple users) or to an account created specifically for publishing.

Once you hit the Setup button, the work on the server is done. Next, switch over to Visual Studio and open up your Solution. Right click on the project you want to deploy and click Publish. Create a new publishing profile and name it whatever you want. On the connection tab, set the parameters like so:

The “Server” should be the domain of the server your deploying to.
The “Site Name” should match with the site name you defined in IIS.
The “User Name” and “Password” should be the user permissions account you set up on the server during the deployment configuration.
You can likely leave the “Destination Server” field empty.

With those elements filled out, click the validate connection button and hopefully you’ll score a green check mark letting you know you’re ready to deploy.

From here you can preview or publish your program to the server by clicking the Publish button.

The fun only starts there. By using different build configurations you can define Web.config transforms that will alter the application settings on the fly as you publish. You can read more about that process here: http://msdn.microsoft.com/en-us/library/dd465318(v=vs.100).aspx

If you’re still zipping up your project files and FTPing them to the server, you owe it to yourself you check out Web Deploy. It will save you time and stress and let you get back to the real task of coding a great application.

Photo Credit: 
Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Answers - Powered by ITworld

ITworld Answers helps you solve problems and share expertise. Ask a question or take a crack at answering the new questions below.

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question
randomness