Previously publishing my web api app was working perfectly. Today i converted my app from being \"any cpu\" to x86. Now when i\'m publishing its adding a connection string t
Edit project .csproj file and add this:
<PropertyGroup>
<InsertAdditionalWebCofigConnectionStrings>false</InsertAdditionalWebCofigConnectionStrings>
It worked for me.
The solution that worked for me, although it's more of a hack, was using the web deploy transformations to remove rogue connection string. See user2395249 answer:
One-click publish in vs 2012: how to remove _ConnectionStringsToInsert?
In the .pubxml file there where some extra connectionstrings added for some reason. Remove all of them and it should work fine, the default connectionstring will still be added.
I have a hunch that this has been added to the .pubxml when I fiddled a little with my publishing information but it wasn't removed when I switched back to my regular publish setup.
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)DefaultConnection-Web.config Connection String" />
<MSDeployParameterValue Include="$(DeployParameterPrefix)MyProject-Web.config Connection String" />
<MSDeployParameterValue Include="$(DeployParameterPrefix)MyProject_dev-Web.config Connection String" />
</ItemGroup>
<ItemGroup>
<_ConnectionStringsToInsert Include="MyProject" />
<_ConnectionStringsToInsert Include="Myproject_dev" />
</ItemGroup>
Add this project property to the .csproj file by editing the XML:
<Project>
<PropertyGroup>
<AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings>
...
</PropertyGroup>
...
</Project>
Alternatively, use a Web Publishing Pipeline targets file as described in this related StackOverflow question.