maandag 6 augustus 2012

SharePoint 2013: app components

When using Visual Studio 2012 RC, by default the SharePoint 2013 developer tools are not installed. Use the link mentioned in one of my previous posts to download and install them.

To create a new SharePoint app, open Visual Studio -> file -> new -> project. Select the 'Office/SharePoint' node and then select 'App for SharePoint 2013'. Make sure you also select the 'SharePoint hosted' option.

As you can see in the Solution Explorer, the solution contains one project containing the app manifest and all the other resources that will make up the final SharePoint app.

The app manifest
The app manifest is a CAML file which tells SharePoint something more about the app we want to install. It contain the name, a unique product ID, an icon, ... . Notice that when you double click on the manifest file, Visual Studio 2012 now provides you with a new and far more easier configuration screen which in the background will correctly adapt the CAML itself. Also notice that when you right click on the manifest file you can still do 'View code' to see the actual CAML and do your own modifications if needed.

<?xml version="1.0" encoding="utf-8" ?>

<App xmlns="http://schemas.microsoft.com/sharepoint/2012/app/manifest"
     Name="SharePointApp1"
     ProductID="{98baa31c-06be-4144-bb39-f9b26595416c}"
     Version="1.0.0.0"
     SharePointMinVersion="15.0.0.0">
  <Properties>
    <Title>SharePointApp1</Title>
    <StartPage>~appWebUrl/Pages/Default.aspx?{StandardTokens}</StartPage>
  </Properties>

  <AppPrincipal>
    <Internal />
  </AppPrincipal>

  <AppPermissionRequests>
    <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web/list" Right="Write"/>
  </AppPermissionRequests>

</App>
  • The first node, the 'App' node contains the name, product ID, version and minimal version of SharePoint required.
  • The default 'properties' tag holds the title and the startpage. Notice the new token '~appWebUrl': The URL of the app web of an app for SharePoint.
  • What I have added myself is the 'AppPermissionRequests' tag. Remember that app permissions are not the same as user permissions. There is not real hierarchy and the application will ask for certain permissions during installation. What is asked for exactly is specified in the manifest file. The permission request is in the form of a URL pointing to what permissions are needed. If you use the visual configuration in Visual Studio, in the 'Permissions request' section, you can try out different stuff. The available options will be listed for you.
Resource files
What else is in the package ? Basically a collection of standard SharePoint modules which will take care of the deployment if the resource files. These are mainly javascript, CSS and ASPX pages. Remember that to create the logic of your app, you cannot use server side code on a SharePoint server. You will have to use a combination of javascript, REST and CSOM to do all your stuff. Microsoft has already included the JQuery javascript library and has also provided you with an app.js file where you can start coding some Javascript. All files are loaded in the default.aspx page.

Geen opmerkingen:

Een reactie posten