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?
If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).
An application can execute without a web. config file, however, you cannot debug an application without a web. config file.
config file is located in the %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ folder. The default settings that are contained in the Machine.
I found a workaround that works for me:
Create needed configurations (Dev,QA,Production etc.) and associated web config transformations.
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.
In the web setup project: select Content files - > Exclude Filter and add Web.config (and all other Web.*.config files containing transformation rules).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With