Friday, July 20, 2012

Office365 Preview Development - Using Visual Studio

..continuing with the Office365 preview and development one of the most anticipated and my favorite feature is given by Visual Studio 2012, what is that? lets see

looking back at SharePoint 2010 and Visual Studio 2010 days - we were able to create the SharePoint projects using built in project templates given by VS for SP 2010 - but the disadvantage of using this project template was we had to install on the SharePoint on machine itself, we couldn't just create the wsp project on local machine with VS 2010 installed and then deploy the wsp to the server.

So whats new now?
Well with the visual studio 2012 RC - there is enhancement done for those who deal with Office365 / SharePoint 2013.  we can create a app project and deploy it on the OnPremise or on cloud SharePoint directly. just need to mention the site URL and we are done. visual studio takes care of deploying and installing the app package for you.

Once you install Visual Studio 2012 RC on your machine - install the Office Project Templates using this link. (download the tools under tools section). after this is done - you will be able to see the SharePoint project templates in VS 2012 RC.

Lets create a sample app project and deploy it directly on Office365 preview SharePoint site.

 Click ok, next step is to enter name URL of SharePoint site on which you want to deploy this app. now interesting point here is you can either add the url of your on premise SharePoint server site or add url of your Office365 site.

again - it asks you to select the type of deployment of your app. there are two types of SharePoint app deployment.

1. SharePoint Hosted - everything remains in SharePoint , complete code runs on client.
2. Cloud Hosted  - when app contains some server side code the this deployment type is selected.
     this is again subdivided into two types
         a. Developer hosted - app developer should bring his own deployment infrastructure.
         b. Auto hosted - SharePoint takes care of deployment of package itself.
For more information - please take care of great video series by Andrew connel here.

we will select the SharePoint hosted app and click finish. VS 2012 RC opens up app editor.
Lets take a closer look at solution explorer which looks like this

Feature - a default feature which takes care of provisioning app entities to SharePoint
Content - application css file
Images - app image
Pages - application's default landing page
Scripts - application js file - all JavaScript files undergo this folder.

There is AppManifest.xml which contains app settings such as

App Title , Name , App Icon and App Default start page

Permission Request - If there are certain resources of the site collection / service applications needs to be accessed by the app - it should be mentioned in the permission requests , when app will be installed - a permission request will be made by the app to the user.

Feature Prerequisites - If app required certain feature of the web to be activated before its use then it is mentioned in feature prerequisites.

when this app is run - you should see welcome message - displaying this welcome message is handled in a js file where ECMA script / JSOM for SharePoint is used to retrieve the user name of the current user.

You can add / modify the js as you wish and can start building and deploying your app on your office365 preview site.

Have fun.

1 comment: