I received the error below when using a Web Deployment Project to build and publish my Web Application locally:
“Microsoft.WebDeployment.targets(1024,9): error : The configuration file has been changed by another program.”
I was using Web configuration section replacements and so I figured it was to do with that:
I double checked the deployment project xml (right click project in Solution Explorer, Open Project File). It had duplicated the entries like the second ‘appSettings’ below, but even removing those didn’t sort it:
<ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<WebConfigReplacementFiles Include="config\appsettings-debug.config">
<Section>appSettings</Section>
<Section>appSettings</Section> <<<< DUPLICATE
</WebConfigReplacementFiles>
<WebConfigReplacementFiles Include="config\customerrors-debug.config">
<Section>system.web/customErrors</Section>
</WebConfigReplacementFiles>
</ItemGroup>
The Fix
I realised whilst the deployment project was set to copy the output to a local IIS folder I’d also done some debugging in situ i.e. in the project’s own folder. So I also had an entry in the web.config to ‘import’ the relevant configuration file like this:
<appSettings configSource="config\appsettings-debug.config" />
When I removed the link to the external file all was well again, leaving the entry in web.config like:
<appSettings />
NB I also had to disable “Enforce matching section replacements” which checks that the replacement section has the same number of entries as the existing one otherwise you get an error like this:
”web.config(11): error WDP00001: section appSettings in "web.config" has 0 elements but "config\appsettings-debug.config" has 2 elements”
No comments:
Post a Comment