VS 2010 Automation Publishing Replacing Config Files

I am using the Publish configuration file replacement feature in Visual Studio 2010, as described in this article . I want to automate this using MSBuild / Hudson. Does anyone know how to do this?

I like the way it works, but if I cannot automate it, I will have to switch to XmlMassUpdate or the like.

+7
visual-studio-2010 hudson msbuild
source share
3 answers

Description

To convert your configuration file, you need to fulfill the TransformWebConfig target.

This target takes two Web.config and Web.$(Configuration).config and generates Web.config . The generated file is a converted version of the source for the current configuration.

This file is created in the folder: obj\$(Configuration)\TransformWebConfig

Using

You really do not explain what you want to achieve, therefore the main use here is the task that generates the converted configuration file in this folder.

Add the following snippet to the end of the *.csproj project file after importing 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> 

In Hudson, you can add an assembly step to your assembly or create a task configured as follows:

  • MsBuild assembly file: Your csproj file.
  • Command-line arguments: /t:ConfigSubstitution /p:Platform=AnyCpu;Configuration=Test;TransformedWebConfigDestination=DestinationFolder
+5
source share

Edit .csproj web project

under

 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> 

Add -
<UseMsDeployExe>True</UseMsDeployExe>

Look at the output of the assembly (make sure that VS Tools - Options - Project and Solutions -Build and Run - Multipage MSBuild output - Detailed)

You should be able to see the msdeploy commands used by VS to create the package. I understand that VS actually uses the Pipeline API and .target to actually create deployment packages when created using MSBuild, and this command uses MsDeploy instead.

This material needs documentation, it is very disappointing.

+3
source share

I use this in Hudson to configure Release:

 / Property: Configuration = Release

Exact settings:

 Build
 MSBuild Version: msbuild-4 (configured to point to v4 msbuild)
 MsBuild Build File: project_name.sln
 Command Line Arguments: / Property: Configuration = Release

You can test this in your project directory by doing something similar (since your version of the .NET platform may be different):

%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319\msbuild project.sln /Property:Configuration=Release

+1
source share

All Articles