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, choose Publish <Application Name>.

    The LightSwitch Publish Application Wizard appears.

  2. On the Application Type page, verify that the Desktop option is selected, and then choose the Next button.

    NoteNote

    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 Server Configuration page, verify that Local is selected, and then choose the Next button.

  4. On the Publish Output page, in the Where do you want the application files to be placed? section, 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 Publish directly to the database now, and then choose the Next button.

    If you prefer to create a database script, choose Create a script to install and configure the database.

    A Database Configuration step will be added to the wizard.

  6. Choose the Next button to continue.

  7. On the Database Connections page of the wizard, enter a connection string for the computer where you will deploy the database.

    To change the connection strings

    1. Choose the browse (…) button.

      The Connection Properties dialog box appears

    2. In the Server name box, 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, choose the Use SQL Authentication option button, and then enter a valid User name and Password for the server.

      If SQL Server is configured to use Windows Authentication, you can choose the Use Windows Authentication option button instead.

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

      You must enter the same name that you entered for the Application Name property in the Application Designer.

  8. Choose the Next button to continue.

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

    To create a new database

    • On the Database Configuration page, choosethhhe Generate a new database called option button, 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. Choose the connection string, and then choose the browse (…) button.

      The Connection Properties dialog box appears

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

      NoteNote

      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. Choose the Next button to continue.

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

    NoteNote

    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.

    NoteNote

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

  15. In the Password field, type a password.

    NoteNote

    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. Choose the Next button 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, choose the Yes, I need to specify additional prerequisites option button, and then select the check boxes of 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. For more information, see How to: Include Prerequisites with a ClickOnce Application.

  21. Choose the Next button to continue.

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

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

  24. Choose the Next button to continue.

  25. On the Summary page, choose the Publish button.

    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.

      NoteNote

      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 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 by running the Setup.exe file.

    NoteNote

    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 LightSwitch Authentication and Authorization.

Show: