Thursday, April 14, 2005

How do you deploy an ASP.NET application to a non default web site?

Well, it's a bit tricky, at least until VS 2005 arrives. Until then, take a look at Microsoft Tech Note 821335. It comes with a new version of DCPA.DLL, and a JavaScript file called EnableHostHeaders.js.

What to do with that though? Well, to make it simplier for me, I created a quick and dirty VS Add in. It's pretty simple. Just use the Add In Wizard. Then add a form to the project and code a button on it to allow you to select the MSI file:

OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "MSI files (*.msi)|*.msi|All files (*.*)|*.*" ;
openFileDialog1.FilterIndex = 1 ;
openFileDialog1.RestoreDirectory = true ;
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
msifile = openFileDialog1.FileName ;
textBox1.Text = msifile ;
bOK.Enabled = true ;
}

Then add another button that uses Process.Start to run the EnableHostHeaders file on the MSI file:

System.Diagnostics.Process.Start(
""c:program filesteamsybaseenablehostheadersEnableHostHeaders.js"", """ + msifile + """) ;
this.Close() ;

Finally, go back to the add in class and in the Exec function simply display the form:

EnableHostHeadersForm myForm = new EnableHostHeadersForm() ;
myForm.Show();

The add in wizard automatically creates a setup project as well. Compile the entire solution, then exit VS.Net and run the setup program outside of VS.Net. If you run the setup from within VS.Net, the changes to the Tools menu aren't saved.



From now on, after compiling your setup project for an ASP.Net project you simply run the add in on the resulting MSI file. When the setup is run now, it will display a DDLB that allows you to select the web site on the server to install to.

1 comment:

Andrea Ferendeles said...

Unfortunately this patch introduce an issue during uninstall of .MSI.

Virutal Directory is not removed !

Some ideas ?

Thanks.Andrea.