2

I'm using TFS 2017, and regarding to title I found a term: Incremental build - but, I can not find out where to set it. I tried to add Incremental parameter in ' build parameters' (/p:IncrementalBuild=true) but always got error which says that this is wrong parameter. Is possible to deliver (or build and deliver) only changed files?

J. Ops
  • 51
  • 1
  • 6

2 Answers2

3

Lets assume how I solved this problem (if anyone has similar problem):

Since TFS 2017 always delivered all files - changed and unchanged, but I need only changed, I solved this as follows:

Since files that are transferred to Artifact keep timestamp (unchanged files have last_edited timestamp, and edited files have new, current timestamp) I decide to create FIXED Artifact directory (not depending on build version, but always the same). Then I wrote PowerShell script (as a first Release step ) which deletes all files (recursive) which have timestamp that is < (Now - x min), and all empty directories after that. On this way Artifact directory contains of ONLY CHANGED files (entire file structure (of changed files) is kept). Now Release will deliver only these files to destination.

Cheers! :)

J. Ops
  • 51
  • 1
  • 6
  • I like your solution. It is very smart. Although I think there is a lope hole for that and that is when you add an existing file to your project (like existing font or image with old date). – Barsham Jan 29 '20 at 06:19
  • That's sounds very cool, but what happened when a PR is taking too long? and It triggers the same build again and again for lets say, a week? – Ori Wiesel Dec 20 '20 at 11:39
  • The main problem I see with this approach would be *deleted files* that existed in previous deployments but are not longer needed in new deployments. – grek40 Apr 20 '21 at 11:21
2

If you want to have an incremental build. When you add a Visual Studio Build / MSBuild task to build the project, just uncheck the Clean option. Thus it will sync the source and only get the changed files from the second time to build. See Build task Arguments for details.

Clean Option : Set to False if you want to make this an incremental build. This setting might reduce your build time, especially if your codebase is large. This option has no practical effect unless you also set Clean repository to False.

Set to True if you want to rebuild all the code in the code projects. This is equivalent to the MSBuild /target:clean argument.

Assuming you want to deliver the only changed files to a specific location, you can add a Copy Files step to copy the changed files to the location.

enter image description here

Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55
  • Thank, Andy-MSFT! I will try it now. – J. Ops Aug 11 '17 at 07:46
  • @J.Ops Have you resolved your issue by the solution? any update? – Andy Li-MSFT Aug 14 '17 at 03:13
  • Andy-MSFT, I didn't solve this problem on way you provide - TFS always delivered all files - changed and unchanged. Last night I solved this as follows: Since files that are transferred to Artifact keep timestamp (unchanged files have last_edited timestamp, and edited files have new, current timestamp) I decide to create FIXED Artifact directory (not depending on build version, but always the same) and write PowerShell script which deletes all files (recursive) which have timestamp < (Now - x min), then deletes all empty directories. – J. Ops Aug 15 '17 at 07:58
  • Now artifact folder contains ONLY edited files (and their directories -> unchanged file structure). Release step will now deliver ONLY edited files (that is, to say, all files in artifact). – J. Ops Aug 15 '17 at 07:58
  • @AndyLi-MSFT any further direction on this 3 years later? The closest thing I can find is this article: https://oshamrai.wordpress.com/2020/01/31/create-the-delta-package-with-azure-devops-pipeline-and-git/ which helps, but still doesn't fit for general website, good old html content. Thanks ahead of time. – one.beat.consumer Aug 26 '20 at 01:09