I am using externalized config section for appsettings, to be able to have different ones per developer, like so:
<appSettings configSource="appsettings.config" />
When I run mstest against this project (it’s a web application), it blindly modifies this section like so:
<appSettings configSource="appsettings.config">
<add key="microsoft.visualstudio.teamsystems.backupinfo" value="1;web.config.backup.af6ed449-e04a-4a52-99d6-b8df0b133316" />
<add key="microsoft.visualstudio.teamsystems.aspnetdevserver:/" value="56917;True;3448;1;-8588944684513929784" />
</appSettings>
Which is obviously wrong, even according to schema.
The reason it needs to modify this is to specify the information about Cassini/dev server that it’s going to run. I think that’s it, it doesn’t seem to modify any other section in the file (very hard to tell since it also completely reformats the file).
Question is, what choices do I have to get this to work?
So far I only came up with two practical ones, both sub-optimal
-
Abandon external config for appsettings
-
Switch from Cassini to cassinidev – then I can stop using
[AspNetDevelopmentServer()]
attribute, which is the one that
results in web.config needing to be
modified -
Configure something in VS to prevent it from doing this. Why does
it even care which port its own
cassini is working on? I couldn’t
find any config settings. -
Wait for MS to fix this, so [AspNetDevelopmentServer()] would
work with externalized appSettings
Bit of a delay, so I don’t know if this is still relevant for you….
But you can use the
file=attribute of<appSettings>instead ofconfigSource.I.e:
While
configSourceexpects to just replace the entire section,filemerges the sections. So even if you have child elements added, it will still add the additional elements from the external file.