I am currently attempting to modify my Wix(V3.5) installer to edit the Web.config settings of the .NET application i want to install. This is fine for normal ASP.NET applications but now im attempting to apply my Wix set up project to an Entity Framework .NET application , which as you may know has a more complicated Connection string setting with model .csdl and .ssdl settings.
So if my web.config connection string setting looks somehting like this :(where [DBSERVER] & [DBNAME] are properties retrived from a dialog )
<connectionStrings>
<add name="SSITacticalSolutionEntities" connectionString="metadata=res://*/Model.TacticalSolutionModel.csdl|res://*/Model.TacticalSolutionModel.ssdl|res://*/Model.TacticalSolutionModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=sd-sql2008r2;Initial Catalog=SsiTacticalSolution1.2.4;Integrated Security=True;MultipleActiveResultSets=True" />
</connectionStrings>
And i edit my Web.config in my Product.Wsx file with somehting like this :
<util:XmlFile Id="ModifyConnectionString" Action="setValue" Permanent="yes" File="[INSTALLLOCATION]Web.config"
ElementPath="/configuration/connectionStrings/add[\[]@name='!(loc.EntityName)'[\]]" Name="connectionString"
Value="Data Source=[DBSERVER];Initial Catalog=[DBNAME];Integrated Security=true;providerName=System.Data.EntityClient;MultipleActiveResultSets=True"" Sequence="5"/>
I get a connection string like this :
<connectionStrings>
<add name="SSITacticalSolutionEntities" connectionString="Data Source=sd-sql2008r2;Initial Catalog=SsiTacticalSolution1.2.4;Integrated Security=true;providerName=System.Data.EntityClient;MultipleActiveResultSets=True""/>
</connectionStrings>
Which of course makes sense , since im asking it to replace the current connection string attribute with what i have defined in the value.
But what i really need here is to edit specific parts of my connection string and leave the remainder (is there some sort of replace action i can use here) ,i.e. leave all my model settings in place and just replace the database server and name etc as i need to. I used to do this with the Visual Studio installers no problem and it was so easy to use.
So my question is can this be done using util.XMLFile , or perhaps util:XmlConfig ? I have tried both without any luck.
Or is this not possible to do with util.XMLFile and will i have to do this in a CustomAction instead ? Any ideas would be of great help , thanks in advance ...