Sunday, May 31, 2009

Web 1-Click Publish with VS 2010

Visual Studio 2010 has great features to make your web deployment easier…   I have written a high level article describing the web deployment feature set of VS 2010 below:

Today my goal is to go through an end to end walkthrough of the Web 1-Click  Publish feature of VS 2010…  This walkthrough will cover following:

  • Prepping up an ASP.NET 4.0 web application which is using a SQL Server Database for deployment
  • Gathering the remote web and database server information
  • Setting up Web.config Transformation to change your connectionString
  • Including SQL Server Databases in Web Deployment
  • Creating a 1-Click Publish Profile to Publish your web content, databases and transformed web.config files
  • 1-Click Publish your Web Application

For this walkthrough you will need Visual Studio 2010 Beta1 which you can download FOR FREE from http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx

Let us get started…

Prepping up an ASP.NET 4.0 web application which is using a SQL Server Database for deployment

In this walkthrough we are assuming that you already have a web application which uses SQL Server database and you are ready to deploy it to remote web server and database server…  If you do not have such a web application then I encourage you to follow the simple step by step instructions in the walkthrough Creating a simple .NET 4.0 web application using Visual Studio 2010

With the assumption that you now have a data driven ASP.NET 4.0 web application let us try to understand what all is needed to be taken care of while deploying such a web application… Things that you need to take care of during such typical deployments are:

  1. You need to modify the connectionStrings in the web.config file to point to the remote SQL database server instead of the local SQL Server Express that you are using on your dev box…
  2. You need to deploy your databases to the remote SQL database server
  3. You need to deploy all of your master pages, content pages, images etc to the remote web server

In the remaining portion of this walkthrough you will see how to accomplish all of the above things…

But before getting to that, let me introduce you to Web Application we are about to deploy… The solution explorer of this web application looks as below:

1-ClickPublish solution explorer

Notice that this web application has 1-ClickPublish.mdf file in the App_Data folder…  Also notice that it has a Site.Master, Default.aspx and Address.aspx Web pages…  When you run Default.aspx it looks as below:

Default.aspx

The top banner of “Visual Studio 2010 Web 1-Click Publish” is coming from Site.Master…  The grid containing FirstNames & LastNames is being populated from the 1-ClickPublish.mdf file…  The “View Addresses” button takes you to “Address.aspx” page which shows the addresses of the people on “Default.aspx” as shown below:

Address.aspx

The web.config file of this web contains connectionString named “1-ClickPublishDB” which points to the SQL Server express database (1-ClickPublish.mdf )…

Gathering the remote web and database server information

Before we begin to deploy the web application to the remote server we will need to gather the information of the destination servers… Typically if you are going to a shared hoster then this information is provided to you in the welcome email from your web hosting company…  Web hosters typically have various plans which include database as well as web server storage space….

If you are not planning to go to web hosting company but rather are interested in hosting your own web and database servers then you will have to follow some more additional steps to set up your web servers and database servers…  I am not covering this in the current walkthrough but will cover the same in subsequent walkthroughs…  But for now let us assume you have a web hoster who has provided you with the information required for deployment…

Typically web hosters will ask you which .NET Framework version you would like to target (i.e. 2.0, 3.0, 3.5 or 4.0)… Based on the .NET Fraemwork version you choose your web site will be provisioned with the correct Application Pool… For .NET 2.0, 3.0 and 3.5 the Application Pool targets CLR version 2.0… For .NET 4.0 the Application Pool is set to CLR version 4.0…. It is very likely that your .NET 2.0, 3.0 or 3.5 web application will run seamlessly on .NET 4.0 but it is still required to talk to your hoster to change you Application pool from .NET 2.0 to .NET 4.0… 

If you register for a hosting plan which supports the new VS 2010, ASP.NET 4.0 and Microsoft Web Deployment Tool (MsDeploy) then you will receive below pieces of important information which we will use later during the walkthrough… In the rest of the walkthrough I will refer to these as “1-Click Settings” so that you can easily relate to this section…:-)

  • Service URL:  This URL is in the format https://myWebServer:8172/MsDeploy.axd and actually points to a IIS handler which will manage your deployment on the remote web server
  • Site/Application Name: This is the name of your IIS Web Site on the remote web server…  This is where your application will be deployed…
  • UserName: This user name is the account which has the access to the ServiceURL and your Site on the remote web server
  • Password:  The password which you use for your above UserName
  • ConnectionString: This is the ConnectionString to your remote database server… Typically your hoster will make sure that your remote web server and remote database server have the correct ports opened so that your web application can easily consume the data from your database…

At this time I am assuming that you have your web application ready to be deployed and you already have the above pieces of information from your web hoster…  The next thing we will do now is to set up web.config transformation to modify your web.config file during deployment….

Setting up Web.config Transformation to change your connectionString

Let us assume that you are using “Release” build configuration when you are deploying to a remote web server…  You can create and use a different build configuration as well but I am choosing “Release” as it comes out of the box with VS 2010…  Learn more about Managing Build Configurations… 

By default “Debug”  is the ‘Active’ build configuration… As we are ready to deploy to a hoster you can change your Active build configuration to “Release”… You can do so by simply changing the drop down value on the VS “Standard” toolbar as shown below:

build configuration

Alternatively you can also change the build configuration by going to the Build –> Configuration Manager menu…

After this step your Active Build Configuration should be “Release”…  You can now open up the node next to the web.config file to reveal web.debug.config and web.release.config as shown below:

web.release.config

In case of VB.NET you will have to click the top right button to “Show all files” to see the dependent web.release.config…

Now open the web.config as well as web.release.config files and copy the connectionString section from the web.config file into the web.release.config file as shown below…

FROM

web.config connection string

TO

web.config with connection string

Now you need to do two quick things

  1. Just simply write xdt:Transform=”Replace” in the connectionString node of web.release.config as shown below…
  2. Also change the connectionString attribute by putting the value that you got from the hoster (the one we referenced in “1-Click Settings” )… Let us say my hoster proived me with connectionString as “Data Source=myHostedSQLServer;Initial Catalog=myhostedDBName; User ID=VishalRJoshi; Password=*VS10Rocks” then my web.release.config should look as below…

final web.release.config

Also note that by default Web.Release.config has a transform called “RemoveAttributes” to remove the debug attribute when you are going to the “Release” environment…  Many hosted environment will not allow you to have debug=true coz it is not safe hence removing the debug attribute is required…

With this you have set up the automated web.config transformation which will take care of changing your connection string during every deployment… !! There is a lot more you can do with XML Document Transforms (XDT)…  Check out the different possibilities Web.Config Transformations by leveraging XDT here…

Including SQL Server Databases in Web Deployment

As the current web application is actually using the data in 1-ClickPublish.mdf it is required to move the database schema and data from this local SQL Server Express database to remote hosted SQL Server database server… In order to make that happen you need to go to “Deploy SQL” tab of the Project properties…

You can open project properties by double clicking the “Properties” item under the project node as shown below:

image_thumb10[2]

When project properties window opens then navigate to “Deploy SQL” tab…Once you open “Deploy SQL” tab you need to do following quick things:

Make sure you are using the “Release” configuration as that is the configuration we are going to deploy (and you also have web.config transformation for Web.Release.config)…

Click “Add” button and give a friendly name for your database deployment as shown below: (I would recommend using the name that you used for your connectionString – for secret reasons I will talk about in future posts :-))

Add new connectionString

Next you will have to configure the “1-ClickPublishDB” settings which you just created by clicking it…  As soon as you click it the disabled section below will light up which you need to fill in as shown below…

Deploy SQL tab

The key points to note while filling up the DB Deployment information above are:

  • ConnectionString for the destination database is the connectionString which you received from hoster in an email (the one we referenced in “1-Click Settings” )…
  • “Pull data from an existing database” will instruct Visual Studio 2010 to extract data from the local SQL Server…
  • The connection string below the “Pull data from…” checkbox represents the source database (which is on your local dev box)… This connection string can be found in the original web.config file of your web application as the datasource controls you used insert the connectionString in web.config file…
  • The “Complete database” radio button instructs Visual Studio 2010 to script both database schema as well as data from your database…  If you contain junk data that you do not want to deploy to the server then choose “Shema only” option…

With these settings you can now hit save on top of Visual Studio and you have configured your database for deployment as well…Hopefully that was not too hard :-)  If your needs are more deeper than the above then there are many other powerful Database Deployment options which I have discussed in DB Deployment post earlier

Creating a 1-Click Publish Profile to Publish your web content, databases and transformed web.config files

Now that you have set up web.config transformation and also set up you database deployment settings, it is time to create a 1-Click Publish profile to use for your deployment…

You can do so by Right clicking on your project node and hitting “Publish…” as shown below:

Right Click Publish

With that you will get the “Publish Web” dialog which you can fill as below:

Publish Dialog

I have specially numbered the fields above so that you can easily relate to them in the text below:

  1. Publish Profile Name-  I have named it as myWebHosterName you can name it with the destination name that you can easily remember…  Usually if you are going to a web hoster then naming this as something like “DiscountAsp” or “OrcsWeb” would be advisable…
  2. Service URL:  As we discussed in the “1-Click Settings” section at the beginning of the post, this is provided to you by your hoster…  This URL associated with the Publish Method “MsDeploy” which is used behind the scenes by Visual Studio 2010 to Publish your entire web… You can learn more about the way MsDeploy works in one of my previous blog posts…  Also while you are at it note that the new “Publish” dialog also tells you the Build Configuration that you are publishing (i.e. the Active Build Configuration), in our situation we are using the “Release” configuration for which we have set up the DB Deployment and Web.config transformation…
  3. Site/Application Name: As we discussed in the “1-Click Settings” section at the beginning of the post, this is also provided to you by your hoster…  If your hoster provided VishalRJoshi.com as your Site name you can feel free to append a folder name underneath it e.g. VishalRJoshi.com/Blog…
  4. Mark Folder as IIS Application on destination: If you choose to Publish to a folder under the parent site eg “VishalRJoshi.com/Blog” AND  want to have separate session state, cache etc functionality for that subfolder then you will have to convert that folder into an IIS Application underneath your parent web site…  This checkbox will allow you to achieve that easily in an hosted environment… This is a the additional IIS enhancement that was made as part of “MsDeploy” Publish Method, so we hope you will like it…:-)
  5. Allow untrusted certificates-  MsDeploy Publish method will only take https:// URLs… As you know that secure http requires a SSL certificate but it is understood that it will not be possible to always buy a certificate from authorities like VeriSign etc and especially if you are deploying within your team environment then expecting a fully signed certificate may not be rational, hence this option allows the web server owner to provide a self signed SSL certificate… Although, in general it should be understood that checking this box increases threat on the data which is being transferred over the wire…
  6. User Name, Password and Save Password:  Again, As we discussed in the “1-Click Settings” section at the beginning of the post, User Name and Password is also provided to you by your hoster…  “Save Password” is a feature in VS 10 which will securely save your password, so that you do not have to keep typing it again and again…
  7. Save -  Now you can hit the Save button on the top, to save the “Publish Profile” you just created…
  8. Close – Close button will allow you to close the “Publish Web” dialog

After doing all of the above you have configured your Web Application for 1-Click Publish going forward…

1-Click Publish your Web Application

For your convenience Visual Studio 2010 offers Web 1- Click Publish toolbar as shown below:

image

You can enable this toolbar (if not visible) by going to View—>Toolbars—> Web One Click Publish… You can now simply click the Publish button below after every little change you make to your project that you want to deploy… 

image

This way you can keep updating your web at the destination with ease…  Do note that you are allowed to have upto 50 Publish profiles per project, which can allow you to Publish the same project to 50 different web servers in just clicks (I hope 50 should be enough, if not let us know now and we will be happy to bump that up :-))…

NOTE:  If you are incrementally publishing you web then you should go to “Deploy SQL” tab and uncheck your database deployment… If you do not do so then your Publishing will fail as MsDeploy intentionally does not overwrite the database that you already have on the server…  There is a easy fix to change that behavior i.e. there is an option to delete database every time you republish, but I will refrain from mentioning it until someone asks as that is purely a Test server scenario… :-)

Checking your deployed Web

With all of the above steps you are good to hit the “PUBLISH” button…  Once you hit the button your web should get deployed to the hoster much more quickly and reliably than ever before…

With all this you are now set up to have 1-Click Publish of your web application from Visual Studio 2010…

In later posts I will share the Performance and Scalability numbers of MsDeploy Publish method too but as far as I can tell MsDeploy publish is quite more reliable and performant than most other traditional web publishing mechanisms…

I hope this walkthrough will help you experience the new powers of Visual Studio 2010 and Microsoft Web Deployment Tool…

If you would like to learn more about Web Deployment with VS 2010, then I have explained a bunch of other features in the posts below:

Hope this walkthrough is helpful

-Vishal

Some KB Items:  There are certain known issues and workarounds which you may or may not encounter but I have still posted them here in case you face any of those… Known Issues, Resolutions and Work-Arounds for VS 10 Web 1-Click Publish

74 comments:

Anonymous said...

Catch this on twitter at #1clickpublish

Anonymous said...

Very useful, thanks for posting

Anonymous said...

Do you know if you can assign a hotkey to the 1-Click Publish? That would make things even easier... :)

Vishal R Joshi said...

I agree my friend that will actually Rock if I could say Ctrl + P equal to publish the current profile... I believe Ming had good reason why that was not doable, will let him respond...
-Vishal

Anonymous said...

Ctrl-P is standard for File.Print command.
We coule fix this on the later drop. But short cut command is getting very hard to define in various profile.
For now, what you can do is
1. Open Tool->Options
2. Go to Environment->Keyboard
3. Map a command "Build.PublishSelection" to a key stroke you prefer (I tried Ctrl+' in the Global)

It will out pop the publish windown that you used to create the WAP publish profile.
It is not exactly what you want, but *almost* there. We will address the issue in the Beta2 or later.
-Ming

Anonymous said...

I am getting an error ..

VsMsdeploy failed. (The client and server are not compatible. The most recent version supported by the client is '7.1.438.0'. The earliest version supported by the server is '7.1.600.0'.)

Can someone help pls?
-Thanks
Parahsar

Vishal R Joshi said...

Hi Parahsar,
The above error happens when the version of MSDEploy on the server is not compatible with the version of MSDEploy that comes with Visual Studio... Could you clarify which deployment server are you going to? (i.e. Discount ASP, OrcsWeb??)
Thanks
Vishal

r4 dsi said...

Thanx for the information. I hate my project guide. they force us to use VS05 even when VS2010 is available....and they still expect us to make newer projects. I mean how can your product work unless you have latest tools used in it.

Imran Baloch said...

@vishal "If you are not planning to go to web hosting company but rather are interested in hosting your own web and database servers then you will have to follow some more additional steps to set up your web servers and database servers… I am not covering this in the current walkthrough but will cover the same in subsequent walkthroughs"

Imran says

Is this walkthrough available?

Unknown said...

Hi Vishal, Thanks for this wonderful walk-through. Unfortunately I am getting the same error for VsMsdeploy failed. just one comment above yours. I am currently using VS 2010beta1 Professional with OCRSWeb for deployment.
Please advise if I need beta 2 to eliminate the error.

Akash Kava said...

Hi Vishal,

Thanks for great post, what happens when we publish next time? Does it only publish changed items? Does it publish one by one or collects all items, compresses and uploads?

Thank you,
- Akash Kava

Unknown said...

Hi,

I was successful trying msdeploy using vs2010 beta 1 but when I use beta 2 I got the following error. Hope you could help. Thanks.


Error 1 VsMsdeploy failed.(Remote agent (URL https://shared18.orcsweb.com:8172/msdeploy.axd?site=Edgardo_Mariano.orcsweb) could not be contacted. Make sure the remote agent service is installed and started on the target computer.)
Error detail:
Remote agent (URL https://shared18.orcsweb.com:8172/msdeploy.axd?site=Edgardo_Mariano.orcsweb) 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. 0 0 PMS

Lee Dumond said...

Hi,

You say in this post that "There is a easy fix to change that behavior i.e. there is an option to delete database every time you republish"...

Well, I'm asking how to do this. I really need to be able to easily reset the db to an initial state upon every publish for testing purposes.

Thanks!

Anonymous said...

Make sure you're running Beta 2, not Beta 1 of VSTS.

ewart said...

I just can not make 1-click work with beta2, onto a server I have full control over. I get an error:

VsMsdeploy failed.(Could not complete the request to remote agent URL 'https://xxxxx.com:8991/yyyy/msdeploy.axd?site=www.zzz.com'.)
Error detail:
Could not complete the request to remote agent URL 'https://xxxxx.com:8991/yyyy/msdeploy.axd?site=www.zzz.com'.
The underlying connection was closed: An unexpected error occurred on a send. The handshake failed due to an unexpected packet format.

I did a custom install of the Web Deployment tool on the server and specified my own port 8991 and my own subdirectory. I notice however under the IIS/Management Service "enable remote connections" screen my port is set to 8172. Are these supposed to be the same? I assumed not but tried to make it the same as a test and can't adjust it in that screen to 8991 anyway, as it says that that port/ip config is in use (even with the deployment agent service stopped)

if I browse to the service url externally I get a popup asking for windows credentials, so I know it's connecting. it seems this is something to do with https?? any pointers apreciated I'm about to give up - ewart@ihug.co.nz

ps in verbose mode heres the last few lines from the stack trace after it fails to deploy:
at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponse(HttpWebRequest request)
at Microsoft.Web.Deployment.AgentClientProvider.CreateStatusThread(DeploymentSyncContext syncContext)
at Microsoft.Web.Deployment.AgentClientProvider.RemoteDestSync(DeploymentObject sourceObject, DeploymentSyncContext syncContext)
at Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable)

Alan said...

Vishal, i have been taking a look at your blog and research over the internet for the past 3 days and couldnt find anything related to the problem im having :(. Let me know if you have time to give me a hand on this.
Im working under team fundation server and visual studio 2010 beta 2. i have created a web site (not web application) and some tests that tests that web site. the problem on commiting as you may realize already is that the tests fails because the web site is not deployed yet. I have tried to customize the xaml file build definition without any luck. tryied to add a msbuild activity.. again without any luck for lack of knowledge.
Please, let me know if you can give me info on how to do aproach this problem of post some tutorial, etc. (since there is not so much info about it).

Bests,
Alan. (alan_k2@hotmail.com)

Pat Marchand said...

I note you provide a link to twitter in: http://blogs.msdn.com/webdevtools/archive/2009/06/01/free-web-hosting-to-try-asp-net-4-beta1-vs-2010-beta1-and-ms-web-deployment-tool-rc1.aspx
but twitter does not know it!

Apart from getting a free dummy hosting until October, are there any hosting companies who can host this new version as I would like to rewrite my store in version 10 now!

Anders Vindberg said...

Any idea when this will be possible on IIS 6.0? Maybe with the latest RC? I have read it wasn't made available in Beta 2.

Thanks for a great post otherwise.

Anonymous said...

I am looking for info on how to configure this on IIS. I have installed the WEb Deployment tool using the platform installer. Now what? Where do you go to configure the port and security settings?

Anonymous said...

Hi vishal, I need your help. I am not able to see Publish web option. my machine is installed with MS VS2008 SP1. I don't know why it is not showing Publish Option in project properties. Could you please help if you can?

I am also not sure whether it was available on VS 2008 with SP1 or not

Thanks in advance.

Anders Vindberg said...

Hi Vishal, great post. Do you know if 1-click publish is supported by IIS 6.0? I haven't been able to find any guides on how to setup iis 6.0 to support 1-click publish.

Hope to hear from you!
Thanks.
Anders

Anonymous said...

Hello Vishal,

I have a VS 2010 MVC project and I have deployed it on the ftp server. Now I am making changes to c# code files and replacing the files on the server with updated ones. But, nothing is being reflected on the server. How do I enable the auto compilation for the site?? I mean whenever we make any changes to any file, the site gets recompiled, as in older versions of .NEt peojects.

Vishal R Joshi said...

Hey Lee check out the post at http://vishaljoshi.blogspot.com/2009/08/replacing-your-old-db-with-new-one.html

Vishal R Joshi said...

Hi Anders,
Yes IIS6 can also support one click publish, you will have to set up remote agent for that...
Please follow the below steps for completing the remote agent install

1. Download the Web Deploy from http://www.iis.net/. (It actually comes installed with VS 2010 but you may not have it on the server)
2. Run the MSI file to install the tool.
3. Select a Custom installation to choose what to install.
4. Click on the remote service node to install the remote service.
5. Complete the installation.
6. Manually start the service by running the following command:
net start msdepsvc
7. Ensure that port 80 is open in the firewall.
Hope this helps...
-Vishal

Vishal R Joshi said...

r4dsi,
Did you ever get to move to VS 2010... Do note that VWD Express 2010 is completely free and has most of these features already...
thanks
Vishal

Vishal R Joshi said...

Imran Baloch,
Plz check the latest comment on Remote agent service installation... that is what you need to do to install local IIS Server for publishing...
thanks
Vishal

Vishal R Joshi said...

Hi Akash,
The next time you publish only the differences get pushed to the server so that the entire site does not need to be repushed to the server...
Thanks
Vishal

Anders said...

Thanks Vishal, I forgot to mention I've been using it since the final release of VS2010/.Net 4.0, its brilliant!
Best, Anders

Vishal R Joshi said...

Thanks Anders, It is great to hear.. Keep me posted if you face any issues...
-Vishal

Vishal R Joshi said...

Hi Pat Marchand,
I know that DiscountASP, MaximumASP and OrcsWeb support the released version of Web Deploy publishing already... I do not know how many more hosting providers already do but I am sure there are many more...
Thanks
Vishal

Vishal R Joshi said...

>>>I am not able to see Publish web option. my machine is installed with MS VS2008 SP1

The above feature set is only available with VS 2010 so unfortunately it is not there in VS 2008 SP1... :-(

Vishal R Joshi said...

>>>I have a VS 2010 MVC project and I have deployed it on the ftp server. Now I am making changes to c# code files and replacing the files on the server with updated ones. But, nothing is being reflected on the server. How do I enable the auto compilation for the site?? I mean whenever we make any changes to any file, the site gets recompiled, as in older versions of .NEt peojects.

Vishal: In case of Web Application Projects the C# files are not compiled on the server, they are compiled when you publish your project.. This helps your app to run faster on the server... Can you confirm that you have followed the steps above for publishing...
Thanks
Vishal

r4ds said...

Hi Vishal,

Great post. Do you know if 1-click publish is supported by IIS 6.0?

Vishal R Joshi said...

Yes 1-click Publish is supported on IIS6... In that situation you would have to install Web Deploy Remote agent on the server...

Thx
Vishal

r4 ds said...

Thanks Vishal! Appreciate the super quick response!

Anonymous said...

Hello Vishal!
I use this method for publish but I can't understand
how can I stop IIS before start publish, customize NET.Framework version, Application pool and so on?
I want to stop IIS then send e-mail to our testers about next publish and after then start publishing...
Sorry for my English...
:)

Sayed Ibrahim Hashimi said...

Hi Goodwin. Vishal is out of office for a while, I can help you with this. Please email me directly sayedha [at] -microsoft- [dot] [com]. Can you explain your scenario in a bit more detail, including if your are using a build server, and if so which one? If not what technologies are you using?

Thanks,
Sayed Ibrahim Hashimi

Pavel Chuchuva said...

Can you do one-click-publish to remote server from command line?

Vishal R Joshi said...

"Can you do one-click-publish to remote server from command line?"

Yes Pavel you can... I am hoping to write that post soon...
thanks
Vishal

Pavel Chuchuva said...

"I am hoping to write that post soon"
Can you at least give a hint on how to do it? :)

Salomon said...

Vishal,

We've been using 1-click publishing for several months now and its great. One issue we've come up against is how to centralize or distribute the settings. We are three developers working on an app, and if we modify the 1-Click settings for one developer it would be great if we could then copy the settings to the other two developers so that everyone is always using the same profile.
The other solutions would be to use a shared settings file.

Any suggestions?

Thanks

SG

Anonymous said...

Hi Vishal, I'm following the steps to deploy the SQL database but cannot see the Deploy-SQL tab after I opened the Properties window? I'm using VS2001.

Thanks, Lou

Vishal R Joshi said...

Hi Lou,
Can you confirm that you are using Web Application Project (WAP) and not WebSite project? Also I assume you mean VS 2010...
Thanks
Vishal

Vishal R Joshi said...

Hey Lou,
Btw the tab is now called "Package/Publish-SQL" instead of "Deploy SQL"
Thanks
Vishal

Anonymous said...

Hi Vishal, you're right. I'm using WebSite project, then how do I go from here? Do I have to convert to WAP or something, and if so then could you show me how please.

Yes, I'm using Visual Studio 2010.

Thanks, Lou

Anonymous said...

oh ok, I got it. I found the tab "Package/Publish-SQL".

Thanks for your quick response.
Lou

Anonymous said...

Hi Vishal,

I have 2 connection strings defined in my webapp, 1 connects to MySQL dbase and the other to SQL Server 2008. When I click on "Import from Web.config" it displays two connection strings as expected.

In the section of "Destination Database Information" what information should I put it there since I'm deploying my webapp to corporated intranet that I'm given this specific ip address, that's all.

As for "Source Database Information" it only automatically pulls out the connection string for MySQL, but not for the SQL Server 2008. Would that be a problem since I have two connection strings needed for my webapp as stated above.

Thanks,
Lou

Vishal R Joshi said...

Hey Lou,
VS does not support MySQL, it only supports SQL Server 2005 & above...
You should delete the MySQL connection from the dialog and only keep SQL Server 2008... In the source connection string just put the SQL Server connection string... For destination connection string you can keep it empty if you are creating a .zip package... If you are publishing then you need to fill it up...
If you have IP address of the server, I think that can be put similar to "Data Source=127.0.0.1 ..." within the connection string...
Hope that helps...
-Vishal

Anonymous said...

Thanks Vishal.

Would that be ok to use "127.0.0.1/myapp" as for Site/Application in the "Publish Web" window because I don't have DNS mapping to this IP yet, and since I'm getting this error:

"Could not complete the request to remote agent URL 'https://127.0.0.1/MsDeploy.axd?site=127.0.0.1'.
Unable to connect to the remote server
No connection could be made bedause the target machine actively refused it 127.0.0.1:443", or would that cause by other problem?
I chose "Web deploy" as Publish method and assumed it behaves same as "MSDeploy Publish".

Thanks,
Lou

Vishal R Joshi said...

Hi Lou,
Is your server setup with MsDeploy Server side configuration... Check http://blogs.msdn.com/webdevtools/archive/2009/06/05/basic-microsoft-web-deployment-tool-setup-for-visual-studio-2010.aspx to make sure that step is enabled... Also you need to provide port number in your URL i.e. https://ServerIP:8172/MsDeploy.axd?site=Default Web Site/myApp...

think about the URL in the following way:

https://ServerIP:8172/MsDeploy.axd?site=Default Web Site/myApp

ServerIP - This is the IP address that you might have for your server
:8172 - This is the portnumber on which IIS Remote management service will be listening...
/MsDeploy.axd - This the handler which will be called by IIS Remote management service and will be passed your site name...
site=Default Web Site/myapp - This is the actual site/application on the server that you are publishing it... IP address just gives you the pointer of the server not the site under it... The site name has to be something like "Default Web Site/App1"... If you do not have a sub app under "Default Web Site" and want to publish directly to the root of the site then you can ignore /App1...
Hope this helps
Vishal

Anonymous said...

Hi Vishal, I've got the domain name and have installed Web Deployment Tool on the server.

Publishing still failed however, with the same error as before. The link you sent (.../basic-microsoft-web-deployment-tool-setup-for-visual-studio-2010.aspx) is for Windows Server 2008 only, and I can't find it for Windows Server 2003.

Web Deployment Agent Service is running on the server.

I'm not sure what else that I missed...
Thanks,
Lou

Anonymous said...

Hi Vishal, below is the error message that I got. I used the default port 443 for https; Web Deployment Tool already installed in the Server, and Web Deployment Agent Service is running on the Server.

Can you help please since it's my first time to publish the website on Windows Server 2003.

Thanks,
Lou


Web deployment task failed.(Could not complete the request to remote agent URL 'https:///MsDeploy.axd?site=aptest.mitel.com'.)
This error indicates that you cannot connect to the server. Make sure the service URL is correct, firewall and network settings on this computer and on the server computer are configured properly, and the appropriate services have been started on the server.
Error details:
Could not complete the request to remote agent URL 'https:///MsDeploy.axd?site=aptest.mitel.com'.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it :443

Vishal R Joshi said...

Hi Lou,
On Win 2k3 it is not possible to use Msdeploy.axd... It is possible only on IIS 7 and above... For Win2k3 you have to use Remote Agent style URLs and you have to be an admin on the server. You can look at the URL format by hitting the blue "?" button next to Service URL on Publish dialog.
I will try to write a blog post on when to use which type of publishing but before I get to it do note the https://server:8172/msdeploy.axd?site=xyz format can be used only with IIS7 and above.
Thanks
Vishal

Anonymous said...

Hi Vishal, thanks for the info. I have a short schedule to get my website published for my company internally, and I actually did try some, but got some errors:

1/ Everytime I create a certificate then apply it, it said it is expired. Just curious, for windows server 2008 does it need a certificate as well?

2/ When I type mysite.mycompany.com, it gives http 403 error with 'This website requires you to log in' even though I added Login.aspx in the 'Documents' tab.

3/ In 'Home Directory' tab, would the 'Local Path' be pointed to the bin directory?

4/ I didn't see the mdf file in the server, how would I do that?

5/ Do I need to copy web.config manually to the bin directory?

6/ How would I configure when one of my connectionString points to MySql database?

Thanks very much for your help.
Lou

Anonymous said...

Sorry, the error for applying certificate saying 'This request may be canceled' even though I've just created one (certreq.cer).

Thanks, Lou

Anonymous said...

Hi Vishal,

I finally got Windows Server 2008 for the test server so now I could follow closely to your instruction, and IIS7 has been installed. I still, however, got this error when publishing:

Web deployment task failed.(Could not complete the request to remote agent URL 'https://:8172/MsDeploy.axd?site=test.mysite.com'.)
This error indicates that you cannot connect to the server. Make sure the service URL is correct, firewall and network settings on this computer and on the server computer are configured properly, and the appropriate services have been started on the server.
Error details:
Could not complete the request to remote agent URL 'https://:8172/MsDeploy.axd?site=test.mysite.com'.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it :8172

The following have been done in the server:

- Web Deploy is installed
- net start msdepsvc is started
- Port 80 is open

I don't nkow what else that I missed? Should I install SSL (Certificate) as well?

Thanks,
Lou

Anonymous said...

I don't know why the serverIP has been removed from the post but it should be read as https://serverIP:8172/MsDeploy.axd? on the Service URL box.

Thanks,
Lou

Vishal R Joshi said...

Hi Salomon,
sorry for the delay in response, you can go to Solution Explorer and click "Show All Files" button then you should find a file called ProjectName.Publish.xml this file contains all the settings which you can eventually check into source code control (not recommended but it is a back door way) and then that can be shared with your team..
the password will not be saved correctly so the only thing which you will have to manually type after every sync would be the password...
Hope this helps
Vishal

Vishal R Joshi said...

Hi Lou,
If the certificate is not trusted you will have to click "Allow untrusted certificates"
Thanks
Vishal

Vishal R Joshi said...

Q. One issue we've come up against is how to centralize or distribute the settings. We are three developers working on an app, and if we modify the 1-Click settings for one developer it would be great if we could then copy the settings to the other two developers
A. Hi Solomon, sorry for the delay in response. Please click on solution explorer icon to "Show all files" this will show the file ending with Publish.xml. this file contains the Publish profile settings. You can share this file across users and share the settings although that is not an official solution. Longer term we will look into fixing this.
thanks
Vishal

hnieef said...

really confius. i use vs.net premium and when i click publish web why i dont get same screen with ur publish web. advise me plssss

Vishal R Joshi said...

Hi Hnieef,
This option is available for Web Application Projects i.e. when you do File --> New --> Project --> Web Application Project...
Can you check if you are getting this on VS 2010
Thanks
vishal

Unknown said...

Can you tell me where your blog on how to configure for an inhouse webserver and database rather than an offsite hosting company is?
Thanks,
Finns

Vishal R Joshi said...

Hi Sheila,
That setup is described at http://blogs.msdn.com/b/webdevtools/archive/2009/06/05/basic-microsoft-web-deployment-tool-setup-for-visual-studio-2010.aspx
Thanks
Vishal

Jyothi said...

Hi,

I am new to sharepoint and TFS. I am using TFS2010, How could i deploy my sharepoint site using TFS.

Vishal R Joshi said...

Jyoti,
Can you please send me an email at Vishal.Joshi@Microsoft.com and I will connect you with the correct people to discuss Sharepoint deployment more.
thanks
Vishal

Anonymous said...

Vishal:

I have a deployment that works great to my web server with http, but that fails with https. With https I get a 403 that suggests I check that the remote deployment agent is running. (It clearly is, since it works with http.)

Any ideas?

Thanks,
John

Vishal R Joshi said...

Hi John,
When you set up the remote agent you either set it up for http OR https, it seems like you set it up for http hence the https:// is not working. Check out the technet article at http://technet.microsoft.com/en-us/library/ee461175(WS.10).aspx which should help you on this better.
Thanks
Vishal

Anonymous said...

Vishal:

Thanks much. I've looked over the page, and can see that there is some considerably configuration in front of me still, but at least it's nice to know what the problem is.

Best,
John

Anonymous said...

My god and they said this is supposed to make our life easier...
Right now it is a hell
For more than two days I am struggling with this and whatever I did I still get an error
I nearly read everything about the subject I could find with google

I have a very common architecture
VS2010 and a remote SQL Server 2008R2 Web server
The Web Server is not in a domain but in its one workgroup and it is running only one MVC application as default site

Vishal R Joshi said...

Hi Anonymous,
I am really sorry to hear that you are facing these problem. Do you want to send out an email at Vishal.Joshi@Microsoft.com with the errors that you are facing and I will be happy to help.
Also if you would like to get on a phone to sort this out then please do let me know.
thanks
Vishal

Anonymous said...

Hi Vishal,
Thanks for this post.Really really helpful.
I am using this method to publish my web application to a diferent directory in the same way you have mentioned in this post.

But I am facing following major issues -
1) I have app_code folder in my project.But after publishing I am not getting all files in the destination 'app_code' folder and thats why I am getting error "class not defined" when I execute my application. I think app_code folder should compile completely??

2)I want to use Web.Release.Config while publishing and I have already made all required chnages as per you told in your post. But When I run my applicationon that server I am getting error related to Web.config(I have error in my project as I haev mentioned in above point 1). Its asking to include in root web.config. I know that there is some error on my page but why it is asking to include even if I used release mode?

Please help me.

Thanks,
Priya

domain register said...

Yes, i agree that Visual Studio 2010 has great features to make web deployment easier….. It has great features.. thanks!

Anonymous said...

Used a lot of this in my final year IS Project....complete lifesaver!
Thank you so much Vishal :)

Minal
(South Africa)