Skip to content

Commit

Permalink
Add package for MailKit
Browse files Browse the repository at this point in the history
  • Loading branch information
bdukes committed Mar 30, 2021

Verified

This commit was signed with the committer’s verified signature. The key has expired.
MSalopek MSalopek
1 parent 9f83285 commit dc39227
Showing 5 changed files with 138 additions and 0 deletions.
1 change: 1 addition & 0 deletions Build/Tasks/OtherPackages.cs
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ namespace DotNetNuke.Build.Tasks

/// <summary>A cake task to include other 3rd party packages.</summary>
[Dependency(typeof(PackageNewtonsoft))]
[Dependency(typeof(PackageMailKit))]
public sealed class OtherPackages : FrostingTask<Context>
{
/// <inheritdoc/>
68 changes: 68 additions & 0 deletions Build/Tasks/PackageMailKit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// 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.Reflection;
using System.Xml;

using Cake.Common.Diagnostics;
using Cake.Common.IO;
using Cake.Frosting;
using Dnn.CakeUtils;

/// <summary>A cake task to generate the MailKit package.</summary>
public sealed class PackageMailKit : FrostingTask<Context>
{
/// <inheritdoc/>
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<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}");
}
}

context.AddXmlFileToZip(packageZip, manifest, manifestPath.GetFilename().ToString(), append: true);
}
}
}
3 changes: 3 additions & 0 deletions Build/Tasks/packaging.json
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
"/bin/System.IdentityModel.Tokens.Jwt.*",
"/bin/Telerik.Web.UI.dll",
"/bin/Telerik.Web.UI.Skins.dll",
"/bin/BouncyCastle.Crypto.dll",
"/bin/MailKit.dll",
"/bin/MimeKit.dll",
"/Install/Module/DNNCE_Website.Deprecated_*_Install.zip"
],
"installInclude": ["/Install/InstallWizard.aspx.cs"],
21 changes: 21 additions & 0 deletions DNN Platform/Components/MailKit/License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (C) 2012-2020 .NET Foundation and Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
45 changes: 45 additions & 0 deletions DNN Platform/Components/MailKit/MailKit.dnn
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<dotnetnuke type="Package" version="5.0">
<packages>
<package name="DotNetNuke.MailKit" type="Library" version="2.10.1">
<friendlyName>MailKit Components</friendlyName>
<description>Libraries required for MailKit.</description>
<dependencies/>
<owner>
<name>DNN</name>
<organization>.NET Foundation</organization>
<url>https://dnncommunity.org</url>
<email>info@dnncommunity.org</email>
</owner>
<license>License.txt</license>
<releaseNotes>
This package includes MailKit assembly version 2.10.1.
Please go to http://www.mimekit.com/ to view release notes on this particular version.</releaseNotes>
<components>
<component type="Assembly">
<assemblies>
<assembly>
<path>bin</path>
<name>MailKit.dll</name>
<version>2.10.1</version>
</assembly>
<assembly>
<path>bin</path>
<name>MimeKit.dll</name>
<version>2.10.1</version>
</assembly>
<assembly>
<path>bin</path>
<name>BouncyCastle.Crypto.dll</name>
<version>1.8.8</version>
</assembly>
<assembly>
<path>bin</path>
<name>System.Buffers.dll</name>
<version>4.5.1</version>
</assembly>
</assemblies>
</component>
</components>
</package>
</packages>
</dotnetnuke>

0 comments on commit dc39227

Please sign in to comment.