12

我正在本地设置 TFS 2015,我在最后一个构建步骤 Publish Build Artifacts 中遇到了问题。出于某种原因,构建代理似乎正在归档旧的二进制文件,我留下了一个巨大的文件路径:

E:\TFSBuildAgent\_work\1a4e9e55\workspace\application\Development\project\WCF\WCF\obj\Debug\Package\Archive\Content\E_C\TFSBuildAgent\_work\1a4e9e55\workspace\application\Development\project\WCF\WCF\obj\Debug\Package\PackageTmp\bin

我正在使用示例 minimatch 模式复制文件,首先是:

**\bin

我目前只是在测试,所以这不是一个永久的解决方案,但我怎样才能复制bin文件夹中的所有二进制文件,但不是obj的后代?

从研究中我认为这应该有效,但它没有(它不匹配任何东西):

**!(obj)**\bin

我正在使用www.globtester.com进行测试。有什么建议么?

在单独的说明中,我稍后会研究存档问题,但如果有人对此有任何指示,请随时发表评论。谢谢

4

2 回答 2

13

在 VSTS 中,SDK 内置的 URL 有两种模式匹配。现在大多数任务都使用马特的回答中描述的 Minimatch 模式。但是,有些使用 1.x 代理的 Powershell SDK 使用的模式。顺便说一句,该格式在 2.x Agent 的 Powershell SDK 中仍然可用。

这意味着有 5 种任务:

  • 1.x 代理 - Powershell SDK
  • 2.x 代理 - 节点 SDK
  • 2.x 代理 - Powershell 1 向后兼容性
  • 2.x 代理 - Powershell 3 SDK - 使用find-files
  • 2.x 代理 - Powershell 3 SDK - 使用find-match

粗体字不是 Minimatch ,而是VSTS-Task-SDKfind-files方法中记录的格式。

最初的问题是在 2015 年发布的,当时 2.x 代理还没有出现。在这种情况下,模式很可能是:

 **\bin\$(BuildConfiguration)\**\*;-:**\obj\**

-:排除它前面的项目。

于 2015-08-25T12:35:57.793 回答
4

According to Microsoft's documentation, here is a list of file matching patterns you can use. The most important rules are:

Match with ?

  • ? matches any single character within a file or directory name (zero or one times).

Match with * or +

  • * or + matches zero or more characters within a file or directory name.

Match with @ sign

  • @ matches exactly once.

Match with Brackets (, ) and |

  • If you're using brackets with | it is treated as a logical OR, e.g. *(hello|world) means "Zero or more occurrances of hello or world"

Match with Double-asterisk **

  • ** recursive wildcard. For example, /hello/**/* matches all descendants of /hello.

Exclude patterns with !

  • Leading ! changes the meaning of an include pattern to exclude. Interleaved exclude patterns are supported.

Character sets with [ and ]

  • [] matches a set or range of characters within a file or directory name.

Comments with #

  • Patterns that begin with # are treated as comments.

Escaping

  • Wrapping special characters in [] can be used to escape literal glob characters in a file name. For example the literal file name hello[a-z] can be escaped as hello[[]a-z].

Example

The following expressions can be used in the Contents field of the "Copy Files" build step to create a deployment package for a web project:

**\?(.config|.dll|*.sitemap)
**\?(.exe|.dll|.pdb|.xml|*.resx)
**\?(.js|.css|.html|.aspx|.ascx|.asax|.Master|.cshtml|*.map)
**\?(.gif|.png|.jpg|.ico|*.pdf)

Note: You might need to add more extensions, depending on the needs of your project.

于 2017-07-19T08:32:08.353 回答