Sharing the goodness…
Beth Massi is a Senior Program Manager on the Visual Studio team at Microsoft and a community champion for .NET developers. Learn more about Beth.
More videos »
A lot of folks have asked me for information on how to publish a LightSwitch application to IIS6. With the help of a couple team members we finally got the steps written down. This is a follow up to the detailed IIS7 on Windows Server 2008 deployment guide which you should familiarize yourself with first. There is a lot more information there on how deployment actually works:
Deployment Guide: How to Configure a Web Server to Host LightSwitch Applications
In this post I’m just going to show you the basic steps necessary to configure a Windows 2003 Server with IIS6 installed. I’ll also show you the MSDeploy commands you need to automate a deployment package created with Visual Studio LightSwitch.
Step 1: Install Web Platform Installer
You can use the Web Platform Installer (WPI) to set up a Windows web server fast. This makes it super easy to set up a machine with all the stuff you need. Although you can do this all manually, I highly recommend you set up your LightSwitch server this way. This will install IIS & Web Deploy for you (if you don’t have it installed already) and configure them properly.
To get started, select the Products link at the top then select Tools on the left. There you will see two options for LightSwitch Server Runtime. One option is to install SQL Server Express called “Visual Studio LightSwitch 2011 Server Runtime and Local SQL“ and the other is “without Local SQL”. If you already have an edition of SQL Server installed on the machine or if you are hosting the database on another machine you can choose the “without Local SQL” option
Select the option you want and then click Install and off you go. During the install you will need to reboot a few times.
Step 2: Start Web Deployment Agent
Next we need to verify the Web Deployment Agent Service is started. Open up Services and right-click on Web Deployment Agent Service and select Start if it’s not already started.
Step 3: Configure Your Web Site and Database for Network Access
In order for other computers to access your server’s websites via HTTP on a Windows 2003 machine, you need to configure the Windows Firewall. Click on the Advanced tab, select the network connection and click the Settings… button. On the Services tab check off the “Web Server (HTTP)” and verify the name of your web server, then click OK.
Now computers on your network will be able to navigate to the server via http://SERVERNAME. Next thing you need to verify is that your database server is also accessible. This configuration is the same as I describe in the Deployment Guide using SQL Configuration Manager so refer to that post.
Step 4: Deploy from Visual Studio LightSwitch
Now that your server is set up, you can deploy directly from Visual Studio LightSwitch. Keep in mind that when you deploy directly to IIS6 that the service URL should use http, not https. Https web deployment it is not supported on IIS6. See the Deployment Guide for step-by-step instructions on how to walk through the deployment wizard.
If you are not deploying directly from Visual Studio LightSwitch to your server but instead create a deployment package on disk, see the bottom of this post on how to install the package on IIS6.
Step 1: Install IIS6
First you will need to install IIS6 on your Windows 2003 box. You can take a look at this article for options on how to do this: Installing IIS (IIS 6.0)
Step 2: Install .NET Framework 4.0
Next you will need to install the .NET Framework 4.0 in order to get ASP.NET on the box.
Step 3: Install Web Deploy 1.1
In order to publish deployment packages you need to install Web Deploy 1.1. Install the appropriate package based on your server architecture and refer to this documentation for installation details: Web Deployment Tool Installation
Step 4: Install Visual Studio LightSwitch 2011 Server Runtime
Step 5: Start Web Deployment Agent
Open up Services and right-click on Web Deployment Agent Service and select Start if it’s not already started. See Step 2 in above section.
Step 6: Configure Your Web Site and Database for Network Access
In order for other computers to access your server’s websites via HTTP on a Windows 2003 machine, you need to configure the Windows Firewall. See step 3 in the above section on how to do this.
Step 7: Set .XAP file MIME type
In IIS Manager, verify the mime type for the .xap file extension. Right-click on the Default Web Site and select Properties then select the HTTP Headers tab. Click MIME Types… and map the .xap extension to application/x-silverlight-app as shown:
Step 8: Deploy from Visual Studio LightSwitch
If you are not deploying directly from Visual Studio LightSwitch to your server but instead create a deployment package on disk, see below for steps on how to install the package on IIS6.
Note: These instructions will only work for the RTM (version 1) Release of Visual Studio LightSwitch (not LightSwitch in Visual Studio 11 Beta). These instructions will work for both IIS6 and 7+
Instead of using direct deployment from the LightSwitch deployment wizard, you can choose to create a deployment package on disk. (See the Deployment Guide for step-by-step on how to walk through the deployment wizard to create a package and deploy it to IIS7).
In order to deploy to IIS6 you need to use the MSDeploy command line tool. If you are going to be creating or updating a remote database you will also need SQL Server Management Objects installed on this machine. You can get these through the Web Platform Installer referenced above and selecting SQL Server Management Studio 2008 R2 Express or the Visual Studio LightSwitch 2011 Server Runtime with Local SQL. You can also obtain them directly from here. If you already have SQL or SQL Express installed then you can skip this prerequisite.
1. Make sure you are logged in as an administrator of the machine.
2. Copy the deployment package (i.e. Application1.zip) to the IIS6 server machine.
3. Next create a file with the parameters you are going to need to pass to MSDeploy. You can obtain the parameters you need from the package by executing this command. Open a command prompt and assuming the path to the deployment package is C:\Publish\Application1.zip, type:
>"C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -verb:getParameters -source:package=C:\Publish\Application1.zip
This will list out the parameters you need. Some of them will change based on the type of authentication you are using. For any LightSwitch application you will need to specify the following:
<?xml version="1.0" encoding="utf-8"?> <parameters> <setParameter name="DatabaseAdministratorConnectionString" value="Data Source=servername\SQLEXPRESS;Initial Catalog=Application1;User ID=admin;Password=adminPassword" /> <setParameter name="DatabaseServer" value="servername\SQLEXPRESS" /> <setParameter name="DatabaseName" value="Application1" /> <setParameter name="DatabaseUserName" value="dbuser" /> <setParameter name="DatabaseUserPassword" value="dbpassword" /> <setParameter name="Application1_IisWebApplication" value="Default Web Site/Application1" /> </parameters>
Note that the DatabaseAdministratorConnectionString is only used by this process to create/update the database. The DatabaseUserName and DatabaseUserPassword values are used to construct the connection string in the web.config and is the credential used by the LightSwitch middle-tier when your app is running.
If you are using Windows authentication you will need to specify one additional parameter:
<setParameter name="Application Administrator User Name" value="DOMAIN\UserName" />
If you are using Forms authentication you will need to specify three additional parameters:
<setParameter name="Application Administrator User Name" value="UserName" /> <setParameter name="Application Administrator Full Name" value="Full Name" /> <setParameter name="Application Administrator Full Password" value="strongPassword" />
4. Save the parameters XML file in the same location as the deployment package (i.e. Application1.Parameters.xml)
5. Run the following command to import the package, replacing the ServerName below with the name of the IIS server:
>"C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -verb:sync -source:package=c:\Publish\Application1.zip –dest:auto,computerName=http://ServerName/MSDEPLOYAGENTSERVICE -setParamFile:c:\Publish\Application1.Parameters.xml
If you get any errors connecting to the deployment service then double-check the service is running (as shown above) and verify that you are logged in as an administrator of the machine.
6. If your application is using Forms or Windows authentication then you need to also run the following command to set up the Admin user in the database so you can log in the first time. You need to specify the location of the web.config to do this.
For Windows authentication, run:
>”C:\Program Files\Microsoft Visual Studio 10.0\LightSwitch\1.0\Tools\Microsoft.LightSwitch.SecurityAdmin.exe” /createadmin /config:"c:\inetpub\wwwroot\Application1\web.config" /user:"DOMAIN\UserName"
For Forms authentication run:
>”C:\Program Files\Microsoft Visual Studio 10.0\LightSwitch\1.0\Tools\Microsoft.LightSwitch.SecurityAdmin.exe” /createadmin /config:"c:\inetpub\wwwroot\Application1\web.config" /user:"UserName" /fullname:"Full Name" /password:"strongPassword"
You can perform the same steps on either an IIS6 or IIS7 machine.
Direct deployment is a lot less work if you can allow it. The LightSwitch publishing wizard performs all the necessary steps for you directly from the LightSwitch development environment. However, often times you do not have (nor want) access to deployment servers. This is why LightSwitch can produce deployment packages on disk instead. With IIS7, you can import these packages using the GUI in IIS manager, however in IIS6 you need to use the MSDeply command line as shown above.
We’re making improvements to the deployment in LightSwitch in Visual Studio 11 and in my next post on deployment I’ll walk through some of the enhancements. In particular, now when you create a package, the parameters and command files are automatically generated for you alongside the deployment package. This makes it really easy to just add your settings and go. Until next time…
UPDATE 2/29/2012: LightSwitch IIS Deployment Enhancements in Visual Studio 11
great post! thanks
This is a huge pain point for a lot of people. I have people in the forums on my site saying "LightSwitch is a great program to use but I can't deploy". Now we have a post to point them to!
Thank you Erik for your help troubleshooting! Hopefully customers will appreciate this info. :-)
This post is so useful! I can't remember how many days (and nights...) I've been trying to deploy to our customer's site!
Hello, where can I find the "Visual Studio LightSwitch 2011 Server Runtime" as the link above is not working. are the files only available in the web platform installer 3.0?
The link works fine for me, maybe you just need to try again. These are also available in the Web Platform installer.
I have a 2-tier deployment question.
We have a separate data source (SQL Server 2005 installed on a PC named DbServer) for all of the data accessed by the LS application; it is NOT using SQL Server Express, like many of your examples. We used SQLPackager to generate the database schema AND some data for our tables, then installed this on DbServer to generate our data source.
In reading through your guides, I can't decipher WHERE the SQL Server Express database needs to be created for deployment??? SQL Server Express resides on the developer's PC during the development process. But does it need to be installed on DbServer for all of our networked clients to see it for the 2-tier deployment?
OR, Does each client need a copy of SQL Server Express installed on it?
Thanks Beth, but how do I deploy with Lightswitch 2012? I don't have "Visual Studio LightSwitch 2012 Server Runtime" in my Web Installer and my publish keeps failing...
Can you please tell me where I can get - Visual Studio LightSwitch 2011 Server Runtime
according to this article.
The link provided in Step 4 does not seem to work.