Weissvonnix
Weissvonnix

Reputation: 763

How do I force MSDeploy API to keep an existing Connectionstring?

We are deploying an ASP.Net application to IIS via MSDeploy API. We only want to update existing websites. In our ...pubxml we have defined following:

<ItemGroup>
  <MSDeployParameterValue Include="$(DeployParameterPrefix)ConnectionstringA-Web.config Connection String">
    <UpdateDestWebConfig>False</UpdateDestWebConfig>
  </MSDeployParameterValue>
  <MSDeployParameterValue Include="$(DeployParameterPrefix)ConnectionstringB-Web.config Connection String">
    <UpdateDestWebConfig>False</UpdateDestWebConfig>
  </MSDeployParameterValue>
</ItemGroup>

By default, the setParameters.xml created on publish, looks like this:

    <setParameter name="ConnectionstringA-Web.config Connection String" value="metadata=res://*/itrDTO.csdl|res://*/itrDTO.ssdl|res://*/itrDTO.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=devServer;initial catalog=devDB;User Id=devUser;Password=devPW;MultipleActiveResultSets=True;App=EntityFramework&quot;" />
    <setParameter name="ConnectionstringB-Web.config Connection String" value="data source=devServer;initial catalog=devDB;integrated security=True" />

I also tried to create a "Projectname.wpp.targets" with this configuration inside my project:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup>
    <AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings>
  </PropertyGroup>
</Project>

The result is that the connectionstrings are not created inside setparameters.xml.

However, all combinations of configurations here are changing the connectionstrings inside the web.config on the destinationserver. This happens if we import the package by the IIS-ManagementUI AND when we deploy the package by MSDeploy API.

All examples I've found for the "parameterization" - topic are for the IIS-Management process. As I understand parameterization, this is only usefull for manually installing updates, so that the admin has a UI to configure stuff. But we have no UI when we update the systems of our customers.

Update: When I Publish with Visual Studio, here is the funny result: enter image description here I think this means "Hey WebDeploy, keep your hands off the connection strings!"

When I preview the changes, this is the result: enter image description here

Upvotes: 1

Views: 1279

Answers (1)

chief7
chief7

Reputation: 14393

Parameterization is useful both through the IIS install UI and via the commandline. We use WebDeploy/Parameterization for the deployment of all our 40+ applications.

I just ran a test with a new blank ASP.NET application and found that by default the ConnectionString is parameterized but after setting the AutoParameterizationWebConfigConnectionStrings MSBUILD property to false it did not parameterize the ConnectionString. The parameter entry was removed from both the parameters.xml and SetParameters files.

I suggest you clear out your target website folder and republish with this property set.

Also double check that you don't have config transforms or something else that might be changing the config.

Upvotes: 2

Related Questions