gpt4 book ai didi

visual-studio-2010 - 自动化 VS 2010 "Publish"配置文件替换

转载 作者:行者123 更新时间:2023-12-04 11:31:22 25 4
gpt4 key购买 nike

我正在使用 Visual Studio 2010 的“发布”功能的配置文件替换功能,如 in this article 所述.我想使用 MSBuild/Hudson 自动执行此操作。有人知道怎么做这个吗?

我喜欢它的工作方式,但如果我不能自动化它,我将不得不切换到 XmlMassUpdate 或类似的。

最佳答案

解释

要转换您的配置文件,您必须执行 TransformWebConfig目标。

这个目标需要两个文件 Web.configWeb.$(Configuration).config并生成 Web.config .生成的文件是当前配置的原始文件的转换版本。

此文件在文件夹中生成:obj\$(Configuration)\TransformWebConfig
用法

您并没有真正解释您想要实现的目标,所以这里有一个基本用法,即在给定文件夹中生成转换后的配置文件的作业。

在项目文件的末尾添加以下部分 *.csproj导入后Microsoft.WebApplication.targets

<PropertyGroup>
<!-- Directory where your web.config will be copied -->
<TransformedWebConfigDestination>$(MSBuildProjectDirectory)</TransformedWebConfigDestination>
</PropertyGroup>

<!--
This target transforms the web.config based on current configuration and
put the transformed files in $(TransformedWebConfigDestination) folder
-->
<Target Name="ConfigSubstitution">
<CallTarget Targets="TransformWebConfig"/>

<ItemGroup>
<TransformedWebConfig Include="obj\$(Configuration)\TransformWebConfig\Web.config"/>
</ItemGroup>

<!-- Copy the transformed web.config to the configured destination -->
<Copy SourceFiles="@(TransformedWebConfig)"
DestinationFolder="$(TransformedWebConfigDestination)"/>
</Target>

hudson 您可以在构建中添加构建步骤,或创建一个配置如下的专用作业:
  • MsBuild 构建文件:Your csproj file.
  • 命令行参数:/t:ConfigSubstitution /p:Platform=AnyCpu;Configuration=Test;TransformedWebConfigDestination=DestinationFolder
  • 关于visual-studio-2010 - 自动化 VS 2010 "Publish"配置文件替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2977279/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com