可以通过 TFS 替换 config.properties 文件的值吗?

Possible to replace values of a config.properties file via TFS?

是否可以通过 TFS 替换 config.properties 文件的值?

我需要通过 MS TFS 更改 config.properties 文件的值,是否可以使用 TFS 中的变量替换值?

示例:我的自动化框架存储在 TFS 中,并有一个中央配置文件,其值如下:

browser=chrome
url=https://www.google.com 

我能否将这些值集中在 TFS 中,例如使用 TFS 中包含的变量将浏览器替换为 firefox。

是的,您可以,只需使用替换令牌任务作为上面的屏幕截图。例如:

假设您有一个包含以下内容的文件:

<?xml version="1.0" encoding="utf-8"?>
<parameters>
  <setParameter name="IIS Web Application Name" value="__SiteName__" />
</parameters> 

This file contains a token called "SiteName".

Drop the Task into the build or release, and then set the Target File to the path where the file is. Then set a global variable or an environment variable called "SiteName" and give it the value you want the token to be replaced with.

环境变量应该使用令牌的名称而不使用令牌标识符。

TFS 版本中有两级变量。它们可以在 Release(全局 - 适用于所有环境)或 Environment(在为环境设置的变量中)中定义。有关发布管理中变量的更多信息,请参阅此 tutorial

您还可以查看此 blog 以逐步了解如何替换配置文件中的标记。