Saturday, October 31, 2009

VS 2010 Beta 2 Read Me Items for Web Deployment

There are some known issues/bugs related to VS 2010 Web Deployment features in VS 2010 Beta 2 Read Me… I can imagine reading the entire Beta 2 read me file can be daunting so I thought I can just copy paste the ones related to Web Deployment here…

DB Deployment will fail if the Database Name is longer than 127 characters

Description: If you are using latest VS 2010 Web Deployment Features and trying to deploy your database using the Deploy SQL property page then at times you might get error from VSMsDeploy task. 

There might be several reasons for the failure including connection and authentication issue but a current bug in the product does not allow you to script schema/data from a database (typically SQL Express MDF file) if the file path is longer than 127 characters.  In the OS like XP or Win2K3 the default path for the VS project & its default ASP.NET Login/Profile DB could be something like C:\Documents and Setting\... \Visual Studio 2010\Projects\MyProject\App_Data\ASPnet_DB.mdf... This path can potentially exceed 127 characters and result into Deployment failure...

Workaround: The easy work around is to have the project copied to a location where the path will not exceed 127 characters for e.g. C:\MyProject\App_Data...  This issue will eventually be resolved in the product...

Some VS 2010 Web Deployment Features will not work if VS 2010 is installed on Vista RTM instead of Vista SP1

Description:  If you are using the new Web Deployment feature set in VS 2010 and are using the below features which integrate with MSDeploy:

then you will have to use Vista SP1 instead of Vista RTM as your OS.

Workaround: MsDeploy requires features which are built inside Vista SP1 and hence trying to run Web Deployment features on Vista RTM fails.  This is a required dependency so you will have to use Vista SP1 as your OS for VS 2010.  Do note that you can still use any other operating system like XP, Win2K3, Win2k8 R2, Win7 etc to install VS 2010 and use the Web Deployment features, it is just advised that any of the OS versions that you use are updated with the latest Service Packs so that all the required dependencies are in place.

MsDeploy.exe.config file will be required to run Web Deployment on machines with .NET 4.0 only

Description: If you installed VS 2010 on a clean machine which does not have .NET 2.0 (e.g Win2K3)  and are trying to use the VS 2010 Web Deployment Features then when you run the deploy.cmd file to install your web package you might receive error stating "Msdeploy.exe -.NET Framework Initialization Error Unable to find a version of the runtime to run this application."  This is due to the fact that VS 2010 comes with only .NET 4/CLR4 and and CLR 4 does not allow CLR 2.0 executables to run  without having an explict exe.config file…  If you are using other .NET 2.0/3.0 or 3.5 exes on a box with just .NET 4 then you might face similar issues with those EXEs too…

Workaround: You can easily work around this by going to "%Program Files%\IIS\Microsoft Web Deploy" (& additionally also on "%Program Files (x86)%\IIS\Microsoft Web Deploy" folders and create following msdeploy.exe.config file in there

<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v2.0.50727" />
<supportedRuntime version="v4.0" />
</startup>
</configuration>






This issue will be fixed in the future releases of the product.



-Vishal

Wednesday, October 21, 2009

How to ensure placeholder folders are created during VS 2010 Web Deployment

During many web deployment scenarios developers want to be able create place holder folders where eventually their log files or runtime generated files like XMLs, Images etc will be stored…

With VS 2010 Web Deployment there will be a small work around required for you to be able to deploy place holder folders…  Before I go about explaining the work around let me call out that if you do not know about VS 2010 Web Deployment features it might be worth while to check out the blog series about VS 2010 Web Deployment at Overview Post for VS 2010 Web Deployment

Anyways, as VS 2010 Web Deployment is completely based on MSBuild based Web Publishing Pipeline (WPP) lot of deployment depends upon the MSBuild constructs…  One of the key features which is also supported using MSBuild based constructs is the ability to exclude Files and Folders from deployment.  I am hoping to write blog posts on both of these topics at some point but currently without going into the details consider following:

There is a file/folder structure like C:\MyWeb\Foo\Bar\myfile.htm…  VS 2010 will allow you to exclude or include myfile.htm or folder “Foo” from Web Deployment… If you now chooses to include myfile.htm but chooses to exclude “Foo” folder then the WPP will get into unwanted complex state for potentially trivial gains…

That is the reason most of the include, exclude, delete etc operations are done at the File level rather than at Folder level… So when you are excluding a folder from deployment  behind the scenes a bunch of files under that folder are getting excluded and the end result is the folder being excluded too… The above explanation is not exactly how it translates into code but is more for understanding purposes…

Anyways, this design decision causes the side effect that if there are no files in a folder then the folder does not get deployed as well… By now I imagine you must have figured out the work around too :-) Ya! just put a place holder file even if it is empty.txt in your place holder folder and it will get deployed too !!

If this causes you a lot of grief then do write back with your scenarios so that we can try to understand and analyze them individually…

Also do note that whether you are creating a web package or doing 1-Click Publish the same rationale applies as ultimately same WPP is executed behind the scenes for both…

-Vishal

Monday, October 19, 2009

How to debug the selected page inside selected project all the time?

As you might already know http://connect.microsoft.com is a way to open bugs/request suggestions on various Microsoft products… One of the repeated suggestion I see for Web Development within Visual Studio is the ability to hit F5 on any .aspx page within a solution and have it be treated as the “Start up page”…

It is pretty common to set a fixed page as a start up page within a Web Project…You could do that simply by right clicking the page of your choice and setting “Set as Start Page” as shown below:

Set As Start Page

The above will fix your start page to be “Default.aspx” and no matter what you select within the project, Default.aspx will start when you hit F5…

You can make the active selected page as your start up page by going to the Project –> Properties –> Web  and choosing the “Current Page” as your “Start Action”

Current Page Start Action

There is a similar option for Web Site Projects too, although the interesting ask comes up when you have more than one web project in your solution and you want to debug current page from the project you have currently selected…

Most people right click on their project and click “Set as StartUp Project” every time they want to change the project they are debugging  (as shown below):

Set as StartUp Project

Although there is a well kept secret in Visual Studio, which is worth noting…  You can actually right click on your “Solution File” and click “Set Start up  projects…”

Set StartUp Projects...

This will bring up the below dialog:

StartUp Projects

In this dialog you just need to select the radio button which says “Current Selection” and this will automatically make the project you are in as the start up project…

Effectively by choosing “Current Selection” for the Start Up Project and the “Current Page” for Start Action,  you can now very easily debug the project + web page of your choice simply hitting F5…

-Vishal

 

Monday, October 12, 2009

Server specific Web.config sections replacement with WDP

In this post I am hoping to explain how you can change your web.config settings per different server environment using Web Deployment Projects (WDP) for VS 2005 or VS 2008…

First of all let me start with the fact that WDP for VS 2005 as well as WDP for VS 2008 are build configuration aware… In fact, special effort was made in WDP 2005 & WDP 2008 to allow configuration specific settings…

That is the reason when you look at the WDP UI you can see configuration specific dropdowns as shown below:

WDP Property Page

You can create one build configuration per your server environment eg. “Testing”, “Staging” , “Production” etc and configure all of your WDP settings per build configuration pretty easily… Learn more how to manage configurations per build environment

Next I want to change connectionStrings section in side the web.config for “Testing” server and “Release” server… The original connection String section in my web.config file looks as below:

<connectionStrings>
<add name="vishal-db" connectionString="Data Source=vijoshi-DevBox; Initial Catalog=vishal-db; Integrated Security=True"/>
</connectionStrings>








  • For “Testing” environment I would like to change my Data Source to be vijoshi-Testing


  • For “Release” environment I would like to change my Data Source to be vijoshi-Release



To accomplish this I am going to add two configuration files to my project named connectionString.Testing.config and connectionString.Release.config… After adding the two files my solution explorer should look as below:



image



The content of connectionString.Testing.config file will look as below:




<connectionStrings>
<add name="vishal-db" connectionString="Data Source=vijoshi-Testing; Initial Catalog=vishal-db; Integrated Security=True"/>
</connectionStrings>

Notice that the connectionString.Testing.config only contains connectionStrings section (as opposed to original web.config which may contain many other sections) … Similar to the above example in connectionString.Release.config file I will only change the Data Source to vijoshi-Release…


After these two files are added I can now open my WDP configuration and go to the “Deployment” node and check the “Enable Web.config file replacement”…  After this the only thing I need to do is write connectionStrings=connectionString.Testing.config  as shown below…


 


connectionStrings=connectionString.Testing.config


 



After this when I build my WDP project the connectionStrings section will be replaced by the content of the connectionString.Testing.config…



Also now I can modify the Configuration from “Testing” to “Release” and set the Web.config file section replacements section to look as below



connectionStrings=connectionString.Release.config 



This way you can also modify the other config sections each in a new line of the text box shown above…



Hope this will help…



-Vishal

Thursday, October 08, 2009

Live Meeting: Simplifying Deployment With the Web Deployment Tool (MSDeploy)

One of our MVPs Sayed Ibrahim Hashimi is doing a Live Meeting  MVP TV talk on : Simplifying Deployment With the Web Deployment Tool (MSDeploy)

You are invited to join the talk which is scheduled for

Wednesday, October 14th, 2009 | 4:00pm – 5:00pm (PDT, Redmond time)

Abstract

Deploying ASP.NET Websites has always been a challenge and different teams have used different approaches to overcoming those challenges. Microsoft has offered some support for making deployment easier in the past. For instance they first introduced Web Deployment Projects for Visual Studio 2005, and also have a version for 2008. Web Deployment Projects do greatly simplify the process of calling the aspnet_compiler and aspnet_merge tool but even though their title states “Deployment” they had no support for physically deploying the site. Now Microsoft has introduced the Web Deployment Tool, also known as MSDeploy. MSDeploy will bridge the gap between taking a web site and physically deploying it to its destination. With MSDeploy you can easily and very effectively perform tasks such as pushing an ASP.NET site (Web site, Web Application Project, ASP.NET, etc) from one machine to several other machines. This is achieved by the target machines having the MSDeploy Remote Agent Service installed and running. You can sync two different Web Sites that are hosted in IIS, you can create a web package (simply a .zip file) and use that as your source, you can sync two different folders, and many other options. Another compelling feature of MSDeploy is that it will be integrated into Visual Studio 2010. From Visual Studio 2010 you can compile your ASP.NET Web Application Project and then create the Web Package which contains all your content files plus IIS settings. This one file will full describe your web.

Live Meeting Information

Join the meeting.
Audio Information
Computer Audio
To use computer audio, you need speakers and microphone, or a headset.
Telephone conferencing
Use the information below to connect:
Toll-free: +1 (866) 500-6738
Toll: +1 (203) 480-8000
Participant code: 5460396

Please join 10 minutes prior to the start time.

First Time Users:
To save time before the meeting, check your system to make sure it is ready to use Microsoft Office Live Meeting.
Notes

Troubleshooting
Unable to join the meeting? Follow these steps:

1. Copy this address and paste it into your web browser:
https://www.livemeeting.com/cc/mvp/join

2. Copy and paste the required information:
Meeting ID: PR7D6Z
Entry Code: A5128ML0Y0D
Location: https://www.livemeeting.com/cc/mvp

If you still cannot enter the meeting, contact support

Note

Microsoft Office Live Meeting can be used to record meetings. By participating in this meeting, you agree that your communications may be monitored or recorded at any time during the meeting.

Hope this helps!!

-Vishal