9

I am working on an ASP.NET project in Visual Studio .NET 2010 and attempting to make an MSI installer using a Web Setup Project. I added the Primary output from the project (which seems to pull in the relevant dependencies) and the Content Files from the project (which pulls in the Web.config and the .svc files).

The issue is that rather than applying the XDT transform and creating the Web.config using the Web.Release.config, it just copies the Web.config, the Web.Release.config, and the Web.Debug.config into the installer without doing any transformation at all.

How do I get it to apply the Web.config transformation before creating the installer?

Ryan M
  • 18,333
  • 31
  • 67
  • 74

3 Answers3

18

I found a workaround that works for me:

  1. Create needed configurations (Dev,QA,Production etc.) and associated web config transformations.

  2. Use notepad or other text editor and include following in your web application project file (.csproj file) before tag (near the end of the project file):

    <Target Name="AfterBuild">
      <TransformXml Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="Web.Transformed.config" />
    </Target>
    

    Do not include Web.Transformed.config in the web application project - if you do visual studio will alert you about the changes after every build which is pretty annoying.

  3. In the web setup project: select Content files - > Exclude Filter and add Web.config (and all other Web.*.config files containing transformation rules).

  4. In the web setup project: select file system editor icon -> web application folder -> Add File and select Web.Transformed.config in the root of your web application project folder.

  5. In the same screen: right click Web.Transformed.config and rename it to Web.config

Now you are able to generate .msi files with selected configuration and root web.config file is transformed! Please note that this does not affect web.config files in the sub folders.

fre0n
  • 1,885
  • 1
  • 20
  • 26
  • I can confirm that this method works. It's also detailed at the end of this post: http://forums.asp.net/p/1596387/4050004.aspx – Tim Partridge Feb 23 '12 at 14:10
  • In the point 2 you are advising not to add Web.Transformed.config but in point 4 you are asking to add Web.Transformed.config file. Both the points are contradicting each other or else I am missing something. Can anyone help me to understand the steps in details. – santosh kumar patro Aug 26 '13 at 12:49
  • @santoshkumarpatro The difference is web application project vs. web setup project. For point 2, you want to *exclude* Web.Transformed.config from the *web application project*. For point 4, you want to *include* Web.Transformed.config in the *web setup project*. – fre0n Aug 26 '13 at 15:35
1

The answer ended up being located on another SO post which I missed when I was searching through before asking because it wasn't exactly what I wanted:

MSBuild Script and VS2010 publish apply Web.config Transform

A co-worker suggested using that to place the transformed Web.config in the project's bin directory and a Web Setup Project configured to grab the Web.config out of the bin directory and put it in the installer. This ended up being the most workable solution without installing any add-ons into Visual Studio.

Community
  • 1
  • 1
Ryan M
  • 18,333
  • 31
  • 67
  • 74
0

You have to make a deployment project (I think this is a separate download), then your Web Setup project take the precompiled output of the deployment project as it input. One neat thing is that you can have it change a section of your Web.config when it builds.

JBrooks
  • 9,901
  • 2
  • 28
  • 32
  • 1
    This might be the answer; however, I don't have administrator privileges (as it is a work computer) so I can't test it to be sure.\ I ended up adding an entry into the .csproj file to perform the transform - I'll post the details soon. – Ryan M Jul 08 '10 at 15:51