From 35477694420ba31635492135eaa21bab5ced1525 Mon Sep 17 00:00:00 2001 From: Robert Dima Date: Fri, 25 Oct 2024 16:33:13 +0300 Subject: [PATCH 1/4] Update DotNetNuke.Newtonsoft.Json.dnn to reference version 13.0.3 --- .../Components/Newtonsoft/DotNetNuke.Newtonsoft.Json.dnn | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DNN Platform/Components/Newtonsoft/DotNetNuke.Newtonsoft.Json.dnn b/DNN Platform/Components/Newtonsoft/DotNetNuke.Newtonsoft.Json.dnn index 23edde1a7ee..fb05b874303 100644 --- a/DNN Platform/Components/Newtonsoft/DotNetNuke.Newtonsoft.Json.dnn +++ b/DNN Platform/Components/Newtonsoft/DotNetNuke.Newtonsoft.Json.dnn @@ -1,6 +1,6 @@ - + Newtonsoft Json Components Provides Newtonsoft Json Components for DotNetNuke. @@ -12,7 +12,7 @@ License.txt - This package includes Newtonsoft.Json assembly version 13.0.1. + This package includes Newtonsoft.Json assembly version 13.0.3. Please go to https://www.newtonsoft.com/json to view release notes on this particular version. @@ -20,7 +20,7 @@ bin Newtonsoft.Json.dll - 13.0.1 + 13.0.3 From cbac92c4ef12de2046eeaaf8d6a2058f07c2b338 Mon Sep 17 00:00:00 2001 From: Brian Dukes Date: Fri, 25 Oct 2024 08:59:14 -0500 Subject: [PATCH 2/4] Extract GetAssemblyFileVersion helper --- Build/ContextExtensions.cs | 22 ++++++++++++++++++++++ Build/Tasks/PackageAspNetMvc.cs | 4 ++-- Build/Tasks/PackageAspNetWebApi.cs | 4 ++-- Build/Tasks/PackageAspNetWebPages.cs | 4 ++-- Build/Tasks/PackageMailKit.cs | 4 ++-- Build/Tasks/PackageMicrosoftGlobbing.cs | 4 ++-- Build/Tasks/PackageNewtonsoft.cs | 7 ++----- Build/Tasks/PackageSharpZipLib.cs | 5 ++--- Build/Tasks/PackageWebFormsMvp.cs | 4 ++-- 9 files changed, 38 insertions(+), 20 deletions(-) create mode 100644 Build/ContextExtensions.cs diff --git a/Build/ContextExtensions.cs b/Build/ContextExtensions.cs new file mode 100644 index 00000000000..0ad7c83d104 --- /dev/null +++ b/Build/ContextExtensions.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information + +namespace DotNetNuke.Build; + +using System.Diagnostics; +using Cake.Common.IO; +using Cake.Core.IO; + +/// Provides extensions to . +public static class ContextExtensions +{ + /// Gets the for an assembly. + /// The cake context. + /// The path to the assembly file. + /// The file version. + public static string GetAssemblyFileVersion(this Context context, FilePath assemblyPath) + { + return FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; + } +} diff --git a/Build/Tasks/PackageAspNetMvc.cs b/Build/Tasks/PackageAspNetMvc.cs index d61f3fa85c4..ee87eee81ce 100644 --- a/Build/Tasks/PackageAspNetMvc.cs +++ b/Build/Tasks/PackageAspNetMvc.cs @@ -21,7 +21,7 @@ public override void Run(Context context) { var binDir = context.WebsiteDir.Path.Combine("bin"); var mainAssemblyPath = binDir.CombineWithFilePath("System.Web.Mvc.dll"); - var packageVersion = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mainAssemblyPath).FullPath).FileVersion; + var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath); var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/AspNetMvc_{packageVersion}_Install.zip"); var packageDir = context.Directory("DNN Platform/Components/Microsoft.AspNetMvc"); @@ -56,7 +56,7 @@ where childNode.LocalName.Equals("name") .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); if (versionNode != null) { - versionNode.InnerText = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; + versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); } } diff --git a/Build/Tasks/PackageAspNetWebApi.cs b/Build/Tasks/PackageAspNetWebApi.cs index db25bebb34f..5610c21366c 100644 --- a/Build/Tasks/PackageAspNetWebApi.cs +++ b/Build/Tasks/PackageAspNetWebApi.cs @@ -21,7 +21,7 @@ public override void Run(Context context) { var binDir = context.WebsiteDir.Path.Combine("bin"); var mainAssemblyPath = binDir.CombineWithFilePath("System.Web.Http.dll"); - var packageVersion = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mainAssemblyPath).FullPath).FileVersion; + var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath); var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/AspNetWebApi_{packageVersion}_Install.zip"); var packageDir = context.Directory("DNN Platform/Components/Microsoft.AspNetWebApi"); @@ -56,7 +56,7 @@ where childNode.LocalName.Equals("name") .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); if (versionNode != null) { - versionNode.InnerText = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; + versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); } } diff --git a/Build/Tasks/PackageAspNetWebPages.cs b/Build/Tasks/PackageAspNetWebPages.cs index d9ef115b9f6..b4fe45a4097 100644 --- a/Build/Tasks/PackageAspNetWebPages.cs +++ b/Build/Tasks/PackageAspNetWebPages.cs @@ -21,7 +21,7 @@ public override void Run(Context context) { var binDir = context.WebsiteDir.Path.Combine("bin"); var mainAssemblyPath = binDir.CombineWithFilePath("System.Web.WebPages.dll"); - var packageVersion = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mainAssemblyPath).FullPath).FileVersion; + var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath); var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/AspNetWebPages_{packageVersion}_Install.zip"); var packageDir = context.Directory("DNN Platform/Components/Microsoft.AspNetWebPages"); @@ -56,7 +56,7 @@ where childNode.LocalName.Equals("name") .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); if (versionNode != null) { - versionNode.InnerText = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; + versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); } } diff --git a/Build/Tasks/PackageMailKit.cs b/Build/Tasks/PackageMailKit.cs index 5fb6b4157ea..80138e7f775 100644 --- a/Build/Tasks/PackageMailKit.cs +++ b/Build/Tasks/PackageMailKit.cs @@ -21,7 +21,7 @@ public override void Run(Context context) { var binDir = context.WebsiteDir.Path.Combine("bin"); var mailKitPath = binDir.CombineWithFilePath("MailKit.dll"); - var packageVersion = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mailKitPath).FullPath).FileVersion; + var packageVersion = context.GetAssemblyFileVersion(mailKitPath); var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/MailKit_{packageVersion}_Install.zip"); var packageDir = context.Directory("DNN Platform/Components/MailKit"); @@ -56,7 +56,7 @@ where childNode.LocalName.Equals("name") .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); if (versionNode != null) { - versionNode.InnerText = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; + versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); } } diff --git a/Build/Tasks/PackageMicrosoftGlobbing.cs b/Build/Tasks/PackageMicrosoftGlobbing.cs index f529e6deed5..f155f45bf72 100644 --- a/Build/Tasks/PackageMicrosoftGlobbing.cs +++ b/Build/Tasks/PackageMicrosoftGlobbing.cs @@ -20,7 +20,7 @@ public override void Run(Context context) { var binDir = context.WebsiteDir.Path.Combine("bin"); var mainAssemblyPath = binDir.CombineWithFilePath("Microsoft.Extensions.FileSystemGlobbing.dll"); - var packageVersion = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mainAssemblyPath).FullPath).FileVersion; + var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath); var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/MicrosoftGlobbing_{packageVersion}_Install.zip"); var packageDir = context.Directory("DNN Platform/Components/Microsoft.Extensions.FileSystemGlobbing"); @@ -55,7 +55,7 @@ where childNode.LocalName.Equals("name") .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); if (versionNode != null) { - versionNode.InnerText = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; + versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); } } diff --git a/Build/Tasks/PackageNewtonsoft.cs b/Build/Tasks/PackageNewtonsoft.cs index 651cb5804a9..0d4c0e9b2d6 100644 --- a/Build/Tasks/PackageNewtonsoft.cs +++ b/Build/Tasks/PackageNewtonsoft.cs @@ -3,9 +3,6 @@ // See the LICENSE file in the project root for more information namespace DotNetNuke.Build.Tasks { - using System; - using System.Linq; - using Cake.Common.IO; using Cake.Frosting; @@ -18,9 +15,9 @@ public sealed class PackageNewtonsoft : FrostingTask public override void Run(Context context) { var version = "00.00.00"; - foreach (var assy in context.GetFiles(context.WebsiteFolder + "bin/Newtonsoft.Json.dll")) + foreach (var assemblyPath in context.GetFiles(context.WebsiteFolder + "bin/Newtonsoft.Json.dll")) { - version = System.Diagnostics.FileVersionInfo.GetVersionInfo(assy.FullPath).FileVersion; + version = context.GetAssemblyFileVersion(assemblyPath); } var packageZip = $"{context.WebsiteFolder}Install/Module/Newtonsoft.Json_{version}_Install.zip"; diff --git a/Build/Tasks/PackageSharpZipLib.cs b/Build/Tasks/PackageSharpZipLib.cs index 4396939b865..952f6d779ab 100644 --- a/Build/Tasks/PackageSharpZipLib.cs +++ b/Build/Tasks/PackageSharpZipLib.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information namespace DotNetNuke.Build.Tasks { - using System.Diagnostics; using System.Linq; using System.Xml; @@ -20,7 +19,7 @@ public override void Run(Context context) { var binDir = context.WebsiteDir.Path.Combine("bin"); var mainAssemblyPath = binDir.CombineWithFilePath("ICSharpCode.SharpZipLib.dll"); - var packageVersion = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mainAssemblyPath).FullPath).FileVersion; + var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath); var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/SharpZipLib_{packageVersion}_Install.zip"); var packageDir = context.Directory("DNN Platform/Components/SharpZipLib"); @@ -55,7 +54,7 @@ where childNode.LocalName.Equals("name") .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); if (versionNode != null) { - versionNode.InnerText = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; + versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); } } diff --git a/Build/Tasks/PackageWebFormsMvp.cs b/Build/Tasks/PackageWebFormsMvp.cs index 4e4af65e70e..ff6b7487f61 100644 --- a/Build/Tasks/PackageWebFormsMvp.cs +++ b/Build/Tasks/PackageWebFormsMvp.cs @@ -20,7 +20,7 @@ public override void Run(Context context) { var binDir = context.WebsiteDir.Path.Combine("bin"); var mainAssemblyPath = binDir.CombineWithFilePath("WebFormsMvp.dll"); - var packageVersion = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mainAssemblyPath).FullPath).FileVersion; + var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath); var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/WebFormsMvp_{packageVersion}_Install.zip"); var packageDir = context.Directory("DNN Platform/Components/WebFormsMvp"); @@ -55,7 +55,7 @@ where childNode.LocalName.Equals("name") .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); if (versionNode != null) { - versionNode.InnerText = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; + versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); } } From e2ea87a3ccda3790580d3308a23819553e2ef57f Mon Sep 17 00:00:00 2001 From: Brian Dukes Date: Fri, 25 Oct 2024 12:37:39 -0500 Subject: [PATCH 3/4] Extract common component packaging task Fixes #5332 Fixes #5997 Fixes #6173 --- Build/Tasks/PackageAspNetMvc.cs | 69 ++------------------ Build/Tasks/PackageAspNetWebApi.cs | 69 ++------------------ Build/Tasks/PackageAspNetWebPages.cs | 69 ++------------------ Build/Tasks/PackageComponentTask.cs | 87 +++++++++++++++++++++++++ Build/Tasks/PackageMailKit.cs | 69 ++------------------ Build/Tasks/PackageMicrosoftGlobbing.cs | 68 ++----------------- Build/Tasks/PackageNewtonsoft.cs | 35 ++-------- Build/Tasks/PackageSharpZipLib.cs | 67 ++----------------- Build/Tasks/PackageWebFormsMvp.cs | 68 ++----------------- 9 files changed, 143 insertions(+), 458 deletions(-) create mode 100644 Build/Tasks/PackageComponentTask.cs diff --git a/Build/Tasks/PackageAspNetMvc.cs b/Build/Tasks/PackageAspNetMvc.cs index ee87eee81ce..fc334c5ff6a 100644 --- a/Build/Tasks/PackageAspNetMvc.cs +++ b/Build/Tasks/PackageAspNetMvc.cs @@ -1,69 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information -namespace DotNetNuke.Build.Tasks -{ - using System; - using System.Diagnostics; - using System.Linq; - using System.Xml; - - using Cake.Common.Diagnostics; - using Cake.Common.IO; - using Cake.Frosting; - using Dnn.CakeUtils; +namespace DotNetNuke.Build.Tasks; - /// A cake task to generate the ASP.NET MVC package. - public sealed class PackageAspNetMvc : FrostingTask +/// A cake task to generate the ASP.NET MVC package. +public sealed class PackageAspNetMvc : PackageComponentTask +{ + /// Initializes a new instance of the class. + public PackageAspNetMvc() + : base("AspNetMvc", "System.Web.Mvc.dll", "Microsoft.AspNetMvc") { - /// - public override void Run(Context context) - { - var binDir = context.WebsiteDir.Path.Combine("bin"); - var mainAssemblyPath = binDir.CombineWithFilePath("System.Web.Mvc.dll"); - var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath); - - var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/AspNetMvc_{packageVersion}_Install.zip"); - var packageDir = context.Directory("DNN Platform/Components/Microsoft.AspNetMvc"); - - context.Information($"Creating {packageZip}"); - context.Zip( - packageDir.ToString(), - packageZip, - context.GetFilesByPatterns(packageDir, new[] { "*" }, new[] { "*.dnn" })); - - var manifestPath = context.GetFiles(packageDir.Path.CombineWithFilePath("*.dnn").ToString()).Single(); - context.Information($"Reading manifest from {manifestPath}"); - var manifest = new XmlDocument(); - manifest.LoadXml(context.ReadFile(manifestPath)); - var assemblies = - from XmlNode assemblyNode in manifest.SelectNodes("//assembly") - from XmlNode childNode in assemblyNode.ChildNodes - where childNode.LocalName.Equals("name") - select childNode; - - foreach (var assemblyNameNode in assemblies) - { - var assemblyPath = binDir.CombineWithFilePath(assemblyNameNode.InnerText); - context.Information($"Adding {assemblyPath} to {packageZip}"); - context.AddFilesToZip( - packageZip, - context.MakeAbsolute(context.WebsiteDir.Path), - context.GetFiles(assemblyPath.ToString()), - append: true); - - var versionNode = assemblyNameNode.ParentNode.ChildNodes.Cast() - .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); - if (versionNode != null) - { - versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); - context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); - } - } - - manifest.SelectSingleNode("//package[@version]").Attributes["version"].Value = packageVersion; - - context.AddXmlFileToZip(packageZip, manifest, manifestPath.GetFilename().ToString(), append: true); - } } } diff --git a/Build/Tasks/PackageAspNetWebApi.cs b/Build/Tasks/PackageAspNetWebApi.cs index 5610c21366c..04be9c488fd 100644 --- a/Build/Tasks/PackageAspNetWebApi.cs +++ b/Build/Tasks/PackageAspNetWebApi.cs @@ -1,69 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information -namespace DotNetNuke.Build.Tasks -{ - using System; - using System.Diagnostics; - using System.Linq; - using System.Xml; - - using Cake.Common.Diagnostics; - using Cake.Common.IO; - using Cake.Frosting; - using Dnn.CakeUtils; +namespace DotNetNuke.Build.Tasks; - /// A cake task to generate the ASP.NET Web API package. - public sealed class PackageAspNetWebApi : FrostingTask +/// A cake task to generate the ASP.NET Web API package. +public sealed class PackageAspNetWebApi : PackageComponentTask +{ + /// Initializes a new instance of the class. + public PackageAspNetWebApi() + : base("AspNetWebApi", "System.Web.Http.dll", "Microsoft.AspNetWebApi") { - /// - public override void Run(Context context) - { - var binDir = context.WebsiteDir.Path.Combine("bin"); - var mainAssemblyPath = binDir.CombineWithFilePath("System.Web.Http.dll"); - var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath); - - var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/AspNetWebApi_{packageVersion}_Install.zip"); - var packageDir = context.Directory("DNN Platform/Components/Microsoft.AspNetWebApi"); - - context.Information($"Creating {packageZip}"); - context.Zip( - packageDir.ToString(), - packageZip, - context.GetFilesByPatterns(packageDir, new[] { "*" }, new[] { "*.dnn" })); - - var manifestPath = context.GetFiles(packageDir.Path.CombineWithFilePath("*.dnn").ToString()).Single(); - context.Information($"Reading manifest from {manifestPath}"); - var manifest = new XmlDocument(); - manifest.LoadXml(context.ReadFile(manifestPath)); - var assemblies = - from XmlNode assemblyNode in manifest.SelectNodes("//assembly") - from XmlNode childNode in assemblyNode.ChildNodes - where childNode.LocalName.Equals("name") - select childNode; - - foreach (var assemblyNameNode in assemblies) - { - var assemblyPath = binDir.CombineWithFilePath(assemblyNameNode.InnerText); - context.Information($"Adding {assemblyPath} to {packageZip}"); - context.AddFilesToZip( - packageZip, - context.MakeAbsolute(context.WebsiteDir.Path), - context.GetFiles(assemblyPath.ToString()), - append: true); - - var versionNode = assemblyNameNode.ParentNode.ChildNodes.Cast() - .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); - if (versionNode != null) - { - versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); - context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); - } - } - - manifest.SelectSingleNode("//package[@version]").Attributes["version"].Value = packageVersion; - - context.AddXmlFileToZip(packageZip, manifest, manifestPath.GetFilename().ToString(), append: true); - } } } diff --git a/Build/Tasks/PackageAspNetWebPages.cs b/Build/Tasks/PackageAspNetWebPages.cs index b4fe45a4097..e36d499330a 100644 --- a/Build/Tasks/PackageAspNetWebPages.cs +++ b/Build/Tasks/PackageAspNetWebPages.cs @@ -1,69 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information -namespace DotNetNuke.Build.Tasks -{ - using System; - using System.Diagnostics; - using System.Linq; - using System.Xml; - - using Cake.Common.Diagnostics; - using Cake.Common.IO; - using Cake.Frosting; - using Dnn.CakeUtils; +namespace DotNetNuke.Build.Tasks; - /// A cake task to generate the ASP.NET Web Pages package. - public sealed class PackageAspNetWebPages : FrostingTask +/// A cake task to generate the ASP.NET Web Pages package. +public sealed class PackageAspNetWebPages : PackageComponentTask +{ + /// Initializes a new instance of the class. + public PackageAspNetWebPages() + : base("AspNetWebPages", "System.Web.WebPages.dll", "Microsoft.AspNetWebPages") { - /// - public override void Run(Context context) - { - var binDir = context.WebsiteDir.Path.Combine("bin"); - var mainAssemblyPath = binDir.CombineWithFilePath("System.Web.WebPages.dll"); - var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath); - - var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/AspNetWebPages_{packageVersion}_Install.zip"); - var packageDir = context.Directory("DNN Platform/Components/Microsoft.AspNetWebPages"); - - context.Information($"Creating {packageZip}"); - context.Zip( - packageDir.ToString(), - packageZip, - context.GetFilesByPatterns(packageDir, new[] { "*" }, new[] { "*.dnn" })); - - var manifestPath = context.GetFiles(packageDir.Path.CombineWithFilePath("*.dnn").ToString()).Single(); - context.Information($"Reading manifest from {manifestPath}"); - var manifest = new XmlDocument(); - manifest.LoadXml(context.ReadFile(manifestPath)); - var assemblies = - from XmlNode assemblyNode in manifest.SelectNodes("//assembly") - from XmlNode childNode in assemblyNode.ChildNodes - where childNode.LocalName.Equals("name") - select childNode; - - foreach (var assemblyNameNode in assemblies) - { - var assemblyPath = binDir.CombineWithFilePath(assemblyNameNode.InnerText); - context.Information($"Adding {assemblyPath} to {packageZip}"); - context.AddFilesToZip( - packageZip, - context.MakeAbsolute(context.WebsiteDir.Path), - context.GetFiles(assemblyPath.ToString()), - append: true); - - var versionNode = assemblyNameNode.ParentNode.ChildNodes.Cast() - .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); - if (versionNode != null) - { - versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); - context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); - } - } - - manifest.SelectSingleNode("//package[@version]").Attributes["version"].Value = packageVersion; - - context.AddXmlFileToZip(packageZip, manifest, manifestPath.GetFilename().ToString(), append: true); - } } } diff --git a/Build/Tasks/PackageComponentTask.cs b/Build/Tasks/PackageComponentTask.cs new file mode 100644 index 00000000000..788f96b1a70 --- /dev/null +++ b/Build/Tasks/PackageComponentTask.cs @@ -0,0 +1,87 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information + +namespace DotNetNuke.Build.Tasks; + +using System.Linq; +using System.Xml; +using Cake.Common.Diagnostics; +using Cake.Common.IO; +using Cake.Core.IO; +using Cake.Frosting; +using Dnn.CakeUtils; + +/// Provides the base functionality for packaging a folder inside Components. +public abstract class PackageComponentTask : FrostingTask +{ + /// Initializes a new instance of the class. + /// The name of the component. + /// The name of the primary assembly. + /// The name of the folder in DNN Platform/Components/. + protected PackageComponentTask(string componentName, FilePath primaryAssemblyName = null, DirectoryPath componentFolderName = null) + { + this.ComponentName = componentName; + this.ComponentFolderName = componentFolderName ?? componentName; + this.PrimaryAssemblyName = primaryAssemblyName ?? $"{componentName}.dll"; + } + + /// Gets the name of the component. + public string ComponentName { get; } + + /// Gets the name of the folder in DNN Platform/Components/ where the component files are. + public DirectoryPath ComponentFolderName { get; } + + /// Gets the name of the primary assembly. + public FilePath PrimaryAssemblyName { get; } + + /// + public override void Run(Context context) + { + var binDir = context.WebsiteDir.Path.Combine("bin"); + var mainAssemblyPath = binDir.CombineWithFilePath(this.PrimaryAssemblyName); + var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath); + + var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/{this.ComponentName}_{packageVersion}_Install.zip"); + var packageDir = context.Directory($"DNN Platform/Components/{this.ComponentFolderName}"); + + context.Information($"Creating {packageZip}"); + context.Zip( + packageDir.ToString(), + packageZip, + context.GetFilesByPatterns(packageDir, new[] { "*" }, new[] { "*.dnn" })); + + var manifestPath = context.GetFiles(packageDir.Path.CombineWithFilePath("*.dnn").ToString()).Single(); + context.Information($"Reading manifest from {manifestPath}"); + var manifest = new XmlDocument(); + manifest.LoadXml(context.ReadFile(manifestPath)); + var assemblies = + from XmlNode assemblyNode in manifest.SelectNodes("//assembly") + from XmlNode childNode in assemblyNode.ChildNodes + where childNode.LocalName.Equals("name") + select childNode; + + foreach (var assemblyNameNode in assemblies) + { + var assemblyPath = binDir.CombineWithFilePath(assemblyNameNode.InnerText); + context.Information($"Adding {assemblyPath} to {packageZip}"); + context.AddFilesToZip( + packageZip, + context.MakeAbsolute(context.WebsiteDir.Path), + context.GetFiles(assemblyPath.ToString()), + append: true); + + var versionNode = assemblyNameNode.ParentNode?.ChildNodes.Cast() + .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); + if (versionNode != null) + { + versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); + context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); + } + } + + manifest.SelectSingleNode("//package[@version]").Attributes["version"].Value = packageVersion; + + context.AddXmlFileToZip(packageZip, manifest, manifestPath.GetFilename().ToString(), append: true); + } +} diff --git a/Build/Tasks/PackageMailKit.cs b/Build/Tasks/PackageMailKit.cs index 80138e7f775..b434707156e 100644 --- a/Build/Tasks/PackageMailKit.cs +++ b/Build/Tasks/PackageMailKit.cs @@ -1,69 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information -namespace DotNetNuke.Build.Tasks -{ - using System; - using System.Diagnostics; - using System.Linq; - using System.Xml; - - using Cake.Common.Diagnostics; - using Cake.Common.IO; - using Cake.Frosting; - using Dnn.CakeUtils; +namespace DotNetNuke.Build.Tasks; - /// A cake task to generate the MailKit package. - public sealed class PackageMailKit : FrostingTask +/// A cake task to generate the MailKit package. +public sealed class PackageMailKit : PackageComponentTask +{ + /// Initializes a new instance of the class. + public PackageMailKit() + : base("MailKit") { - /// - public override void Run(Context context) - { - var binDir = context.WebsiteDir.Path.Combine("bin"); - var mailKitPath = binDir.CombineWithFilePath("MailKit.dll"); - var packageVersion = context.GetAssemblyFileVersion(mailKitPath); - - var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/MailKit_{packageVersion}_Install.zip"); - var packageDir = context.Directory("DNN Platform/Components/MailKit"); - - context.Information($"Creating {packageZip}"); - context.Zip( - packageDir.ToString(), - packageZip, - context.GetFilesByPatterns(packageDir, new[] { "*" }, new[] { "*.dnn" })); - - var manifestPath = context.GetFiles(packageDir.Path.CombineWithFilePath("*.dnn").ToString()).Single(); - context.Information($"Reading manifest from {manifestPath}"); - var manifest = new XmlDocument(); - manifest.LoadXml(context.ReadFile(manifestPath)); - var assemblies = - from XmlNode assemblyNode in manifest.SelectNodes("//assembly") - from XmlNode childNode in assemblyNode.ChildNodes - where childNode.LocalName.Equals("name") - select childNode; - - foreach (var assemblyNameNode in assemblies) - { - var assemblyPath = binDir.CombineWithFilePath(assemblyNameNode.InnerText); - context.Information($"Adding {assemblyPath} to {packageZip}"); - context.AddFilesToZip( - packageZip, - context.MakeAbsolute(context.WebsiteDir.Path), - context.GetFiles(assemblyPath.ToString()), - append: true); - - var versionNode = assemblyNameNode.ParentNode.ChildNodes.Cast() - .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); - if (versionNode != null) - { - versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); - context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); - } - } - - manifest.SelectSingleNode("//package[@version]").Attributes["version"].Value = packageVersion; - - context.AddXmlFileToZip(packageZip, manifest, manifestPath.GetFilename().ToString(), append: true); - } } } diff --git a/Build/Tasks/PackageMicrosoftGlobbing.cs b/Build/Tasks/PackageMicrosoftGlobbing.cs index f155f45bf72..bf4cf5a01f6 100644 --- a/Build/Tasks/PackageMicrosoftGlobbing.cs +++ b/Build/Tasks/PackageMicrosoftGlobbing.cs @@ -1,68 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information -namespace DotNetNuke.Build.Tasks -{ - using System.Diagnostics; - using System.Linq; - using System.Xml; - - using Cake.Common.Diagnostics; - using Cake.Common.IO; - using Cake.Frosting; - using Dnn.CakeUtils; +namespace DotNetNuke.Build.Tasks; - /// A cake task to generate the Microsoft.Extensions.FileSystemGlobbing package. - public sealed class PackageMicrosoftGlobbing : FrostingTask +/// A cake task to generate the Microsoft.Extensions.FileSystemGlobbing package. +public sealed class PackageMicrosoftGlobbing : PackageComponentTask +{ + /// Initializes a new instance of the class. + public PackageMicrosoftGlobbing() + : base("MicrosoftGlobbing", "Microsoft.Extensions.FileSystemGlobbing.dll", "Microsoft.Extensions.FileSystemGlobbing") { - /// - public override void Run(Context context) - { - var binDir = context.WebsiteDir.Path.Combine("bin"); - var mainAssemblyPath = binDir.CombineWithFilePath("Microsoft.Extensions.FileSystemGlobbing.dll"); - var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath); - - var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/MicrosoftGlobbing_{packageVersion}_Install.zip"); - var packageDir = context.Directory("DNN Platform/Components/Microsoft.Extensions.FileSystemGlobbing"); - - context.Information($"Creating {packageZip}"); - context.Zip( - packageDir.ToString(), - packageZip, - context.GetFilesByPatterns(packageDir, new[] { "*" }, new[] { "*.dnn" })); - - var manifestPath = context.GetFiles(packageDir.Path.CombineWithFilePath("*.dnn").ToString()).Single(); - context.Information($"Reading manifest from {manifestPath}"); - var manifest = new XmlDocument(); - manifest.LoadXml(context.ReadFile(manifestPath)); - var assemblies = - from XmlNode assemblyNode in manifest.SelectNodes("//assembly") - from XmlNode childNode in assemblyNode.ChildNodes - where childNode.LocalName.Equals("name") - select childNode; - - foreach (var assemblyNameNode in assemblies) - { - var assemblyPath = binDir.CombineWithFilePath(assemblyNameNode.InnerText); - context.Information($"Adding {assemblyPath} to {packageZip}"); - context.AddFilesToZip( - packageZip, - context.MakeAbsolute(context.WebsiteDir.Path), - context.GetFiles(assemblyPath.ToString()), - append: true); - - var versionNode = assemblyNameNode.ParentNode.ChildNodes.Cast() - .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); - if (versionNode != null) - { - versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); - context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); - } - } - - manifest.SelectSingleNode("//package[@version]").Attributes["version"].Value = packageVersion; - - context.AddXmlFileToZip(packageZip, manifest, manifestPath.GetFilename().ToString(), append: true); - } } } diff --git a/Build/Tasks/PackageNewtonsoft.cs b/Build/Tasks/PackageNewtonsoft.cs index 0d4c0e9b2d6..11b60f5aaf0 100644 --- a/Build/Tasks/PackageNewtonsoft.cs +++ b/Build/Tasks/PackageNewtonsoft.cs @@ -1,35 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information -namespace DotNetNuke.Build.Tasks -{ - using Cake.Common.IO; - using Cake.Frosting; - - using Dnn.CakeUtils; +namespace DotNetNuke.Build.Tasks; - /// A cake task to generate the Newtonsoft.Json package. - public sealed class PackageNewtonsoft : FrostingTask +/// A cake task to generate the Newtonsoft.Json package. +public sealed class PackageNewtonsoft : PackageComponentTask +{ + /// Initializes a new instance of the class. + public PackageNewtonsoft() + : base("Newtonsoft.Json", "Newtonsoft.Json.dll", "Newtonsoft") { - /// - public override void Run(Context context) - { - var version = "00.00.00"; - foreach (var assemblyPath in context.GetFiles(context.WebsiteFolder + "bin/Newtonsoft.Json.dll")) - { - version = context.GetAssemblyFileVersion(assemblyPath); - } - - var packageZip = $"{context.WebsiteFolder}Install/Module/Newtonsoft.Json_{version}_Install.zip"; - context.Zip( - "./DNN Platform/Components/Newtonsoft", - packageZip, - context.GetFiles("./DNN Platform/Components/Newtonsoft/*")); - context.AddFilesToZip( - packageZip, - "Website", - context.GetFiles(context.WebsiteFolder + "bin/Newtonsoft.Json.dll"), - true); - } } } diff --git a/Build/Tasks/PackageSharpZipLib.cs b/Build/Tasks/PackageSharpZipLib.cs index 952f6d779ab..6b9bd3dfa33 100644 --- a/Build/Tasks/PackageSharpZipLib.cs +++ b/Build/Tasks/PackageSharpZipLib.cs @@ -1,67 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information -namespace DotNetNuke.Build.Tasks -{ - using System.Linq; - using System.Xml; - - using Cake.Common.Diagnostics; - using Cake.Common.IO; - using Cake.Frosting; - using Dnn.CakeUtils; +namespace DotNetNuke.Build.Tasks; - /// A cake task to generate the SharpZipLib package. - public sealed class PackageSharpZipLib : FrostingTask +/// A cake task to generate the SharpZipLib package. +public sealed class PackageSharpZipLib : PackageComponentTask +{ + /// Initializes a new instance of the class. + public PackageSharpZipLib() + : base("SharpZipLib", "ICSharpCode.SharpZipLib.dll") { - /// - public override void Run(Context context) - { - var binDir = context.WebsiteDir.Path.Combine("bin"); - var mainAssemblyPath = binDir.CombineWithFilePath("ICSharpCode.SharpZipLib.dll"); - var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath); - - var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/SharpZipLib_{packageVersion}_Install.zip"); - var packageDir = context.Directory("DNN Platform/Components/SharpZipLib"); - - context.Information($"Creating {packageZip}"); - context.Zip( - packageDir.ToString(), - packageZip, - context.GetFilesByPatterns(packageDir, new[] { "*" }, new[] { "*.dnn" })); - - var manifestPath = context.GetFiles(packageDir.Path.CombineWithFilePath("*.dnn").ToString()).Single(); - context.Information($"Reading manifest from {manifestPath}"); - var manifest = new XmlDocument(); - manifest.LoadXml(context.ReadFile(manifestPath)); - var assemblies = - from XmlNode assemblyNode in manifest.SelectNodes("//assembly") - from XmlNode childNode in assemblyNode.ChildNodes - where childNode.LocalName.Equals("name") - select childNode; - - foreach (var assemblyNameNode in assemblies) - { - var assemblyPath = binDir.CombineWithFilePath(assemblyNameNode.InnerText); - context.Information($"Adding {assemblyPath} to {packageZip}"); - context.AddFilesToZip( - packageZip, - context.MakeAbsolute(context.WebsiteDir.Path), - context.GetFiles(assemblyPath.ToString()), - append: true); - - var versionNode = assemblyNameNode.ParentNode.ChildNodes.Cast() - .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); - if (versionNode != null) - { - versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); - context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); - } - } - - manifest.SelectSingleNode("//package[@version]").Attributes["version"].Value = packageVersion; - - context.AddXmlFileToZip(packageZip, manifest, manifestPath.GetFilename().ToString(), append: true); - } } } diff --git a/Build/Tasks/PackageWebFormsMvp.cs b/Build/Tasks/PackageWebFormsMvp.cs index ff6b7487f61..af073bcc89a 100644 --- a/Build/Tasks/PackageWebFormsMvp.cs +++ b/Build/Tasks/PackageWebFormsMvp.cs @@ -1,68 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information -namespace DotNetNuke.Build.Tasks -{ - using System.Diagnostics; - using System.Linq; - using System.Xml; - - using Cake.Common.Diagnostics; - using Cake.Common.IO; - using Cake.Frosting; - using Dnn.CakeUtils; +namespace DotNetNuke.Build.Tasks; - /// A cake task to generate the WebFormsMvp package. - public sealed class PackageWebFormsMvp : FrostingTask +/// A cake task to generate the WebFormsMvp package. +public sealed class PackageWebFormsMvp : PackageComponentTask +{ + /// Initializes a new instance of the class. + public PackageWebFormsMvp() + : base("WebFormsMvp") { - /// - public override void Run(Context context) - { - var binDir = context.WebsiteDir.Path.Combine("bin"); - var mainAssemblyPath = binDir.CombineWithFilePath("WebFormsMvp.dll"); - var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath); - - var packageZip = context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/WebFormsMvp_{packageVersion}_Install.zip"); - var packageDir = context.Directory("DNN Platform/Components/WebFormsMvp"); - - context.Information($"Creating {packageZip}"); - context.Zip( - packageDir.ToString(), - packageZip, - context.GetFilesByPatterns(packageDir, new[] { "*" }, new[] { "*.dnn" })); - - var manifestPath = context.GetFiles(packageDir.Path.CombineWithFilePath("*.dnn").ToString()).Single(); - context.Information($"Reading manifest from {manifestPath}"); - var manifest = new XmlDocument(); - manifest.LoadXml(context.ReadFile(manifestPath)); - var assemblies = - from XmlNode assemblyNode in manifest.SelectNodes("//assembly") - from XmlNode childNode in assemblyNode.ChildNodes - where childNode.LocalName.Equals("name") - select childNode; - - foreach (var assemblyNameNode in assemblies) - { - var assemblyPath = binDir.CombineWithFilePath(assemblyNameNode.InnerText); - context.Information($"Adding {assemblyPath} to {packageZip}"); - context.AddFilesToZip( - packageZip, - context.MakeAbsolute(context.WebsiteDir.Path), - context.GetFiles(assemblyPath.ToString()), - append: true); - - var versionNode = assemblyNameNode.ParentNode.ChildNodes.Cast() - .SingleOrDefault(childNode => childNode.LocalName.Equals("version")); - if (versionNode != null) - { - versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath); - context.Information($"Set {assemblyPath} version to {versionNode.InnerText}"); - } - } - - manifest.SelectSingleNode("//package[@version]").Attributes["version"].Value = packageVersion; - - context.AddXmlFileToZip(packageZip, manifest, manifestPath.GetFilename().ToString(), append: true); - } } } From d21b0aa99a687e3892d71a72e9b03ca0376e0add Mon Sep 17 00:00:00 2001 From: Brian Dukes Date: Fri, 25 Oct 2024 12:39:22 -0500 Subject: [PATCH 4/4] Remove Globbing from thirdparty.json It's build directly via the PackageMicrosoftGlobbing task --- Build/Tasks/thirdparty.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Build/Tasks/thirdparty.json b/Build/Tasks/thirdparty.json index 575986874cd..6c425aa16c3 100644 --- a/Build/Tasks/thirdparty.json +++ b/Build/Tasks/thirdparty.json @@ -54,11 +54,5 @@ "folder": "DNN Platform/Components/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/", "destination": "Install/Library", "extension": "resources" - }, - { - "name": "MicrosoftFileSystemGlobbing", - "folder": "DNN Platform/Components/Microsoft.Extensions.FileSystemGlobbing/", - "destination": "Install/Library", - "excludes": [ "**/*.xml" ] } ]