How to: Deploy a 2-tier Application

A 2-tier deployment creates a LightSwitch application that runs on the end-user’s Windows desktop computer. The database and server components run on the same computer. The LightSwitch Publish Application Wizard guides you through the deployment process.

To publish a 2-tier desktop application

  1. On the Build menu, click Publish <Application Name>.

    The LightSwitch Publish Application Wizard appears.

  2. On the Welcome to the LightSwitch Publish Wizard page, verify that the Desktop option is selected, and then click Next.

    Note

    Selecting Web will change the application to a 3-tier browser application. For more information, see How to: Deploy a 3-tier Application.

  3. On the Application Services page, verify that Local is selected, and then click Next.

  4. On the Publish Output page, select the Where do you want the application files to be placed? section and enter the path where you want the publish output to be located. The default location is the Publish subdirectory under your project directory.

  5. In the How do you want to publish the default database? section, choose either Publish directly to the database now or Create a script to install and configure the database, and then click Next.

  6. Click Next to continue.

  7. On the LightSwitch Application Data – SQL Database Connection page of the wizard, verify that the connection strings are valid for the computer where you will deploy the database. You can change the strings to specify a different database server and different user credentials if necessary.

    To change the connection strings

    1. Select the connection string that you want to change and click the browse (…) button.

      The Connection Properties dialog box appears

    2. In the Connection Properties dialog box, select the Server name field and enter the name of the database server where you want to publish the application database.

      The database server must be pre-configured to have SQL Server 2005 or a later version, or SQL Server 2005 Express or a later version. It does not have to be located on the same server where you are publishing the application.

    3. In the Log on to the server section, select Use SQL Authentication and enter a valid User name and Password for the server.

    4. In the Select or enter a database name, enter the name of your application, and then click OK.

      This must be the same name that you entered for the Application Name property in the Application Designer.

  8. Click Next to continue.

  9. If you chose to create a script, the Database Configuration page will appear. On this page you can choose to create a new database or update an existing database.

    To create a new database

    • On the Database Configuration page, select Generate a new database called, and enter the name for your database.

      This must be the same name that you entered for the Application Name property in the Application Designer.

    To update an existing database

    1. On the Database Configuration page, select The application needs to update an existing database.

    2. Select the connection string and click the browse (…) button.

      The Connection Properties dialog box appears

    3. In the Connection Properties dialog box, enter the connection information for the database.

      Note

      The connection string can point to a different database as long as the database schema is exactly the same as the database that you want to update.

  10. Click Next to continue.

  11. If you have enabled authentication for your application, the Application Administrator page will appear.

    Note

    If you chose to create a database script, you do not need to provide any information on this page.

  12. On the Authentication page, select the Should the Application Administrator be created when the application is deployed? section and then click Yes, create the Application Administrator at this time.

  13. In the User Name field, type a user name.

    If you are using Windows authentication, this should be a valid Windows login name using the form domain\user.

  14. In the Full Name field, type the full name of the user who will be the default administrator.

    Note

    The Full Name field does not appear if you are using Windows authentication.

  15. In the Password field, type a password.

    Note

    The Password and Confirm Password fields do not appear if you are using Windows authentication.

  16. In the Confirm Password field, type the password again.

    Make sure that you remember the user name and password. You will need it later.

  17. Click Next to continue.

  18. On the Prerequisites page, in the Does the application have additional prerequisites that need to be installed? section, review the list of prerequisites to determine whether you want to install them.

    The prerequisites that are checked are the default prerequisites.

  19. If you want to install additional prerequisites, click Yes, I need to specify additional prerequisites, and then check the prerequisites to install.

  20. In the Specify the install location for the prerequisites section, if you want to install from a network share, click Download from the following location and enter the path of the location where the installers for the prerequisites are located.

    The default choice, Download from the Internet, will download the prerequisites from the Microsoft download site as needed.

    You can also choose Copy from the same location as my application. If you choose this option, you will need to make sure that the installers for the prerequisites are located in the application folder.

  21. Click Next to continue.

  22. If you have specified additional data sources for your application, the Other Connections page will appear. Verify that the connection strings are correct, and then click Next.

  23. On the Specify a Certificate page, leave Specify a certificate unchecked. A certificate is not required for a 2-tier application.

  24. Click Next to continue. The Summary page appears.

  25. Click Publish to publish the application.

    When the application is published, the setup files are placed in the directory that you specified for the publish output.

  26. Copy the contents of the publish output directory to each computer where you want to install the application. The following step must be completed before running Setup on the target computer.

    1. If you chose the Publish directly to the database now option in Step 5, in the directory that contains the publish output, open the Install.htm file and follow the instructions to configure the target computer.

      Note

      If you are installing on a computer that has LightSwitch or another LightSwitch application installed, the computer is already configured.

    2. If you chose the Create a script to install and configure the database option in Step 5, in the directory that contains the publish output, run the two script (.sql) files to create the database and the default SQL user account for the application.

  27. Users can install the application double-clicking the Setup.exe file.

    Note

    If you have enabled authentication for your application, the application administrator will have to authorize users before they can run the application. For more information, see How to: Create a Role-based Application.

See Also

Tasks

How to: Change the Deployment Topology and Application Type

How to: Create a Role-based Application

Concepts

Deploying LightSwitch Applications

Other Resources

Deployment: Distributing and Maintaining Your Application

How to: Deploy a 3-tier Application