从 Visual Studio 团队服务部署时复制目标目录中的一个文件 [英] Copy one file in target directory on deploy from visual studio team services

查看:14
本文介绍了从 Visual Studio 团队服务部署时复制目标目录中的一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 VSTS 作为构建服务器,在构建时我想将 bin 文件夹内容复制到目标的根目录,并将自定义文件从另一个文件夹复制到此目标.MSDN 建议我使用 minimatch 模式,但它正在复制具有子目录结构的文件.我对恢复结构不感兴趣.

I'm using VSTS as a build server, and while building I want to copy the bin folder contents to the root of the target, and also custom files from another folder to this target. MSDN suggests I use a minimatch pattern, but it's copying files with the subdirectory structure. I'm not interested in restoring the structure.

例如,我得到这个文件夹结构:

For example, I am getting this folder structure:

Project
    MyProjectFiles
    bin
        x86 (it's build configuration)
            Project.exe
    Other project files
    Project.sln
SomeScrips
    script1.ps1

但我想收到这个文件夹结构:

But I want to receive this folder structure:

Project.exe
SomeScripts
    script.ps1

我可以使用哪种 minimatch 模式来满足我的要求?

Which minimatch pattern can I use for my requirements?

推荐答案

使用基于 Web 的新构建系统,您可以在一个步骤中使用多个模式.因此,您可以为您的案例执行以下操作:

With the new web based build system you can use multiple patterns in a single step. Therefore you can do something like this for your case:

Projectinx86Releaseproject.exe
SomeScripts***

或者,如果您在构建步骤中使用的变量(例如 BuildPlatform/BuildConfiguration)中有构建平台和配置,则可以在构建步骤中使用它们模式:

Or if you have the build platform and configuration in a variable (eg. BuildPlatform / BuildConfiguration) which you also use in the build step you could use them in the pattern:

Projectin$(BuildPlatform)$(BuildConfiguration)project.exe
SomeScripts***

如果您希望 project.exe 位于根目录而不是结构中,您需要先使用 Copy Task 将文件暂存为所需结构.您可以使用 $(Build.StagingDirectory) 作为目标.然后使用 Publish 任务和 $(Build.StagingDirectory) 作为复制根并将所有内容从这个根发布到 drop.

If you want the project.exe to be in the root instead of the structure you need to use a Copy Task to stage your files in the desired structure first. You can use $(Build.StagingDirectory) as a target for this. Afterwards use the Publish task with $(Build.StagingDirectory) as copy root and publish everything from this root to the drop.

这篇关于从 Visual Studio 团队服务部署时复制目标目录中的一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆