Skip to content

Commit 86238e9

Browse files
committed
Clean up and remove transforms no longer needed
1 parent b0de77d commit 86238e9

File tree

8 files changed

+26
-145
lines changed

8 files changed

+26
-145
lines changed

build/UmbracoFileSystemProviders.Azure.proj

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@
125125
<PdbFiles Include="$(ProjectDir)\bin\$(BuildConfig)\Our.Umbraco.FileSystemProviders.Azure.pdb" />
126126
<WebConfigXDTFiles Include="$(MSBuildProjectDirectory)\transforms\web.config.*.xdt" />
127127
<UmbPakWebConfigXDTFiles Include="$(MSBuildProjectDirectory)\transforms\umbpak-web.config.*.xdt" />
128-
<FileSystemProvidersConfigXDTInstallFile Include="$(MSBuildProjectDirectory)\transforms\FileSystemProviders.config.install.xdt" />
129-
130-
<!-- The FileSystemProviders.config.uninstall.xdt needs to be excluded from the NuGet package so that upgrades don't overwrite parameter values due to NuGet upgrades actually executing uninstall/install -->
131-
<FileSystemProvidersConfigXDTUninstallFile Include="$(MSBuildProjectDirectory)\transforms\FileSystemProviders.config.uninstall.xdt" />
132128

133129
<MediaWebConfigXDTInstallFile Include="$(MSBuildProjectDirectory)\transforms\media-web.config.install.xdt" />
134130
<MediaWebConfigXDTUninstallFile Include="$(MSBuildProjectDirectory)\transforms\media-web.config.uninstall.xdt" />
@@ -142,8 +138,6 @@
142138
<PackageFile Include="$(MSBuildProjectDirectory)\package.xml" />
143139
<ImageProcessorSecurityConfigXDTInstallFile Include="$(MSBuildProjectDirectory)\transforms\security.config.install.xdt" />
144140
<ImageProcessorSecurityConfigDefaultFile Include="$(InstallerProjectDir)\config\imageprocessor\security.config" />
145-
<ImageProcessorWebConfigXDTInstallFile Include="$(MSBuildProjectDirectory)\transforms\imageprocessor.web.config.install.xdt" />
146-
147141
<!-- NuGet specific -->
148142
<SrcFiles Include="$(ProjectDir)\**\*.cs" Exclude="$(ProjectDir)\obj\**"/>
149143
<NuSpecFile Include="$(MSBuildProjectDirectory)\package.nuspec" />
@@ -158,11 +152,8 @@
158152
<Copy SourceFiles="@(MediaWebConfigXDTInstallFile)" DestinationFolder="$(BuildUmbDir)\App_Plugins\UmbracoFileSystemProviders\Azure\Install" />
159153
<Copy SourceFiles="@(MediaWebConfigXDTUninstallFile)" DestinationFolder="$(BuildUmbDir)\App_Plugins\UmbracoFileSystemProviders\Azure\Install" />
160154

161-
<Copy SourceFiles="@(FileSystemProvidersConfigXDTInstallFile)" DestinationFolder="$(BuildUmbDir)\App_Plugins\UmbracoFileSystemProviders\Azure\Install" />
162-
<Copy SourceFiles="@(FileSystemProvidersConfigXDTUninstallFile)" DestinationFolder="$(BuildUmbDir)\App_Plugins\UmbracoFileSystemProviders\Azure\Install" />
163155
<Copy SourceFiles="@(ImageProcessorSecurityConfigXDTInstallFile)" DestinationFolder="$(BuildUmbDir)\App_Plugins\UmbracoFileSystemProviders\Azure\Install" />
164156
<Copy SourceFiles="@(ImageProcessorSecurityConfigDefaultFile)" DestinationFolder="$(BuildUmbDir)\App_Plugins\UmbracoFileSystemProviders\Azure\Install" />
165-
<Copy SourceFiles="@(ImageProcessorWebConfigXDTInstallFile)" DestinationFolder="$(BuildUmbDir)\App_Plugins\UmbracoFileSystemProviders\Azure\Install" />
166157

167158
<Copy SourceFiles="@(UmbracoInstallerFiles)" DestinationFiles="@(UmbracoInstallerFiles->'$(BuildUmbDir)\App_Plugins\UmbracoFileSystemProviders\Azure\Install\Configurator\%(RecursiveDir)%(Filename)%(Extension)')" />
168159
<Copy SourceFiles="@(UmbracoInstallerLogo)" DestinationFolder="$(BuildUmbDir)\App_Plugins\UmbracoFileSystemProviders\Azure\Install" />
@@ -175,7 +166,6 @@
175166
<Copy SourceFiles="@(MediaWebConfigXDTInstallFile)" DestinationFiles="$(BuildNuGetDir)\Content\Media\web.config.install.xdt" />
176167
<Copy SourceFiles="@(MediaWebConfigXDTUninstallFile)" DestinationFiles="$(BuildNuGetDir)\Content\Media\web.config.uninstall.xdt" />
177168

178-
<Copy SourceFiles="@(FileSystemProvidersConfigXDTInstallFile)" DestinationFolder="$(BuildNuGetDir)\Content\Config" />
179169
<Copy SourceFiles="@(SrcFiles)" DestinationFiles="@(SrcFiles->'$(BuildNuGetDir)\src\%(RecursiveDir)%(Filename)%(Extension)')" />
180170
<Copy SourceFiles="@(NuSpecFile)" DestinationFolder="$(BuildNuGetDir)" />
181171
</Target>

build/transforms/FileSystemProviders.config.install.xdt

Lines changed: 0 additions & 41 deletions
This file was deleted.

build/transforms/FileSystemProviders.config.uninstall.xdt

Lines changed: 0 additions & 22 deletions
This file was deleted.

build/transforms/imageprocessor.web.config.install.xdt

Lines changed: 0 additions & 12 deletions
This file was deleted.

build/transforms/web.config.install.xdt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
<?xml version="1.0"?>
22
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
33
<appSettings>
4-
<add key="AzureBlobFileSystem.ContainerName:media" xdt:Locator="Match(key)" xdt:Transform="Remove" />
54
<add key="AzureBlobFileSystem.ContainerName:media" value="media" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing" />
6-
<add key="AzureBlobFileSystem.RootUrl:media" xdt:Locator="Match(key)" xdt:Transform="Remove" />
75
<add key="AzureBlobFileSystem.RootUrl:media" value="https://[myAccountName].blob.core.windows.net/" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing"/>
8-
<add key="AzureBlobFileSystem.ConnectionString:media" xdt:Locator="Match(key)" xdt:Transform="Remove" />
96
<add key="AzureBlobFileSystem.ConnectionString:media" value="DefaultEndpointsProtocol=https;AccountName=[myAccountName];AccountKey=[myAccountKey]" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing"/>
10-
<add key="AzureBlobFileSystem.MaxDays:media" xdt:Locator="Match(key)" xdt:Transform="Remove" />
117
<add key="AzureBlobFileSystem.MaxDays:media" value="365" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing" />
12-
<add key="AzureBlobFileSystem.UseDefaultRoute:media" xdt:Locator="Match(key)" xdt:Transform="Remove" />
138
<add key="AzureBlobFileSystem.UseDefaultRoute:media" value="true" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing" />
14-
<add key="AzureBlobFileSystem.UsePrivateContainer:media" xdt:Locator="Match(key)" xdt:Transform="Remove" />
159
<add key="AzureBlobFileSystem.UsePrivateContainer:media" value="false" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing" />
1610
</appSettings>
1711

src/UmbracoFileSystemProviders.Azure.Installer/InstallerController.cs

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/UmbracoFileSystemProviders.Azure.sln

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BuildPackage", "BuildPackag
1717
..\appveyor.yml = ..\appveyor.yml
1818
..\build-appveyor.cmd = ..\build-appveyor.cmd
1919
..\build.cmd = ..\build.cmd
20-
..\build\transforms\FileSystemProviders.config.install.xdt = ..\build\transforms\FileSystemProviders.config.install.xdt
21-
..\build\transforms\FileSystemProviders.config.uninstall.xdt = ..\build\transforms\FileSystemProviders.config.uninstall.xdt
22-
..\build\transforms\imageprocessor.web.config.install.xdt = ..\build\transforms\imageprocessor.web.config.install.xdt
2320
..\build\transforms\media-web.config.install.xdt = ..\build\transforms\media-web.config.install.xdt
2421
..\build\transforms\media-web.config.uninstall.xdt = ..\build\transforms\media-web.config.uninstall.xdt
2522
..\build\package.nuspec = ..\build\package.nuspec

src/UmbracoFileSystemProviders.Azure/Helpers/ConfigurationHelper.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@
44

55
public class ConfigurationHelper
66
{
7-
public static string GetAppSetting(string key, string providerAlias)
7+
internal static string GetAppSetting(string key, string providerAlias)
88
{
9-
var settingValue = ConfigurationManager.AppSettings[key];
10-
if (settingValue != null)
11-
{
12-
return $"{settingValue}:{providerAlias}";
13-
}
14-
15-
return null;
9+
return ConfigurationManager.AppSettings[$"{key}:{providerAlias}"];
1610
}
1711
}
1812
}

0 commit comments

Comments
 (0)