How to Use Visual Studio 10 Web Deploy to Publish Your Application

I like to use Web Deploy because it is quick and easy if I am making multiple changes in development and testing. For example, I might want to test the speed of a page on my hosting server, something I can’t test by running it on my local machine. Web Deploy allows me to change a line of code, deploy it quickly, and test it.

So, how to do it? I spent quite a lot of time aimlessly trying options, but got it right in the end. Here’s what works for me.

First off, go to project properties, Package / Publish Web tab.

Choose “Only files needed to run this application”. If you don’t, your source code will be copied to the hosting server.
Before you go any further, take a backup of your web.config on your hosting server if it is different to your development file. It will be over-written by your development file in the Publish process (more on how to prevent this below).

Next, go Menu -> Build -> Publish MyProject (I use a keyboard shortcut: Ctrl Alt F9)
You’ll see the Publish Web dialogue box

Publish Method:                                        Web Deploy
Service URL:                                               HAZEL.arvixe.com (or your appropriate Arvixe server)
Site/application:                                       MyWebSite.com
Mark as IIS application:                         Unticked
Leave extra files on destination:         Ticked (don’t delete your web.config, see below)
Allow untrusted cert.                               Ticked
User name:                                                   MyWebSite.com_admin (see below)
Password:

To get your user name and password, go to the Arvixe Control Panel, Management tab in Web Site Properties
There you will see the username, and can set your password.

How to prevent your hosting server  web.config being over-written in the Publish process:

  1. Publish Web option “Leave extra files on destination (do not delete)”:      Ticked (see above)
  2. Look in directory C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications

Find the file Microsoft.WebApplication.targets

Edit it (admin rights needed, and of course copy a backup)
Find the line
<Import Project=”..\Web\Microsoft.Web.Publishing.targets” Condition=”Exists(‘..\Web\Microsoft.Web.Publishing.targets’)” />

After this line add these lines:

<ItemGroup>
<ExcludeFromPackageFiles Include=”web.config”>
<FromTarget>Project</FromTarget>
</ExcludeFromPackageFiles>
</ItemGroup>

Works for me. Comments and suggestions welcome.

Bryce

Tags: , , , , , , , , , , , | Posted under Web Deploy | RSS 2.0

8 Comments on How to Use Visual Studio 10 Web Deploy to Publish Your Application

  1. Thanks Bryce, just what I needed. The extra bit about the web.config was much appreciated too.

  2. Dave says:

    Hi,

    Do you know how to publish a LightSwitch application?

    I fill-in Service URL: TARES.arvixe.com

    I keep getting the following error:
    Error 12 Web deployment task failed.(Remote agent (URL https://tares.arvixe.com:8172/msdeploy.axd?site=tracking.shotcare.com.TARES.arvixe.com) could not be contacted. Make sure the remote agent service is installed and started on the target computer.)
    Make sure the site name, user name, and password are correct. If the issue is not resolved, please contact your local or server administrator.
    Error details:
    Remote agent (URL https://tares.arvixe.com:8172/msdeploy.axd?site=tracking.shotcare.com.TARES.arvixe.com) could not be contacted. Make sure the remote agent service is installed and started on the target computer.
    An unsupported response was received. The response header ‘MSDeploy.Response’ was ” but ‘v1′ was expected.
    The remote server returned an error: (401) Unauthorized. C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v1.0\Microsoft.LightSwitch.targets 962 10 Tracking

    Thanks for any help.

    Dave

  3. Bryce says:

    Are you using the user name and password specified in the Management tab of Control Panel?

  4. Archana says:

    I referred this article” How to Use Visual Studio 10 Web Deploy to Publish Your Application” and tried to publish asp.net WCf Service but getting an error “The “IsCleanMSDeployPackageNeeded” task failed unexpectedly.
    System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.Web.Deployment, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35′ or one of its dependencies. The system cannot find the file specified.”
    please help me. I am trying this since last 4 days

  5. Archana says:

    I installed Web deploy 2

  6. Bryce Abbott Bryce Abbott says:

    Sorry can’t help further, I would re-build

Leave a Reply

Your email address will not be published. Required fields are marked *


3 × = 18

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>