我使用的是Visual Studio2010的“发布”功能的配置文件替换功能,如in this article所述。我想使用MSBuild/Hudson自动执行此操作。有人知道怎么做吗?
我喜欢它的工作方式,但如果我不能自动化它,我将不得不切换到XmlMassUpdate或类似的。
发布于 2010-06-11 21:21:12
解释
要转换配置文件,您必须执行TransformWebConfig目标。
这个目标获取两个文件Web.config和Web.$(Configuration).config并生成一个Web.config。生成的文件是当前配置的原始文件的转换版本。
此文件在文件夹obj\$(Configuration)\TransformWebConfig中生成
用法
您并没有真正解释您想要实现什么,所以这里只是一个基本用法,即在给定文件夹中生成转换后的配置文件的作业。
在导入Microsoft.WebApplication.targets之后,将以下内容添加到项目文件*.csproj的末尾
<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中,您可以在构建中添加构建步骤,或者创建如下配置的专用作业:
Your csproj file.
/t:ConfigSubstitution /p:Platform=AnyCpu;Configuration=Test;TransformedWebConfigDestination=DestinationFolder
发布于 2010-06-09 19:28:41
编辑您的web project.csproj
在……下面
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">添加-
<UseMsDeployExe>True</UseMsDeployExe>
查看构建输出(确保VS工具-选项-项目和解决方案-Build & Run - MSBuild输出详细信息-详细)
您应该能够看到msdeploy命令和生成包的用法。据我所知,在使用MSBuild构建时,VS实际上使用Web Platform Pipeline API和.target文件来实际生成deploy包,并且此命令改为使用MsDeploy。
这些东西非常需要文档,非常令人沮丧。
https://stackoverflow.com/questions/2977279
复制相似问题