SharePoint-hosted add-ins are one of the two major types of SharePoint Add-ins —SharePoint-hosted and provider-hosted. In these Provider hosted add-in is the one which is hosted and cantered around a remote web app or data source whereas provider hosted add-in is cantered around SharePoint components including lists, pages, web parts, workflows, libraries etc.

Among the two methods, the simpler and the most used one is SharePoint add-in which eases out building RAD applications for non-developers. There might be many cases where a business analyst need to build a demo site with the data present in the SharePoint list/libraries for their customers when this really comes in handy. But it is very rare that a Business analyst to be accustomed with using visual studio which is the only way to create an add-in.

So it is always advantageous to be able to build a SharePoint add-in with any HTML and JavaScript based files that are generated from any of the RAD tools available in the market like WaveMaker for example. So to be able to do this we first need to analyse how a SharePoint add-in is packaged so that we can do that ourselves manually or build a tool which does the job without the need of visual studio.

Building App (.app) folder

Analysing the add-in package we can observe that it is a compressed packaged folder with .app extension but the only thing we need to take care is the packaging is done confining to the open xml standards which adds relationship files(.rels) for each file in the package. This app package folder will have the .wsp file which is the actual add-in and the whole metadata required for add-in like AppManifest and AppIcon etc. Also to generate relationship files for all these files, we need to have one Config file (.config) for each file which would assign a unique GUID for each of them. Config file is an xml file which would be in below format, we can easily generate these in .Net using XML serialization.

In open xml packaging standards each file is considered as an AppPart. Once we have this folder ready with the items mentioned we can generate the .app file using system.io.packaging namespace. we can use below code to package the folder in Open XML standards.

Building wsp (.wsp) folder

wsp folder is a packaged cabinet file. In this the web files are added into one of the feature folder. This is because sharepoint addin can host multiple feature sets at a time.Apart from the feature folder it contains a manifest file which points to the feature.xml files present inside the feature set folder.

Once we generate all these xml files we can build the cabinet file using the nuget reference MSFTCompressionCab and below code

This generated app file can directly be uploaded into a O365 SharePoint developer site from the UI easily which completes the sharepoint addin hosting.