I’ve been using the auto generated build numbers paired with Stefan Bauer: How to version new SharePoint Framework projects and it’s been working great for myself. There is however, one minor issue. After running ‘npm version major/minor/patch’ it will also run the build/bundle that automatically increments the revision numbers. This is an unwanted side effect.

Running ‘npm version major/minor/patch’ requires a clean tree, but the build/bundle modifies the package-solution.json file causing a problem. I’ve updated the build/bundle code to accept a parameter that will NOT automatically increment the revision number. Ultimately I’m fixing a problem that I caused.

Let’s take a see an example.

First thing that you need is an extra npm package called ‘gulp-util’

Here are the gulpfile.js enhancements again, specifically gutil & fs

Next add the gulp task to bump the revision. You can see that this task is looking for an argument called ‘–no-revision’. If  ‘–no-revision’ is specified in the build or bundle command it will noop on the bumpRevision task.

Lastly register the bumpRevisionTask with the build process.

Again … all this is above the following

Now in order to skip the bumpRevisionTask you can call build/bundle like this:

That’s it… add this and you will get auto incrementing revision number w/ the option to NOT increment the build number.


Why is that so great? Because, if you pair this with Stefan Bauer’s npm versioning post it will run when you execute the ‘npm version major/minor/patch’ command causing a version like v1.0.3.1 … instead of v1.0.3.0


I’ll leave you with an example of my build commands for new versions that I’m releasing to dev/staging/prod.




I recommend reading some of my other posts on this subject

Original Post: SPFx Automatically Generating Revision Numbers

Simple Build Script for the SharePoint Framework

Stefan Bauer: How to version new SharePoint Framework projects


Enjoy! let me know how this works for you and your development teams.

There are no comments.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.