Skip to content

Commit c81f645

Browse files
committed
Transform new media web.config for Umbraco package installs
1 parent 78f42cc commit c81f645

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

build/UmbracoFileSystemProviders.Azure.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
<FileSystemProvidersConfigXDTUninstallFile Include="$(MSBuildProjectDirectory)\transforms\FileSystemProviders.config.uninstall.xdt" />
131131

132132
<MediaWebConfigXDTInstallFile Include="$(MSBuildProjectDirectory)\transforms\media-web.config.install.xdt" />
133-
<MediaWebConfigXDTUninstallFile Include="$(MSBuildProjectDirectory)\transforms\media-web.config.install.xdt" />
133+
<MediaWebConfigXDTUninstallFile Include="$(MSBuildProjectDirectory)\transforms\media-web.config.uninstall.xdt" />
134134

135135
<!-- Umbraco specific -->
136136
<!-- Newtonsoft.Json Excluded for now as Umbraco requires different major versions -->

build/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<Actions>
3232
<Action runat="uninstall" undo="true" alias="UmbracoFileSystemProviders.Azure.TransformConfig" file="~/web.config" xdtfile="~/App_Plugins/UmbracoFileSystemProviders/Azure/Install/web.config"></Action>
3333
<Action runat="uninstall" undo="true" alias="UmbracoFileSystemProviders.Azure.TransformConfig" file="~/Config/FileSystemProviders.config" xdtfile="~/App_Plugins/UmbracoFileSystemProviders/Azure/Install/FileSystemProviders.config"></Action>
34-
34+
<Action runat="uninstall" undo="true" alias="UmbracoFileSystemProviders.Azure.TransformConfig" file="~/Media/web.config" xdtfile="~/App_Plugins/UmbracoFileSystemProviders/Azure/Install/media-web.config"></Action>
3535
</Actions>
3636

3737
<control>/App_Plugins/UmbracoFileSystemProviders/Azure/Install/Configurator/Views/Configure.ascx</control>

src/UmbracoFileSystemProviders.Azure.Installer/Constants.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public static class Constants
3030
/// </summary>
3131
public const string WebConfigFile = "web.config";
3232

33+
/// <summary>
34+
/// The media web configuration xdt file name.
35+
/// </summary>
36+
public const string MediaWebConfigXdtFile = "media-web.config";
37+
3338
/// <summary>
3439
/// The full qualified type name for the provider.
3540
/// </summary>

src/UmbracoFileSystemProviders.Azure.Installer/InstallerController.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public class InstallerController : UmbracoAuthorizedApiController
4444

4545
private readonly string webConfigXdtPath = HostingEnvironment.MapPath($"{Constants.InstallerPath}{Constants.WebConfigFile}.install.xdt");
4646

47+
private readonly string mediaWebConfigXdtPath = HostingEnvironment.MapPath($"{Constants.InstallerPath}{Constants.MediaWebConfigXdtFile}.install.xdt");
48+
4749
/// <summary>
4850
/// Gets the parameters from the XDT transform file.
4951
/// </summary>
@@ -84,7 +86,7 @@ public InstallerStatus PostParameters(IEnumerable<Parameter> parameters)
8486

8587
if (SaveParametersToFileSystemProvidersXdt(this.fileSystemProvidersConfigInstallXdtPath, newParameters) && SaveContainerNameToWebConfigXdt(this.webConfigXdtPath, routePrefix))
8688
{
87-
if (!ExecuteFileSystemConfigTransform() || !ExecuteWebConfigTransform())
89+
if (!ExecuteFileSystemConfigTransform() || !ExecuteWebConfigTransform() || !ExecuteMediaWebConfigTransform())
8890
{
8991
return InstallerStatus.SaveConfigError;
9092
}
@@ -374,6 +376,20 @@ private static bool ExecuteWebConfigTransform()
374376
return transformConfig.Execute("UmbracoFileSystemProviders.Azure", transFormConfigAction);
375377
}
376378

379+
private static bool ExecuteMediaWebConfigTransform()
380+
{
381+
XmlNode transFormConfigAction =
382+
helper.parseStringToXmlNode("<Action runat=\"install\" "
383+
+ "undo=\"true\" "
384+
+ "alias=\"UmbracoFileSystemProviders.Azure.TransformConfig\" "
385+
+ "file=\"~/Media/web.config\" "
386+
+ "xdtfile=\"~/app_plugins/UmbracoFileSystemProviders/Azure/install/media-web.config\">"
387+
+ "</Action>").FirstChild;
388+
389+
PackageActions.TransformConfig transformConfig = new PackageActions.TransformConfig();
390+
return transformConfig.Execute("UmbracoFileSystemProviders.Azure", transFormConfigAction);
391+
}
392+
377393
private static bool ExecuteImageProcessorSecurityConfigTransform()
378394
{
379395
// Ensure that security.config exists in ~/Config/Imageprocessor/

0 commit comments

Comments
 (0)