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..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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mainAssemblyPath).FullPath).FileVersion; - - 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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; - 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 db25bebb34f..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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mainAssemblyPath).FullPath).FileVersion; - - 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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; - 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 d9ef115b9f6..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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mainAssemblyPath).FullPath).FileVersion; - - 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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; - 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 5fb6b4157ea..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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mailKitPath).FullPath).FileVersion; - - 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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; - 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 f529e6deed5..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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mainAssemblyPath).FullPath).FileVersion; - - 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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; - 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 651cb5804a9..11b60f5aaf0 100644 --- a/Build/Tasks/PackageNewtonsoft.cs +++ b/Build/Tasks/PackageNewtonsoft.cs @@ -1,38 +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.Linq; - - 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 assy in context.GetFiles(context.WebsiteFolder + "bin/Newtonsoft.Json.dll")) - { - version = System.Diagnostics.FileVersionInfo.GetVersionInfo(assy.FullPath).FileVersion; - } - - 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 4396939b865..6b9bd3dfa33 100644 --- a/Build/Tasks/PackageSharpZipLib.cs +++ b/Build/Tasks/PackageSharpZipLib.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 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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mainAssemblyPath).FullPath).FileVersion; - - 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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; - 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 4e4af65e70e..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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(mainAssemblyPath).FullPath).FileVersion; - - 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 = FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion; - 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/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" ] } ] 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