I have a package which applies app.config transformations upon project. Transform file looks like this
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="handlerId" value="$assemblyname$"/> <!--populate from project params-->
<--other params-->
</appSettings>
</configuration>
The case is: add package to a new project with no app.config, manually update app.config in project, and then update package.
If I include app.config.transform to my package nuget creates app.config in project, but if i change value of one of parameters and update/reinstall package it creates copy of that parameter with value of package instead of skipping it.
For example: Installed package upon clean project
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="handlerId" value="MyApp"/>
</appSettings>
</configuration>
Then changed handlerId value to MyApp1
and update package. The result of transformation is
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="handlerId" value="MyApp1"/>
<add key="handlerId" value="MyApp"/> <!--shouldn't appear!-->
</appSettings>
</configuration>
I tried to use xdt transformations instead. They work great upon package updating or installing package on project with app.config, but if there is no app.config nuget doesn't create it.