Modify existing files without losing content on nuget package update

Topics: General
May 29, 2013 at 9:41 PM
Edited May 29, 2013 at 9:45 PM
I have created nuget package which has the following Settings.config.transform file under contents folder:
<common>
<configurations>
  <SupportEmailorUrl>ReplaceMe@microsoft.com</SupportEmailorUrl>
<PrivacyUrl>http://www.ReplaceYourPrivacyWebUrlorInternalPageUrlHere.com/privacy</PrivacyUrl>
</configurations>
</common>
After doing the initial install of this package, NuGet will add this file in the solution since it didn’t exist previously. And they can change the SupportEmailorUrl and PrivacyUrl value in Settings.config file. Now when newer version of my nuget package is available, I do not want to lose modified SupportEmailorUrl and PrivacyUrl values on nuget package update and at the same time, I should be able to add new elements in config file.

Can anyone tell me how I can achieve above scenario?
Jun 4, 2013 at 1:20 AM
You can continue to use the same settings.config.transform file as above. If user has changed the values of those elements, NuGet won't override those values when updating to the new version of your package.
Jun 5, 2013 at 10:04 PM
I agree with you. It won't override modified values but still adds duplicate element in the config file. I had to change XML structure and customize install.ps1 script to remove duplicate elements. Please find below link for more information

http://www.fairwaytech.com/2013/03/nuget-config-file-transformation-causes-duplicate-entries-on-update/
Jun 5, 2013 at 10:11 PM
I see your point. The good news is that in the next 2.6 release, we'll support the XDT syntax, which would help you avoid adding duplicate element.
Jun 5, 2013 at 10:17 PM
Oh cool. Good to know.

I have one more issue with .config.transform file. Currently it is working fine when I install nuget package with Settings.config.transform file in Windows Store XAML applications. But in Windows Store JS apps, it is throwing "Object reference not set to an instance of an object." exception. After several trials, I found out I am able to install the same nuget with Settings.config file but not with
Settings.config.transform file.

Can you please tell me how can I resolve this?

Thanks in advance,
Jun 5, 2013 at 10:21 PM
Hmm, please file a bug for the exception. It'd be great if you could your package too.
Jun 5, 2013 at 10:34 PM
I filed a bug: https://nuget.codeplex.com/workitem/3380

Can you pelase tell me when can I expect any solution for this?