Excluding files/folders from VSTS publish

2020-02-26 04:25发布

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.

5条回答
We Are One
2楼-- · 2020-02-26 05:00

!/$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.

查看更多
beautiful°
3楼-- · 2020-02-26 05:00

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.

查看更多
爷、活的狠高调
4楼-- · 2020-02-26 05:01

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

查看更多
Animai°情兽
5楼-- · 2020-02-26 05:05

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.

查看更多
Evening l夕情丶
6楼-- · 2020-02-26 05:15

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.

查看更多
登录 后发表回答