This post is over a year old, some of this information may be out of date.
Not long after I had published my previous article, I got the following question on Twitter:
Let’s split this up into the following questions:
- Can you automate the SPFx solution package upload process?
- Remove the app from the recycle bin? For this article, I will only cover the first one. The second one is currently not possible with the gulp-spsync or gulp-spsync-creds plugin.
How to automate solution package upload process
The same plugins can also be used to automate the solution package publication to your site. That way you do not have to do any manual actions anymore, everything can be done from your command prompt.
Important: the only manual action is that is required, is after you first publish the solution package, that you manually trigger the deployment.
The task that you need to add in your gulp file (gulpfile.js) looks like this:
Once you added this task in the gulp file, first run the command to package the solution:
gulp package-solution (test) or
gulp package-solution --ship (production). After the solution package is created, you can now run the new upload package command:
gulp upload-app-pkg or
gulp upload-app-pkg --ship.
One required manual action
As I mentioned, there is one manual action which you should execute. That manual action is the deployment of your solution package and can be done as follows:
- Go to your app catalog site
- Open the apps for SharePoint list
- Select the solution package
- In the ribbon, select files -> Deploy and click on deploy
- Once you have done this, can just update the package via the gulp task
What with different environments: test, production?
Currently, the ship flag for the new upload package task has no added functionality yet. When you are working with test and production environments. To take advantage from this flag and automate the publication of your scripts and solution page to either your test or production.
This is what the updated task looks like to support the ship flag:
If you now run the following command:
gulp upload-app-pkg, it will upload it to your test tenant. With
gulp upload-app-pkg --ship you can upload it to your production environment.
I have updated the sample project which I used in the previous post with this new task. You can find the sample project on the following GitHub repository: upload to Office 365 CDN.