Auto versioning SharePoint Apps (and Sandbox Solutions)


spav  is a simple tool which can be used to automatically version SharePoint App packages and SandBox solution packages. You can provide custom app versioning library to provide your own mechanism to build app or WSP. It also can be used to generate application version JavaScript file which can later used to inject into pages and use in client side.

This a project which I created to automate the versioning of SharePoint hosted app. Initially it started as small tool, but in order to make it usable to other developers, I have added few modifications to it.

First I will explain the reason I created this tool in the first place. Recently I was involved in development of SharePoint app which had rapid development cycle. Client was expecting fast builds which deployed in SharePoint Online site. Client used his app catalog to publish the developed application across multiple sites. First version of the application published in multiple sites without any issue, but when we had to release next version of the app, we faced few problems.

  1. Versioning of the app package
  2. Update exiting content published by app -> Solution feature versioning

In order to update an application which published via app catalog, next version must have version upgrade. It can be major, minor or even patch level update, whichever it is, it must be reflected on Version property in AppManifest.xml file. If we do not change version in this file, site collection administrators will not see an app update in Site Contents.

Even if we update app version in AppManifest.xml file, it will not update the content we added in the app if we do not version application features properly. You can read more about versioning features in this blog post. As you can see, update content of the an app not easy as we think, and it all depends on feature version.

In this version of the application, my target was very simple. I wanted to maintain same version throughout the application as well as all features. In this way, when I add or update a file in a module, it’ll automatically get replaced.


spav  is a simple tool which can be used to automatically version SharePoint App packages and SandBox solution packages. It also can be used to generate application version JavaScript file which can later used to inject into pages and use in client side.


In order to use this tool inside Visual Studio, you have to add pre or post deployment step to SharePoint add-in project. Whether to use pre-deployement or post-deployment is up to your requirement.

-p, --path  [Required] Directory of application project. Can be taken from $(ProjectDir) MSBUILD parameter.

-m, --mode  [Required] Running mode.

  • AppPackage: Increases the version of application package(.app)
  • Wsp: Build a sandbox compatible package with feature versioning
  • AppPackageAndWsp: Update app package and create sandbox solution

-b, --build-config  (Default: Debug) Application build configuration. Can be taken from $(Configuration) MSBUILD paramater.

-j, --build-js  (Default: False) Build JavaScript file to use in versioning for client side versioning. This will work with parameters –js-path and –js-class.

--js-path  (Default: {Path}\applicationVersion.js) Save path for JavaScript file.

--js-class  (Default: appVersion) JavaScript namespace to contain application version.

--versioning-lib  (Default: AutoIncrementBuildVersion.dll) Library used to get build version.

--versioning-class  (Default: SharePointAppAutoVersioning.AutoIncrementBuildVersion.VersionProvider) Full path of class in versioning library.

--help  Display help screen.


Auto increment patch and build version of the SharePoint App package

Generate SandBox compatible solution with feature updates

Update app package version and generate SandBox solution

Build JavaScript file which can be used inside the application while updating version of app package

This will generate below JS file.

NOTE: Application will use 5 commented lines which is on top of JavaScript file to generate the next version. If you erase these lines, version will be resetted to If you want to change major or minor version, you can change it in here and it’ll be reflected it next build.

You can access version values as below,

Use custom versioning library

You can write your own custom versioning library for your versioning purposes. In order to do that, you have to create new class library and add reference to SharePointAppAutoVersioning.Shared.dll  file which you can find in application folder.

Lets assume that dll from your project is ContosoApp.CustomBuildVersion.dll . In order to use this inside the application, you have to copy this file to location of spav.exe  path. After you copy it, you can use it like below.

I will explain in another post about tools and libraries which I used to develop this application. Meanwhile, you can check my repo here, fork it, do your customization and send pull request to me. I’d like to add new versioning libraries for different scenarios and make it usable for more people. 🙂 Happy coding!!

Get Tenant Id from SharePoint App | JavaScript

In rare cases, you may need to find id for Office 365 tenant or SharePoint app catalog tenant id. This solution is for you, who want to get tenant id or unique id for a SharePoint farm with in a SharePoint App using JavaScript.

This solution can only be used when host web has SharePoint App installed, reason for that is, in order to get tenant id, it uses the product id of the app. If SharePoint App is installed in the site, this solution can be used in the host web or in the app web.


Searching with the Office 365 APIs – Richard diZerega

Today, Microsoft quietly launched the “search” permission scope in Azure AD Applications. This is huge step in delivering new scenarios with the Office 365 APIs that leverage SharePoint search and the Office Graph. In this post, I’ll illustrate how to leverage search with the Office 365 APIs and use it to query site collections and modern groups a user has access to (a difficult/impossible task with the Office 365 APIs until today).

via Searching with the Office 365 APIs – Richard diZerega’s Blog – Site Home – MSDN Blogs.