CreateApp (Application Deployment Sample)

This topic explains how to use the CreateApp sample, which demonstrates using the BTSTask command-line tool to deploy and undeploy a BizTalk application. You could use scripts such as those included in this sample to automate your nightly build process to deploy and undeploy BizTalk applications.

Important

You should always write your deployment scripts to run in silent mode. If you do not, dialog boxes will display that require user input. This will stop the deployment process until the dialog box is manually dismissed, which can cause the import process to hang.

What This Sample Does

The sample includes scripts that automate application deployment tasks. To perform these tasks, you run a script that generates the BizTalk project and files. Then you run a script that generates two BizTalk application .msi files – an .msi file that contains all of the artifacts in an application, and another that contains only one assembly in the application. Next you run a script that uses an .msi file to import an application into a BizTalk group and install the application onto the local computer. During installation, a pre-processing script included in the application creates folders used by the application and logs its actions to a file. Finally, you run a script that deletes and uninstalls the application. During uninstallation, a pre-processing script included in the application removes the files and folders that were created during installation and logs its actions to a file.

The following are the scripts included with this sample:

  • Build.bat. Generates a key file, builds the project in Visual Studio, and signs the .dll files.

  • CreateFullAndPartialMSI.bat. Takes the following actions, in order:

    1. Uses the BTSTask AddApp command to create an application.

    2. Uses the BTSTask AddResource command to add to the application three BizTalk assemblies as well as other resources that were generated by Build.bat.

    3. Uses the BTSTask ExportApp command to export the application's artifacts into an .msi file named CreateApplicationSample.msi.

    4. Uses the BTSTask ListApp Command to generate an application manifest named AppManifest.xml, which lists all of the artifacts contained in the application.

    5. Uses the BTSTask ExportApp command to export only the orchestrations assembly into an .msi file named CreateApplicationSamplePartial.msi. It does this by providing ResourceSpecPartial.xml for the ResourceSpec parameter. ResouceSpecPartial.xml is an edited version of ResourceSpecComplete.xml that has been provided with this sample. This file has been edited so that it contains a reference to the orchestrations assembly only. When provided with this parameter, BTSTask exports only the artifacts listed in the ResourceSpecPartial.xml file – in this case, the orchestrations assembly.

    6. Deletes the application from the BizTalk Management database for the group.

  • CreateNewAppFromMSI.bat. Uses CreateApplicationSample.msi generated by CreateFullAndPartialMSI.bat to install an application named CreateApplicationSample on the local computer as well as import the application into the BizTalk group. During installation, PreProcScript.bat runs automatically, as described later.

  • RemoveApp.bat. Takes the following actions, in order:

    1. Uses the BTSTask RemoveApp Command to delete the CreateApplicationSample application from the BizTalk Management database for the group.

    2. Uses the BTSTask UninstallApp Command to uninstall the CreateApplicationSample application from the local computer. During installation, PreProcScript.bat runs automatically, as described next.

  • PreProcScript.bat. Takes the following actions:

    • Each time it runs, sets the public key token for the assembly that has been provided by the user.

    • During application installation, creates the following folders that will be used by the CreateApplicationSample application to contain messages:

      C:\CreateApplicationSample\Out

      C:\CreateApplicationSample\In

    • During application uninstallation, deletes the files and folders that were created during installation. Also uninstalls from the global assembly cache (GAC) any assemblies that were installed in the GAC during installation and logs its actions to a file. To uninstall the assemblies from the GAC, it refers to the public key token provided by the user.

    • During both installation and uninstallation, creates a log file in the following location:

      C:\ScriptLog.txt

Where to Find This Sample

You can find the sample files in the following folders under <Samples Path>\Application Deployment\:

  • CreateApp (Folder)

    • Build.bat

    • CreateFullAndPartialMSI.bat

    • CreateNewAppFromMSI.bat

    • RemoveApp.bat

  • CreateApp\Bindings (Folder)

    • CreateApplicationSampleBindings.xml
  • CreateApp\Dlls (Folder)

    • Empty
  • CreateApp\ResourceSpecs (Folder)

    • ResourceSpecPartial.xml

    • ResourceSpecComplete.xml

  • CreateApp\Scripts (Folder)

    • PreProcScript.bat
  • CreateApp\HelloApplicationDeployment (Folder)

    • HelloApplicationDeployment.suo

    • HelloApplicationDeployment.sln

  • CreateApp\HelloApplicationDeployment\Maps (Folder)

    • POToInvoice.btm

    • Maps.btproj

  • CreateApp\HelloApplicationDeployment\Orchestrations (Folder)

    • Orchestrations.btproj

    • HelloOrchestration.odx

  • CreateApp\HelloApplicationDeployment\Schemas (Folder)

    • Schemas.btproj

    • POSchema.xsd

    • InvoiceSchema.xsd

How to Use This Sample

Use the following procedure to use this sample.

To use the sample

  1. Run Build.bat. This generates a key file, builds the projects under the folder HelloApplicationDeployment, signs the resulting .dll files, and places the.dll files in the Dlls folder.

  2. Open the PreProcScript.bat file, which is located in the CreateApp\Scripts folder. In the following line of code, remove REM and provide the public key token for the assembly:

    REM set PublicKeyToken=

    Example:

    set PublicKeyToken=1234a5b6c1234567

  3. Run CreateFullAndPartialMSI.bat. This creates two application .msi files, CreateApplicationSample.msi and CreateApplicationSamplePartial.msi.

  4. Run CreateNewAppFromMSI.bat. This imports the CreateApplicationSample application into the BizTalk group and installs it on the local computer.

  5. Check the script log file, located at C:\ScriptLog.txt to verify that the script logged its installation actions.

  6. Verify that the CreateApplicationSample application appears both in the BizTalk Server Administration console and Add or Remove Programs.

  7. Run RemoveApp.bat. This deletes the CreateApplicationSample from the BizTalk Management database and uninstalls it from the local computer.

  8. Check the script log file, located at C:\ScriptLog.txt to verify that the script logged its uninstallation actions. They should appear after the installation actions logged earlier, during installation.

  9. Verify that the CreateApplicationSample application no longer appears in either the BizTalk Server Administration console or Add or Remove Programs.

  10. Verify that the folders that were created during installation have been deleted.

  11. Verify that the assemblies have been uninstalled from the GAC.

See Also

Application Deployment (BizTalk Server Samples Folder)
Deploying BizTalk Applications