简体   繁体   English

VSTS将文件复制到:带变量的文件名

[英]VSTS copy files to : filenames with variables

I am configuring VSTS build and release process. 我正在配置VSTS构建和发布过程。

I have a scenario where I have DEV and QA environments. 我有一个具有DEV和QA环境的场景。 I have different config files for each of the environments, think of the naming convention Test.Dev.Config Test.QA.Config 对于每种环境,我都有不同的配置文件,请考虑命名约定Test.Dev.Config Test.QA.Config

In the "Copy files to" step of the build process, in the "contents" field, are you able to use the BuildConfiguration variable in order to tell the build process to copy the configuration files relevant to the BuildConfiguration: 在构建过程的“将文件复制到”步骤的“目录”字段中,您可以使用BuildConfiguration变量来告诉构建过程复制与BuildConfiguration相关的配置文件:

在此处输入图片说明

so that the output of the package contains the Test.DEV.config files for the Dev build step and the Test.QA.config file for the QA build step. 因此,程序包的输出包含用于Dev构建步骤的Test.DEV.config文件和用于QA构建步骤的Test.QA.config文件。

I am basically testing out a options for config transforms in VSTS 我基本上是在测试VSTS中的配置转换选项

Using a VSO variable combined with a string literal often doesn't work as expected within a task like File Copy . File Copy之类的任务中,将VSO变量与字符串文字结合使用通常无法正常工作。 Also, you don't want to do that in every task that requires build configuration specific config file. 另外,您不想在需要构建特定于配置的配置文件的每个任务中都这样做。 What you can do instead, is to have a separate variable in your build definition that derives from BuildConfiguration variable like so: 您可以做的是,在构建定义中有一个单独的变量,该变量是从BuildConfiguration变量派生的,如下所示:

Variable              Value
BuildConfigFile    *.$(BuildConfiguration).config

And then, within the File Copy task, you can directly use this variable as: 然后,在“ File Copy任务中,可以直接将此变量用作:

_PublishedWebsites\App_Config\$(BuildConfigFile)

For more details on defining one variable in terms of the other, refer this SO post. 有关根据另一个变量定义一个变量的更多详细信息,请参阅 SO帖子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM