Tips and Tricks to build a Package for Web Application Gallery

 Building a package for Web Application Gallery does not have to be a daunting task. Here are a few tips and tricks to build a package for Web Application Gallery.  In order to create both these configuration files (manifest and parameters), you need to have a good understanding of the application and the manual installation process of the application on IIS. For identifying what goes into a manifest.xml file and parameters.xml file , these are the key things to look for:

#1 : What folder and files require Modify Permissions

The default ACL is ReadandExecute for any folder and file. So include ACLs if there is a folder(s) or files that require MODIFY permissions.

For ASPNET applications DO NOT use setAclUser attribute. The default is always Worker Process

Example code in manifest file

<setAcl path="application/App_Data" setAclAccess="Modify" />

For PHP applications , alywasy use setAclUser="anonymousAuthenticationUser"

Example code in manifest file

<setAcl path="application/sites/default/settings.php" setAclResourceType="File" setAclAccess="Modify" setAclUser="anonymousAuthenticationUser" />

Note # you will NEED to create matching parameters for these ACLs in the parameters.xml file. Web deploy understands which content ACLs need to be changes by referencing both the parameter for setAcl provider and the corresponding match in manifest.xml

#2: Does the application support a database (SQL Server and MySQL) .

If yes , then you would have to include SQL Scripts:

For SQL Server/SQL Azure :  

  • One script is required to create a user login
  • One script is required for setting permissions for this newly created user

These tasks can be combined in one SQL script, but will not work if you want your application to be included for Azure App Gallery but will work for Web PI and Web Matrix

For MySQL :

  •  Single script required to create the user and setting the permissions for this newly created user

Sometimes you may need to include the database schema scripts in the package if you want the database to be configured during deployment . For more details on creating a package that supports a database , refer to this article

#3: Where is the database information stored in the application

Identify the file where this information is stored and parameterize this database information: database name, host, username , password

For PHP apps , it is usually a configuration setting in the its config file . For example here is a code snippet for parameterizing Database Name

<parametername="Database Name"description="Name of the database for your application."defaultValue="app_db"tags="MySQL,dbName"> <parameterEntrytype="TextFile"scope="install.sql"match="PlaceHolderForDbName"/></parameter><parametername="Automatic Database Name PHP File"defaultValue="define('DB_NAME', '{Database Name}');"tags="Hidden, MySQL"> <parameterEntrykind="TextFile"scope="wp-config\.php$"match="define\('DB_NAME', '[^']*'\);"/></parameter>


For ASPNET apps , usually is it a connection string format for example

<parameter name="Connection String For Config" defaultValue="Data Source= {DbServer};Database={DbName};uid={DbAdmin};Pwd={DbAdminPW};" tags="Hidden,SQL">
<parameterEntry type="XmlFile" scope="\\web\.config$" match="//connectionStrings/add/@connectionString" />


Note # always use XPATH (if using XmlFile as Type) or Regular expression (if using TextFile as Type) that is generic and will always find a match for the parameter in the configuration file. This is specific to Web Matrix, where the end –user can change the values of the database name or username. Web Matrix should be able to identify the database and allow the user to access the database within Web Matrix

#4: Does this application require additional information from the user

The application may require additional information from the user. If this information needs to be requested from the end-user before deployment, then create parameters to capture this information. If this is handled with the applications “configuration scripts” or “installer”, then you don’t need to create parameters as this will be handled after a successfully deployment.

#5: Does you application satisfy the security standards for App Gallery  

For ASPNET apps, make sure it meets the standard best practices for Security and supports Medium Trust level . For PHP apps, make sure there are Rewrite URLs included in a web.config for the application which can be imported from the application's htaccess files . 


Additional references

You can find more articles and samples on Web Application Gallery here .