parameters.xml

时间:2017-08-01 19:33:32

标签: tfs web-deployment tfsbuild microsoft-web-deploy

我有一个IIS托管Web应用程序的parameters.xml文件(适用于javascript,HTML和CSS文件)。 为了创建一个Continues Deployment序列,我阅读了有关创建发布配置文件,使用令牌对其进行标记以及通过TFS(On-Prem)进行构建和发布,标记化并发布我的Web应用程序的内容。 问题是我在客户端站点应用程序中有一个javascript配置文件。我希望能够使用已经创建的管道中的标记对其进行编辑。

我的参数xml如下:

<parameters>
  <parameter name="DebugOption"
    description="Some debug option."
    defaultValue="false">
  <parameterEntry  
    kind="TextFile" 
    scope="config.js" 
    match="debugOption = true" />
  </parameter>
</parameters>

如您所见,我匹配字符串“debugOption = true”。 我想要实现的只是将 true 更改为 false ,但在TFS中的tokenizer任务中,如果我将$(DebugOption)设置为false,则将所有字符串替换为false - 具体而言,它将“debugOption = true”替换为“false”,这不是我想要的最终结果。

是否可以匹配这种字符串(我不能仅匹配true,因为它将替换javascrip文件中的所有'true'出现),并且只更改值,而不给出值“debugOption” = false“ - 只有假?

2 个答案:

答案 0 :(得分:0)

更新无法实现。只需提供错误即可将debugMode=true替换为debugMode=false;匹配器不知道哪个部分需要更换。

如果您在Tokenization Task

中使用Release Management Utility tasks或Tokenizer任务
This task finds the pattern __<pattern>__ and replaces the same with the value from the variable with name <pattern>.
Eg. If you have a variable defined as foo with value bar,
on running this task on a file that contains __foo__ will be changed to bar.

绕过匹配整个字符串而不是每个标记化字符串。您需要稍微更改RegEx以使其选择不贪婪。

$regex = '__[A-Za-z0-9._-]*?__'

更多详情请参阅此问题:Tokenization based pattern replacement in web.config.token

答案 1 :(得分:0)

如果不能替换部分字符串,为什么不用替换整个单词。即在这里你想为debugOption设置false,所以在release部分中将变量设置为$(DebugOption)= debugOption = false。

我希望这会奏效。

由于