private static Configuration GetUserConfig(Project project, string assemblyFullName)
{
DebugCheck.NotNull(project);
var userConfigFilename
= Path.Combine(
(string)project.Properties.Item("FullPath").Value,
project.IsWebProject()
? "Web.config"
: "App.config");
var document = XDocument.Load(userConfigFilename);
FixUpConfig(document, assemblyFullName);
var tempFile = Path.GetTempFileName();
document.Save(tempFile);
return(ConfigurationManager.OpenMappedExeConfiguration(
new ExeConfigurationFileMap {
ExeConfigFilename = tempFile
},
ConfigurationUserLevel.None));
}