For any SharePoint 2013 apps to deploy and be of use to anyone, they must be first packaged into .app
packages, which in turn are Open Packaging Convention (OPC) packages,
and therefore Zip files in disguise. If you rename them with a .zip
extension you can open and extract them much like you would any other
Zip package. The OPC packaging format is fully documented and
standardized. You can read more about it and working with packages at: http://msdn.microsoft.com/en-us/magazine/cc163372.aspx.
A SharePoint app package has four main parts:
- Manifest
- SharePoint solution package
- Web deploy package
- Database package
For those developers familiar with full-trust solution .wsp
files in SharePoint 2010, this concept of a single file containing
multiple subparts might seem familiar (excluding the database package
portion). In SharePoint 2010, WSP solutions also included a manifest,
files and assets, and code packages (DLLs). However, in SharePoint 2013
the format and deployment of these assets varies greatly.
The manifest in an app package contains important information such as the app’s name and version.
The SharePoint solution package
contains XML-based declarations for SharePoint components such as lists
and content types that should be deployed as part of the app.
The Web deploy package is the code portion of your app. It is the package that will be deployed to Azure as part of an Autohosted app.
Finally, the database package
contains the SQL Azure deployment package that deploys and creates a
database as part of an Autohosted app deployment, and might include
post deployment scripts to populate tables with data.
To better understand the format and contents of an app package, take a look inside one in the following Try It Out.
Exploring an App Package (SharePointAppPackage.app)
In this exercise you open an .app package file and explore its parts.
1. Copy the SharePointAppPackage.app file to a location on your hard drive; for example, c:\tmp\SharePointAppPackage.app.
2. Right-click the file and choose Rename.
3. Remove the .app extension and replace it with .zip. You might need to turn on Show file extensions in Windows Explorer options if you don’t see the .app extension when you go to rename it.
4. If you are asked whether you are sure you want to rename the file choose OK.
5. After renaming it, open the Zip file. You should see a set of files similar to the one shown in Figure 1.
6. Select all
the files and copy them to a new location outside of the Zip file. This
step assists with opening and exploring them.
7. Open the
AppManifest.xml
file. You will see the manifest markup as shown in the following code
snippet. This contains the name of the app, ID, version, and other
information about the app code and where it’s located.
<?xml version="1.0" encoding="utf-8"?>
<App xmlns="http://schemas.microsoft.com/sharepoint/2012/app/manifest"
Name="SharePointAppPackage" ProductID="{6b80672f-3edc-409c-94fe-608ee4264280}" Version="1.0.0.0"
SharePointMinVersion="15.0.0.0">
<Properties>
<Title>SharePointAppPackage</Title>
<StartPage>~remoteAppUrl/Pages/Default.aspx?{StandardTokens}</StartPage>
</Properties>
<AppPrincipal>
<AutoDeployedWebApplication />
</AppPrincipal>
<AppPermissionRequests>
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web"
Right="FullControl" />
</AppPermissionRequests>
<AppPrerequisites>
<AppPrerequisite Type="Capability" ID="A83C8D70-71DE-4260-9FB8-677418EB47F2" />
<AppPrerequisite Type="Feature" ID="5B79B49A-2DA6-4161-95BD-7375C1995EF9" />
<AppPrerequisite Type="AutoProvisioning" ID="Database" />
<AppPrerequisite Type="AutoProvisioning" ID="RemoteWebHost" />
</AppPrerequisites>
</App>
How It Works
The fundamental part of an app package is the app.manifest
file. As you have seen in this example it is straightforward to open
and look around inside an app package. It is also recommended you take
a look inside the SharePointAppPackage.Web.zip file. This is the app code and pages packaged in a Web deploy package.
The Database1.dacpac file is the SQL Database project for the app that will be deployed to SQL Azure when the application is installed.
The last important element is the SharePointAppPackage.wsp
file. This is the SharePoint Solution package that contains definitions
for things such as content types, columns, lists/libraries, and
features.
In the following sections you will
explore each of these main components that go into an app package in
more detail and also try out building your own.