---
title: "Discussion on \"Package SPFx solution with one command and automatically increase the version\" | Hashnode"
description: "Discussion on \"Package SPFx solution with one command and automatically increase the version\". Optimize SPFx packaging with auto-version increment in one command for seamless updates, syncing package-solution.json and package.json"
url: "https://hashnode.com/posts/package-spfx-solution-with-one-command-and-automatically-increase-the-version/62ac542a2b2b09182b658540"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Package SPFx solution with one command and automatically increase the version](https://spfx-app.dev/package-spfx-solution-with-one-command-and-automatically-increase-the-version?utm_source=hashnode&utm_medium=feed)

Optimize SPFx packaging with auto-version increment in one command for seamless updates, syncing package-solution.json and package.json

Jun 17, 2022 · 7 min read · spfx-app.dev  
Updated Sep 7, 2023  
Read the article

-   [#microsoft](https://hashnode.com/tag/microsoft)

## Written by

[$€®¥09@](https://hashnode.com/@Seryoga)

@Seryoga · Nuremberg, Germany

  
[View profile](https://hashnode.com/@Seryoga)

Software Architect

I am Sergej and I am a Software Architect from Germany (AURUM GmbH). I have been developing on Microsoft technologies for more than 14 years, especially in SharePoint / Microsoft 365. With this blog, I want to share my knowledge with you and also improve my English skills. The posts are not only about SPFx (SharePoint Framework) but also about tips &amp; tricks around the M365 world &amp; developments of all kinds. The posts are about TypeScript, C#, Node.js, Vue.js, Visual Studio/ VS Code, Quasar, PowerShell, and much more. I hope you will find some interesting posts. I would also be happy if you follow me. Greetings from Germany Sergej / $€®¥09@

## Responses 4

Markdown supported · ⌘↵ to post

[Jonathan Adcox](https://hashnode.com/@blayderunner123)

[Jun 24, 2024](https://hashnode.com/posts/package-spfx-solution-with-one-command-and-automatically-increase-the-version/62ac542a2b2b09182b658540/comment/66799c95d8fb7d5221748bcc)

Very useful. Deployed it instantly

[Jonathan Adcox](https://hashnode.com/@blayderunner123)

[Jun 28, 2024](https://hashnode.com/posts/package-spfx-solution-with-one-command-and-automatically-increase-the-version/62ac542a2b2b09182b658540/comment/66799c95d8fb7d5221748bcc#reply-667e9edefac7b06621612d73)

[$€®¥09@](https://hashnode.com/@Seryoga) to the Gulp command in the article. However there were a few bugs. When I build and clean it will not run as intended and only when I use the gulp command directly does it build properly and it builds with Major version only. Did you address this in the comments?

[$€®¥09@](https://hashnode.com/@Seryoga)

[Jun 28, 2024](https://hashnode.com/posts/package-spfx-solution-with-one-command-and-automatically-increase-the-version/62ac542a2b2b09182b658540/comment/66799c95d8fb7d5221748bcc#reply-667ea635514bf9951350370c)

[Jonathan Adcox](https://hashnode.com/@blayderunner123) Hmmm, where exactly is the error? I've never had this before. I use `npm run publish` and this command does a `gulp clean` and then a `gulp build`, `gulp bundle --ship`, `gulp bump-version` and then `gulp package-solution --ship` one after the other.

Normally only the patch version is updated, unless you specify something else.

By the way: If you use the command `npm run publish` and there was a warning/error in the console output, then the commands are not executed, with the output `exit with code 1` (or something like that). This is due to the `&&` command combination. But you can prevent this by disabling the warnings.

PS: As mentioned in the other comments, I can recommend using my CLI, which does exactly the same settings as described in this article, and does so with a command line and also adds the "disable warnings" command. And some more. Here is the link to the CLI article (with Video): [spfx-app.dev/my-cli-for-spfx-development](https://spfx-app.dev/my-cli-for-spfx-development)

[Jonathan Adcox](https://hashnode.com/@blayderunner123)

[Jun 28, 2024](https://hashnode.com/posts/package-spfx-solution-with-one-command-and-automatically-increase-the-version/62ac542a2b2b09182b658540/comment/66799c95d8fb7d5221748bcc#reply-667eb0773e394f1a5793f7ac)

[$€®¥09@](https://hashnode.com/@Seryoga) oh I already disabled those errors due to an unused variable that is only accessed in SharePoint however in the build it is never used. As such I had to disable the warning to build the solution. I likely fat fingered something. I will go back and see what I transposed wrong

[$€®¥09@](https://hashnode.com/@Seryoga)

[Dec 9, 2022](https://hashnode.com/posts/package-spfx-solution-with-one-command-and-automatically-increase-the-version/62ac542a2b2b09182b658540/comment/63935db5344783061f8c5757)

Hello [Thomas Leclaire](https://hashnode.com/@tleclaire), hello [Sujit Daswant](https://hashnode.com/@Sujit88Daswant),

now you can use my newly released npm package [@spfxappdev/cli](https://www.npmjs.com/package/@spfxappdev/cli). This package is a command-line utility that modifies your SharePoint Framework solution so that you can use the versioning logic described above without additional modifications. You can use "alias" paths instead of relative paths. Also, an automatic "version increment" task (gulp) is included and you can build, version, bundle and package the solution with just one `npm` command.

A blog post will follow in the next few days.

[Sujit Daswant](https://hashnode.com/@Sujit88Daswant)

[Sep 16, 2022](https://hashnode.com/posts/package-spfx-solution-with-one-command-and-automatically-increase-the-version/62ac542a2b2b09182b658540/comment/63244665dd55cd8b89b1be7e)

Hi Sergej Schwabauer, I am really appreciate for this blog, this is helped me lot for Auto increment the the version number.

But I am facing issue with the above, when I am trying to run the command for npm run publish -- --no-patch,npm run publish -- --major,npm run publish -- --minor version always the minor version get updated even for no patch also.

Please let me know how to fix this.

[Sujit Daswant](https://hashnode.com/@Sujit88Daswant)

[Sep 19, 2022](https://hashnode.com/posts/package-spfx-solution-with-one-command-and-automatically-increase-the-version/62ac542a2b2b09182b658540/comment/63244665dd55cd8b89b1be7e#reply-632848bd99624fc71cd5161f)

[$€®¥09@](https://hashnode.com/@Seryoga) , Thanks for quick response. As per mentioned in comment I have tried to run the command and its working fine. version is getting updated as expected.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1663584321596/PDgumGoPT.png)

I think the issue is with this command, npm run publish -- --no-patch npm run publish -- --major npm run publish -- --minor

I have followed the steps as per mentioned in this blog.

[$€®¥09@](https://hashnode.com/@Seryoga)

[Sep 19, 2022](https://hashnode.com/posts/package-spfx-solution-with-one-command-and-automatically-increase-the-version/62ac542a2b2b09182b658540/comment/63244665dd55cd8b89b1be7e#reply-63288b98195e7dc741da5e32)

[Sujit Daswant](https://hashnode.com/@Sujit88Daswant) Okay, I understand. And now I know what you mean and what the problem is. The `npm run` command with the additional arguments is only added to the "last" command (in our case ==> `gulp package solution` command). But we need this argument in the `gulp bundle` command. Thanks for your hint. To fix it, you need to create a post-script and modify the "publish" script:

```
"publish": "gulp clean && gulp build && gulp bundle --ship",
"postpublish": "gulp package-solution --ship"
```

Thanks again and I have already changed it in the post above.

[Sujit Daswant](https://hashnode.com/@Sujit88Daswant)

[Sep 20, 2022](https://hashnode.com/posts/package-spfx-solution-with-one-command-and-automatically-increase-the-version/62ac542a2b2b09182b658540/comment/63244665dd55cd8b89b1be7e#reply-632986fd195e7dc741da7ac9)

[$€®¥09@](https://hashnode.com/@Seryoga) ,

I am really appreciate your solution. The solution which you have provided is worked for me and also seen the updated changed in the blog.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1663665849506/NfegjPetm.png)

Now the Auto Version are updating as per expectation.

Keep posting your valuable experience with us.

Happy Coding ;-)

[Thomas Leclaire](https://hashnode.com/@tleclaire)

[Jun 17, 2022](https://hashnode.com/posts/package-spfx-solution-with-one-command-and-automatically-increase-the-version/62ac542a2b2b09182b658540/comment/62accf24f867313a799c58ee)

How would you use this in an Azure Devops Deployment pipeline where you would have to save the increased version back to the repo?

[$€®¥09@](https://hashnode.com/@Seryoga)

[Jun 20, 2022](https://hashnode.com/posts/package-spfx-solution-with-one-command-and-automatically-increase-the-version/62ac542a2b2b09182b658540/comment/62accf24f867313a799c58ee#reply-62b0c348c0f84f6b540d1c78)

[Thomas Leclaire](https://hashnode.com/@tleclaire) Thank you for your comment. Please have a look at this newly created post. I hope it helps you: [spfx-app.dev/spfx-azure-devops-pipeline-increment…](https://spfx-app.dev/spfx-azure-devops-pipeline-increment-version-push-to-repository-and-publish-package)
