@@ -34,18 +34,12 @@ namespace Our.Umbraco.FileSystemProviders.Azure.Installer
3434
3535 public class InstallerController : UmbracoAuthorizedApiController
3636 {
37- private static readonly string ImageProcessorWebAssemblyPath = HostingEnvironment . MapPath ( Constants . ImageProcessor . WebAssemblyPath ) ;
38- private static readonly Version ImageProcessorWebMinRequiredVersion = new Version ( Constants . ImageProcessor . WebMinRequiredVersion ) ;
39-
4037 private static readonly string ImageProcessorConfigPath = HostingEnvironment . MapPath ( Constants . ImageProcessor . ConfigPath ) ;
4138
4239 private static readonly string ImageProcessorSecurityConfigPath = HostingEnvironment . MapPath ( $ "{ Constants . ImageProcessor . ConfigPath } { Constants . ImageProcessor . SecurityConfigFile } ") ;
4340 private static readonly string ImageProcessorSecurityDefaultConfigPath = HostingEnvironment . MapPath ( $ "{ Constants . InstallerPath } { Constants . ImageProcessor . SecurityConfigFile } ") ;
4441 private static readonly string ImageProcessorSecurityInstallXdtPath = HostingEnvironment . MapPath ( $ "{ Constants . InstallerPath } { Constants . ImageProcessor . SecurityConfigFile } .install.xdt") ;
4542
46- private readonly string fileSystemProvidersConfigInstallXdtPath = HostingEnvironment . MapPath ( $ "{ Constants . InstallerPath } { Constants . FileSystemProvidersConfigFile } .install.xdt") ;
47- private readonly string fileSystemProvidersConfigPath = HostingEnvironment . MapPath ( $ "{ Constants . UmbracoConfigPath } { Constants . FileSystemProvidersConfigFile } ") ;
48-
4943 private readonly string webConfigXdtPath = HostingEnvironment . MapPath ( $ "{ Constants . InstallerPath } { Constants . WebConfigFile } .install.xdt") ;
5044 private readonly string webConfigPath = HostingEnvironment . MapPath ( $ "/{ Constants . WebConfigFile } ") ;
5145
@@ -107,18 +101,11 @@ public InstallerStatus PostParameters(IEnumerable<Parameter> parameters)
107101 SaveBlobPathToImageProcessorSecurityXdt ( ImageProcessorSecurityInstallXdtPath , rootUrl , routePrefix , containerName ) ;
108102
109103 // Transform ImageProcessor security.config
110- if ( ExecuteImageProcessorSecurityConfigTransform ( ) )
111- {
112- if ( ! ExecuteImageProcessorWebConfigTransform ( ) )
113- {
114- return InstallerStatus . ImageProcessorWebConfigError ;
115- }
116- }
117- else
104+ if ( ! ExecuteImageProcessorSecurityConfigTransform ( ) )
118105 {
119106 return InstallerStatus . ImageProcessorWebConfigError ;
120- }
121-
107+
108+ }
122109
123110 return InstallerStatus . Ok ;
124111 }
@@ -153,6 +140,13 @@ internal static bool SaveParametersToWebConfigXdt(string xdtPath, IList<Paramete
153140 return false ;
154141 }
155142
143+ var removeNodesExist = false ;
144+ var removeNodes = document . SelectNodes ( $ "//appSettings/add[@xdt:Transform='Remove']", nsMgr ) ;
145+ if ( removeNodes != null && removeNodes . Count > 0 )
146+ {
147+ removeNodesExist = true ;
148+ }
149+
156150 XmlNodeList settings = document . SelectNodes ( $ "//appSettings/add") ;
157151 if ( settings == null )
158152 {
@@ -175,22 +169,24 @@ internal static bool SaveParametersToWebConfigXdt(string xdtPath, IList<Paramete
175169 }
176170 }
177171
178- //XmlNode settingRemoveElement = document.CreateNode("element", "add", null);
179-
180- //XmlAttribute keyAttr = document.CreateAttribute("key");
181- //keyAttr.Value = setting.GetAttribute("key");
182- //settingRemoveElement.Attributes.Append(keyAttr);
172+ if ( ! removeNodesExist )
173+ {
174+ XmlNode settingRemoveElement = document . CreateNode ( "element" , "add" , null ) ;
183175
184- // XmlAttribute locatorAttr = document.CreateAttribute("Locator", strNamespace );
185- //locatorAttr .Value = "Match( key)" ;
186- // settingRemoveElement.Attributes.Append(locatorAttr );
176+ XmlAttribute keyAttr = document . CreateAttribute ( "key" ) ;
177+ keyAttr . Value = setting . GetAttribute ( " key" ) ;
178+ settingRemoveElement . Attributes . Append ( keyAttr ) ;
187179
188- // XmlAttribute transformAttr = document.CreateAttribute("Transform ", strNamespace);
189- //transformAttr .Value = "Remove ";
190- // settingRemoveElement.Attributes.Append(transformAttr );
180+ XmlAttribute locatorAttr = document . CreateAttribute ( "Locator " , strNamespace ) ;
181+ locatorAttr . Value = "Match(key) " ;
182+ settingRemoveElement . Attributes . Append ( locatorAttr ) ;
191183
192- //providerElement.InsertBefore(settingRemoveElement, setting);
184+ XmlAttribute transformAttr = document . CreateAttribute ( "Transform" , strNamespace ) ;
185+ transformAttr . Value = "Remove" ;
186+ settingRemoveElement . Attributes . Append ( transformAttr ) ;
193187
188+ providerElement . InsertBefore ( settingRemoveElement , setting ) ;
189+ }
194190 }
195191
196192 try
@@ -446,21 +442,6 @@ private static bool ExecuteImageProcessorSecurityConfigTransform()
446442 return true ;
447443 }
448444
449- private static bool ExecuteImageProcessorWebConfigTransform ( )
450- {
451- XmlNode transFormConfigAction =
452- ParseStringToXmlNode ( "<Action runat=\" install\" "
453- + "undo=\" false\" "
454- + "alias=\" UmbracoFileSystemProviders.Azure.TransformConfig\" "
455- + "file=\" ~/web.config\" "
456- + "xdtfile=\" ~/app_plugins/UmbracoFileSystemProviders/Azure/install/imageprocessor.web.config\" >"
457- + "</Action>" ) . FirstChild ;
458-
459- PackageActions . TransformConfig transformConfig = new PackageActions . TransformConfig ( ) ;
460- return transformConfig . Execute ( "UmbracoFileSystemProviders.Azure" , ToXElement ( transFormConfigAction ) ) ;
461- return true ;
462- }
463-
464445 private static bool TestAzureCredentials ( string connectionString , string containerName )
465446 {
466447 bool useEmulator = ConfigurationManager . AppSettings [ Azure . Constants . Configuration . UseStorageEmulatorKey ] != null
0 commit comments