Can NuGet edit a config file or only add to it?

The answer is NO From the nuget site I found the following answer.

The answer is NO. From the nuget site I found the following answer: "When NuGet merges a transform file into a project's configuration file, it only adds elements or adds attributes to existing elements in the configuration file; it does not change existing elements or attributes in any other way. " docs.nuget.org/docs/creating-packages/co....

Yes, that is correct. The transform engine does not cover all scenarios, though we may extend it in the future. – David Ebbo Aug 2 at 21:04.

NuGet transforms can't edit existing values. But NuGet lets you run Powershell scripts on package install, so you can edit the config file that way. Create an Install.

Ps1 file and use this code: # Install. Ps1 param($installPath, $toolsPath, $package, $project) $xml = New-Object xml # find the Web. Config file $config = $project.

ProjectItems | where {$_. Name -eq "Web. Config"} # find its path on the file system $localPath = $config.

Properties | where {$_. Name -eq "LocalPath"} # load Web. Config as XML $xml.

Load($localPath. Value) # select the node $node = $xml. SelectSingleNode("configuration/connectionStrings/add@name='gveconn'") # change the connectionString value $node.

SetAttribute("connectionString", "Data Source=. \;Initial Catalog=GVE;User ID=ex;Password=example") # save the Web. Config file $xml.

Save($localPath. Value).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions