Eonasdan
Eonasdan

Reputation: 7765

Getting npm caching to work for a .net core angular project in azure devops

I have a client project that takes about 15 minutes to build an Angular 10/.Net Core project and I'm trying to get the caching task to work. I've tried several permutations of the configuration below but when I add eq(variables['CacheRestored'],False) as a run condition to the npm install task, the angular build task fails complaining about missing packages.

enter image description here

The project is setup as

.sln
xx.Web
   - ClientApp
     - package.json

The caching tasks seems like it's working:

enter image description here

Update:

For reference we are using "postinstall": "ngcc", so maybe the cache is working and it's the post install causing the slow down.

I've created a gist with a stripped version of the pipeline yaml, and a post cache error message the questions doesn't get super long.

I'd love to speed up Angular 10s slow build times, but I'm sure that's a totally different question.

Solution: @Walter's answer fixed one of the errors I was getting. Fixing the path, removing the quotes and pointing to the ClientApp folder, was what fixed it.

Our builds went from 15 minutes to 7 minutes!

I've updated my gist with a working yaml in case that helps someone in the future.

Upvotes: 0

Views: 997

Answers (1)

Walter
Walter

Reputation: 3048

According to your Pipe.yaml:

path: '"$(Build.SourcesDirectory)/xx.Web/ClientApp/node_modules"'

You need to remove the double quotes. The correct format should be:

path:'$(Build.SourcesDirectory)/xx.Web/ClientApp/node_modules'.

According to your post cache task log:

tar: /home/vsts/work/1/s/“/home/vsts/work/1/s/xx.Web/ClientApp/node_modulesâ€: Cannot open: No such file or directory

You can also see that your path of the folder to cache is incorrect. Please change your path in your cache task to

path: '$(Build.SourcesDirectory)/xx.Web/ClientApp/node_modules'.

Upvotes: 3

Related Questions