Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DotNetNuke.Newtonsoft.Json.dnn to reference version 13.0.3 #6174

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Build/ContextExtensions.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>Provides extensions to <see cref="Context"/>.</summary>
public static class ContextExtensions
{
/// <summary>Gets the <see cref="FileVersionInfo.FileVersion"/> for an assembly.</summary>
/// <param name="context">The cake context.</param>
/// <param name="assemblyPath">The path to the assembly file.</param>
/// <returns>The file version.</returns>
public static string GetAssemblyFileVersion(this Context context, FilePath assemblyPath)
{
return FileVersionInfo.GetVersionInfo(context.MakeAbsolute(assemblyPath).FullPath).FileVersion;
}
}
69 changes: 7 additions & 62 deletions Build/Tasks/PackageAspNetMvc.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>A cake task to generate the ASP.NET MVC package.</summary>
public sealed class PackageAspNetMvc : FrostingTask<Context>
/// <summary>A cake task to generate the ASP.NET MVC package.</summary>
public sealed class PackageAspNetMvc : PackageComponentTask
{
/// <summary>Initializes a new instance of the <see cref="PackageAspNetMvc"/> class.</summary>
public PackageAspNetMvc()
: base("AspNetMvc", "System.Web.Mvc.dll", "Microsoft.AspNetMvc")
{
/// <inheritdoc/>
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<XmlNode>()
.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);
}
}
}
69 changes: 7 additions & 62 deletions Build/Tasks/PackageAspNetWebApi.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>A cake task to generate the ASP.NET Web API package.</summary>
public sealed class PackageAspNetWebApi : FrostingTask<Context>
/// <summary>A cake task to generate the ASP.NET Web API package.</summary>
public sealed class PackageAspNetWebApi : PackageComponentTask
{
/// <summary>Initializes a new instance of the <see cref="PackageAspNetWebApi"/> class.</summary>
public PackageAspNetWebApi()
: base("AspNetWebApi", "System.Web.Http.dll", "Microsoft.AspNetWebApi")
{
/// <inheritdoc/>
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<XmlNode>()
.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);
}
}
}
69 changes: 7 additions & 62 deletions Build/Tasks/PackageAspNetWebPages.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>A cake task to generate the ASP.NET Web Pages package.</summary>
public sealed class PackageAspNetWebPages : FrostingTask<Context>
/// <summary>A cake task to generate the ASP.NET Web Pages package.</summary>
public sealed class PackageAspNetWebPages : PackageComponentTask
{
/// <summary>Initializes a new instance of the <see cref="PackageAspNetWebPages"/> class.</summary>
public PackageAspNetWebPages()
: base("AspNetWebPages", "System.Web.WebPages.dll", "Microsoft.AspNetWebPages")
{
/// <inheritdoc/>
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<XmlNode>()
.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);
}
}
}
87 changes: 87 additions & 0 deletions Build/Tasks/PackageComponentTask.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>Provides the base functionality for packaging a folder inside Components.</summary>
public abstract class PackageComponentTask : FrostingTask<Context>
{
/// <summary>Initializes a new instance of the <see cref="PackageComponentTask"/> class.</summary>
/// <param name="componentName">The name of the component.</param>
/// <param name="primaryAssemblyName">The name of the primary assembly.</param>
/// <param name="componentFolderName">The name of the folder in <c>DNN Platform/Components/</c>.</param>
protected PackageComponentTask(string componentName, FilePath primaryAssemblyName = null, DirectoryPath componentFolderName = null)
{
this.ComponentName = componentName;
this.ComponentFolderName = componentFolderName ?? componentName;
this.PrimaryAssemblyName = primaryAssemblyName ?? $"{componentName}.dll";
}

/// <summary>Gets the name of the component.</summary>
public string ComponentName { get; }

/// <summary>Gets the name of the folder in <c>DNN Platform/Components/</c> where the component files are.</summary>
public DirectoryPath ComponentFolderName { get; }

/// <summary>Gets the name of the primary assembly.</summary>
public FilePath PrimaryAssemblyName { get; }

/// <inheritdoc />
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<XmlNode>()
.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);
}
}
Loading