Excluding files/folders from VSTS publish
Asked Answered
M

5

19

We are using the new VSO/VSTS style build within TFS on premise, 2015 Update 1 as of yesterday.

During the publish build artifacts stage we want to copy all the files/folders from a root bar 2 sub folders.

ie:

$\somefilestopublish1\...
$\somefilestopublish2\...
$\somefilestoexclude1\...
$\somefilestoexclude2\...

Currently I have **\* as the contents argument which obviously will publish everything. I have tried appending ;-:<exclude_pattern> as suggested by a Google search but that just stopped all output and resulted in an empty folder.

Is there a way to use the minimatch expression to exclude folders or will I need to swap to explicitly selecting the folders to publish instead.

Midship answered 2/12, 2015 at 11:45 Comment(0)
I
16

Minimatch use "!" to exclude the given pattern. You could specify it with following format:

!(somefilestoexclude1|somefilestoexclude2)

Following is the example: With !(bin|obj), "bin" folder and "obj" folder under "WindowsFormsApplication1" folder are not copied to artifact. enter image description here

Irradiant answered 3/12, 2015 at 5:52 Comment(5)
Could you give an example? I'm till struggling with this: I have : !(_build|$tf)/* but I'm still coping the $tf and _build folders into my drop.Midship
@Midship I just create a sample and add the screenshot in the answer, please refer to it for details.Irradiant
@Eddie-MSFT How would this work for ignoring certain file types. Like .pdb and .xml?Eb
@Thomas Refer to this link: msdn.microsoft.com/en-us/Library/vs/alm/Build/steps/utility/…Irradiant
Using **\!($tf) to copy everything except the $tf folder doesn't work in tfs2017.1.Tatterdemalion
Z
1

!/$tf/** works for me. I've opted to shorten that to !/$*/**

http://www.globtester.com/ helped. The $ symbol doesn't have to be escaped despite conflicting guidance on msdn: https://msdn.microsoft.com/en-us/library/bb383819.aspx.

Zeke answered 17/2, 2016 at 7:38 Comment(5)
You don't need to @ping the OP. He'll find out there's an answer anyway (and I think it only works from comments).Heavyarmed
@Heavyarmed I intended to add a comment, but lack the reputation.Zeke
@piet.t I don't follow your point. The essential part of the answer is that /!($tf)/** worked for me. The 2 links augment (but are not essential to) the answer. That said, as it turns out, /!($tf)/** isn't including files in the root folder so I'm still searching for a better minimatch pattern.Zeke
!/$tf/** is the best solution I've found, and I've opted to shorten that to: !/$*/**Zeke
@JasonVercellone Do you have to combine this with something else to copy everything except the $tf folder?Tatterdemalion
S
1

Suppose you want to collect all the *.nupkg files in your solution (for instance the ones you create during build) and copy them to another folder, but you want to exclude the ones you get through the package restore, you need to specify the following:

**\*.nupkg !packages\**

It's important to specify them in this order. Placing the exclusion on the packages folder on top, will result in the Copy task copying all the *.nupkg files.

Suzannsuzanna answered 11/12, 2017 at 13:36 Comment(0)
C
0

This worked for me for folder try this !**\Uploads*** For file **!(Web.config)

Above example is for excluding a folder and file available in same folder path.

Checkoff answered 17/2, 2017 at 14:7 Comment(0)
S
0

On TFS 2017 Update 1 if you are using the Copy Files task and you want to copy all files from the $(Build.SourcesDirectory) but exclude the $tf folder what I found to work was the following.

In the Contents text box enter the following two lines.

**\*
!$tf\**

This post on social.msdn.microsoft.com is what helped me figure this out.

Suspender answered 5/12, 2017 at 15:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.