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

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

问题描述

我将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

我可以使用哪种最小匹配模式?

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:

Project\bin\x86\Release\project.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:

Project\bin\$(BuildPlatform)\$(BuildConfiguration)\project.exe
SomeScripts\**\*

如果希望project.exe位于根目录而不是结构中,则需要先使用Copy Task将文件暂存到所需的结构中.您可以将$(Build.StagingDirectory)用作此目标.然后,使用$(Build.StagingDirectory)作为副本根目录使用Publish任务,并将所有内容从该根目录发布到下拉列表.

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 Team Services部署时在目标目录中复制一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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