Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude node_modules folder from publish artifact in VSTS

I currently have a build definition in place to build my project and publish my files for release. My project relies on a bit of NPM to do some automation using Gulp.js. I dont need it for anything else once my gulp-tasks have run.

When I get to my publish artifacts step, it publishes all of the files in the node_modules directory even though I don't even have them in my repo. I was wondering if there was a way to exclude them from within the contents section or if anyone else has a better idea?

Here is my Publish Artifacts settings: enter image description here

In the Contents section, I also tried:

**\*
!**\node_modules\*

I am pretty new with the Build & Release process and I am unsure what other information might be needed to help debug this issue. So please comment and I can include information as needed. Thanks!

like image 789
scapegoat17 Avatar asked Aug 18 '17 15:08

scapegoat17


People also ask

What is stored in the node_modules directory of your node application folder?

The node_modules folder contains every installed dependency for your project. In most cases, you should not commit this folder into your version controlled repository. As you install more dependencies, the size of this folder will quickly grow. Furthermore, the package-lock.

What is node_modules folder for?

The node_modules folder is used to save all downloaded packages from npm in your computer for the JavaScript project that you have. Developers are always recommended to do a fresh install with npm install each time they downloaded a JavaScript project into their computer.


1 Answers

Since Copy and Publish Build Artifacts task is deprecated now, you’d better use Copy Files task and Publish Build Artifacts task instead. And these two tasks can help you exclude node_modules folder from publishing to server. Detail settings as below:

Copy Files task

Source Folder: $(Build.SourcesDirectory)

Contents:

**\**
!**\node_modules\**

Target Folder: $(build.artifactstagingdirectory)

enter image description here

Publish Build Artifacts task

Publish Build Artifacts task: $(build.artifactstagingdirectory)

Artifact Name: drop

enter image description here

like image 62
Marina Liu Avatar answered Sep 23 '22 14:09

Marina Liu