Skip to content
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
2 changes: 1 addition & 1 deletion Build/BuildScripts/AEPackage.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CompressCss>True</CompressCss>
<UseResourceZipWorkingDirectory>True</UseResourceZipWorkingDirectory>
</PropertyGroup>

<Import Project="Package.Targets" />
Expand Down
32 changes: 3 additions & 29 deletions Build/BuildScripts/Package.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DotNetNukeMSBuildTasksLib>$(BuildScriptsPath)\DotNetNuke.MSBuild.Tasks.dll</DotNetNukeMSBuildTasksLib>
<YuiLib>$(BuildScriptsPath)\Yahoo.Yui.Compressor.MsBuild.dll</YuiLib>
</PropertyGroup>

<UsingTask TaskName="ExtensionPackager" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
Expand Down Expand Up @@ -35,8 +34,6 @@
</Code>
</Task>
</UsingTask>
<UsingTask AssemblyFile="$(YuiLib)" TaskName="CssCompressorTask" />
<!--<UsingTask AssemblyFile="$(YuiLib)" TaskName="JavaScriptCompressorTask" />-->

<Target Name="Package" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<XmlPeek Namespaces="&lt;Namespace Prefix='n' Uri='http://schemas.microsoft.com/developer/msbuild/2003' /&gt;"
Expand All @@ -49,9 +46,9 @@
</Output>
</ExtensionPackager>

<CallTarget Condition="'$(CompressCss)' == 'True'" Targets="Minification" />
<CallTarget Condition="'$(UseResourceZipWorkingDirectory)' == 'True'" Targets="RezipResources" />
<Copy SourceFiles="$(DNNFileName).dnn" DestinationFolder="$(MSBuildProjectDirectory)\Package" />
<Zip Condition="'$(CompressCss)' != 'True'" Files="@(Resources)" WorkingDirectory="$(MSBuildProjectDirectory)" ZipFileName="$(MSBuildProjectDirectory)\Package\Resources.zip" />
<Zip Condition="'$(UseResourceZipWorkingDirectory)' != 'True'" Files="@(Resources)" WorkingDirectory="$(MSBuildProjectDirectory)" ZipFileName="$(MSBuildProjectDirectory)\Package\Resources.zip" />

<ItemGroup>
<LicenseFiles Include="license.txt"/>
Expand All @@ -74,37 +71,14 @@
<RemoveDir Directories="$(MSBuildProjectDirectory)\Package" ContinueOnError="WarnAndContinue" />
</Target>

<Target Name="Minification">

<Target Name="RezipResources">
<MakeDir Directories="$(MSBuildProjectDirectory)\Package"/>
<Zip Files="@(Resources)" WorkingDirectory="$(MSBuildProjectDirectory)" ZipFileName="$(MSBuildProjectDirectory)\Package\Resources.zip" />
<Unzip ZipFileName="$(MSBuildProjectDirectory)\Package\Resources.zip" TargetDirectory="$(MSBuildProjectDirectory)\Package\Resources" />
<Delete Files="$(MSBuildProjectDirectory)\Package\Resources.zip" />
<ItemGroup>
<!--<_JSFilesToMinify Include="$(MSBuildProjectDirectory)\Package\Resources\**\*.js" Exclude="$(MSBuildProjectDirectory)\Package\Resources\**\*.min.js" />-->
<_Step2FilesToZip Include="$(MSBuildProjectDirectory)\Package\Resources\**\*" />
</ItemGroup>
<!--
<Message Text="Compressing Javascript files" Importance="high" />
<JavaScriptCompressorTask Files="@(_JSFilesToMinify)" ContinueOnError="WarnAndContinue" />
-->

<ItemGroup>
<_CSSFilesToCompress Include="$(MSBuildProjectDirectory)\*\*.css;$(MSBuildProjectDirectory)\*\*\*.css;$(MSBuildProjectDirectory)\*\*\*\*.css;$(MSBuildProjectDirectory)\*\*\*\*\*.css;" Exclude="Package\**\*;**\node_modules\**;**\WebApps\**" />
</ItemGroup>
<Message Text="Compressing the following CSS files:" Importance="high" />
<Message Text="%(_CSSFilesToCompress.Identity)" Importance="high" />

<CssCompressorTask
SourceFiles="@(_CSSFilesToCompress)"
DeleteSourceFiles="false"
OutputFile="$(MSBuildProjectDirectory)\Package\Resources\%(RecursiveDir)%(Filename)%(Extension)"
CompressionType="Standard"
LoggingType="Info"
PreserveComments="false"
LineBreakPosition="-1"
Condition="@(_CSSFilesToCompress->Count())!=0"
/>

<Zip Files="@(_Step2FilesToZip)" WorkingDirectory="$(ResourceZipWorkingDirectory)"
ZipFileName="$(MSBuildProjectDirectory)\Package\Resources.zip" />
Expand Down
Binary file removed Build/BuildScripts/Yahoo.Yui.Compressor.MsBuild.dll
Binary file not shown.
Binary file removed Build/BuildScripts/Yahoo.Yui.Compressor.dll
Binary file not shown.
1 change: 1 addition & 0 deletions Build/Tasks/OtherPackages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace DotNetNuke.Build.Tasks
[IsDependentOn(typeof(PackageSharpZipLib))]
[IsDependentOn(typeof(PackageMicrosoftExtensionsDependencyInjection))]
[IsDependentOn(typeof(PackageMicrosoftWebInfrastructure))]
[IsDependentOn(typeof(PackageMicrosoftCodeDomProvidersDotNetCompilerPlatform))]
public sealed class OtherPackages : FrostingTask<Context>
{
private static readonly string[] IncludeAll = ["**/*",];
Expand Down
10 changes: 2 additions & 8 deletions Build/Tasks/PackageAspNetMvc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@
namespace DotNetNuke.Build.Tasks;

/// <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")
{
}
}
public sealed class PackageAspNetMvc()
: PackageComponentTaskBase("AspNetMvc", "System.Web.Mvc.dll", "Microsoft.AspNetMvc");
10 changes: 2 additions & 8 deletions Build/Tasks/PackageAspNetWebApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@
namespace DotNetNuke.Build.Tasks;

/// <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")
{
}
}
public sealed class PackageAspNetWebApi()
: PackageComponentTaskBase("AspNetWebApi", "System.Web.Http.dll", "Microsoft.AspNetWebApi");
10 changes: 2 additions & 8 deletions Build/Tasks/PackageAspNetWebPages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@
namespace DotNetNuke.Build.Tasks;

/// <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")
{
}
}
public sealed class PackageAspNetWebPages()
: PackageComponentTaskBase("AspNetWebPages", "System.Web.WebPages.dll", "Microsoft.AspNetWebPages");
Original file line number Diff line number Diff line change
@@ -1,96 +1,121 @@
// 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.IO;
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>
{
private static readonly string[] AllFiles = ["*",];
private static readonly string[] ManifestFiles = ["*.dnn",];

/// <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, AllFiles, ManifestFiles));

var manifestPath = context.GetFiles(packageDir.Path.CombineWithFilePath("*.dnn").ToString()).Single();
context.Information($"Reading manifest from {manifestPath}");
var manifest = new XmlDocument();
using (var manifestReader = XmlReader.Create(new StringReader(context.ReadFile(manifestPath)), new XmlReaderSettings { XmlResolver = null, }))
{
manifest.Load(manifestReader);
}

var assemblies =
from XmlNode assemblyNode in manifest.SelectNodes("//assembly")
from XmlNode childNode in assemblyNode.ChildNodes
where childNode.LocalName.Equals("name", System.StringComparison.Ordinal)
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", System.StringComparison.Ordinal));
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);
}
}
// 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.IO;
using System.Linq;
using System.Threading.Tasks;
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 PackageComponentTaskBase : AsyncFrostingTask<Context>
{
private static readonly string[] AllFiles = ["*",];
private static readonly string[] ManifestFiles = ["*.dnn",];

/// <summary>Initializes a new instance of the <see cref="PackageComponentTaskBase"/> 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 PackageComponentTaskBase(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 Task RunAsync(Context context)
{
var binDir = GetBinDir(context);
var packageZip = this.GetPackageZipPath(context, binDir);
var packageDir = context.Directory($"DNN Platform/Components/{this.ComponentFolderName}");

context.Information($"Creating {packageZip}");
context.Zip(
packageDir.ToString(),
packageZip,
context.GetFilesByPatterns(packageDir, AllFiles, ManifestFiles));

var manifestPath = context.GetFiles(packageDir.Path.CombineWithFilePath("*.dnn").ToString()).Single();
context.Information($"Reading manifest from {manifestPath}");
var manifest = new XmlDocument();
using (var manifestReader = XmlReader.Create(new StringReader(context.ReadFile(manifestPath)), new XmlReaderSettings { XmlResolver = null, }))
{
manifest.Load(manifestReader);
}

var assemblies =
from XmlNode assemblyNode in manifest.SelectNodes("//assembly")
where assemblyNode.Attributes?["action"]?.Value != "UnRegister"
from XmlNode childNode in assemblyNode.ChildNodes
where childNode.LocalName.Equals("name", System.StringComparison.Ordinal)
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", System.StringComparison.Ordinal));
if (versionNode != null)
{
versionNode.InnerText = context.GetAssemblyFileVersion(assemblyPath);
context.Information($"Set {assemblyPath} version to {versionNode.InnerText}");
}
}

manifest.SelectSingleNode("//package[@version]").Attributes["version"].Value = this.GetPackageVersion(context, binDir);

context.AddXmlFileToZip(packageZip, manifest, manifestPath.GetFilename().ToString(), append: true);

return Task.CompletedTask;
}

/// <summary>Get the path to the <c>bin</c> directory, from which to get DLLs.</summary>
/// <param name="context">The context.</param>
/// <returns>The path.</returns>
protected static DirectoryPath GetBinDir(Context context)
{
return context.WebsiteDir.Path.Combine("bin");
}

/// <summary>Gets the path to the <c>zip</c> file generated by this task.</summary>
/// <param name="context">The context.</param>
/// <param name="binDir">The path to the <c>bin</c> directory (from <see cref="GetBinDir"/>).</param>
/// <returns>The file path.</returns>
protected FilePath GetPackageZipPath(Context context, DirectoryPath binDir)
{
return context.WebsiteDir.Path.CombineWithFilePath($"Install/Library/{this.ComponentName}_{this.GetPackageVersion(context, binDir)}_Install.zip");
}

private string GetPackageVersion(Context context, DirectoryPath binDir)
{
var mainAssemblyPath = binDir.CombineWithFilePath(this.PrimaryAssemblyName);
var packageVersion = context.GetAssemblyFileVersion(mainAssemblyPath);
return packageVersion;
}
}
10 changes: 2 additions & 8 deletions Build/Tasks/PackageHtmlSanitizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@
namespace DotNetNuke.Build.Tasks;

/// <summary>A cake task to generate the MailKit package.</summary>
public sealed class PackageHtmlSanitizer : PackageComponentTask
{
/// <summary>Initializes a new instance of the <see cref="PackageHtmlSanitizer"/> class.</summary>
public PackageHtmlSanitizer()
: base("HtmlSanitizer")
{
}
}
public sealed class PackageHtmlSanitizer()
: PackageComponentTaskBase("HtmlSanitizer");
10 changes: 2 additions & 8 deletions Build/Tasks/PackageMailKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@
namespace DotNetNuke.Build.Tasks;

/// <summary>A cake task to generate the MailKit package.</summary>
public sealed class PackageMailKit : PackageComponentTask
{
/// <summary>Initializes a new instance of the <see cref="PackageMailKit"/> class.</summary>
public PackageMailKit()
: base("MailKit")
{
}
}
public sealed class PackageMailKit()
: PackageComponentTaskBase("MailKit");
Loading
Loading