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.


VMWare Fusion: Access SharePoint App from Mac Host

If you are a SharePoint App (Add-In) developer who uses a Mac and VMWare Fusion for VMs, you may wonder whether you can access your app from host. May be you want to test your app in Safari on Mac, or may be, just may be your VM is too slow when Chrome running on it (that was my case 😉 ). For what ever the reason, if you want to access your app from Mac, this is the guide for you.

First step of this guide is basic configuration of your VM, SharePoint and host Mac OS to make it available.

Add network adapter to your VM and set its connectivity type to NAT (Share with my Mac on settings). You don’t have to do this if you already have a NAT adapter. Now if you goto Network Connections on Windows, you must see an adapter which have IP begins with If you want to use the subnet as it is, you can ignore next steps and make IP address static on it to make sure it won’t change later. Remember to add the default gateway when you add static IPs.

To change the subnet of your network adapter, you have to update internal settings of the NAT adapter. When you set connectivity type to NAT in any network adapter, it automatically point to vmnet8 internal adapter. What we are going to do is to update its settings so that you can add subnet mask you want.

  1. First turn off all the VMs running and quit VMWare Fusion
  2. Goto folder
    In Fusion 4.x and above:  /Library/Preferences/VMware Fusion/
    In Fusion 3.x and earlier:  /Library/Application Support/VMware Fusion/
  3. Open networking file and update subnet and mask as appropriate
  4. Goto folder  vmnet8  and open  nat.conf
  5. Update NAT gateway address which aligned to above subnet and mask
  6. If you are using Fusion 4.x, just start VMWare Fusion, 3.x and below, run below command

    Note: When using 4.x and above, do not use the –restart command because it may result in unexpected behaviors. Instead, restart Fusion.
  7. Goto SharePoint VM, make NAT network adapter configuration static and update IP and gateway IP which aligns to above configuration.
  8. Disable firewall settings or allow access from host to Windows.
  9. Run ping on your IP from terminal to make sure it works.

This is not required, but if you want to access one of your web application from IP, you can update alternative access mapping of your web application to IP address and check whether it’s accessible via host. This is not recommended because, in this way you can only point to one web application, but you want all of your web applications accessible from the host.

In my case, I have two completely different domains to web applications and apps.

Web applications: *
Apps: *

What I want to do is to access both of these from my host. If you may notice, if I need to access only web applications and I only have few number of web applications, I can just update  hosts file in Mac OS and access it via host. But the issue is accessing apps, when you develop SharePoint Apps, each time you deploy it to SharePoint, it changes the domain name of the application, and we can’t add wild card domain names to  hosts file. Because of this reason, we goto next stage of this tutorial.

  1. Install  Homebrew if you don’t have it on your Mac
  2. Install  dnsmasq , using this tool, you can setup your DNS resolver. Read more about dnsmasq here.
  3. Make sure you have  /usr/local/etc folder exists.
  4. Now I want to point above mentioned wildcard domains to my VM IP (

    Purpose of this command is to create  dnsmasq.conf file in   /usr/local/etc which have following lines.

    From this what is says is to point all traffic from * and * to IP
  5. Now we want Mac OS resolver to use  dnsmasq only for above wildcard domains. First we have to create folder which contains custom resolver domains.

    Add custom domain to use resolver in localhost.

    Now you have resolver pointed to  dnsmasq only for domains we need.
  6. Now we want to launch dnsmasq and restart it with Mac OS startup.
  7. Run pings on few domain names under your wildcard domains to see the beauty. 😉

Now you can peacefully try your SharePoint domains from Mac OS browsers and verify your application works on all environments.