Setting web.config properties during build (not through publishing)

I am trying to deploy an application using a web setup project. The problem I am facing is that the web.config file never converts. According to this post, its design does the conversion only at the time of publication. How can I correctly update the properties of web.config if building an installation project in turn invokes a build command for other assemblies?

+6
source share
2 answers

I fixed this by adding a dummy web.Template.config file, such as Andriy K, suggested in this post , and then calling TransformXml during my BeforeBuild event, for example:

<Target Name="BeforeBuild"> <TransformXml Source="$(WebFolderName)Web.Template.config" Transform="$(WebFolderName)Web.$(Configuration).config" Destination="$(WebFolderName)Web.config" /> </Target> 
+5
source

The easiest option is to install the xslt command-line utility and run it during the subsequent build of your project. You can also use one of the many MSBuild XSLT tasks and add it to your .csproj file. (This is just an MSBuild script file, there are comments already at the bottom below explaining how to configure the assembly.)

You can also perform any of these steps in the pre-project operation of your installation project, and not after creating your web application. If you also use the publish wizard, this second option might work better, since it will not interfere with the normal XSLT transformation that happens in the publisher.

Microsoft XSLT Command Line Utility: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=2fb55371-c94e-4373-b0e9-db4816552e41&displaylang=en

Example MSBuild XSLT task: http://www.arlt.eu/blog/2007/10/01/msbuild-xslt-task/

+2
source

Source: https://habr.com/ru/post/887460/


All Articles