From dc77110813264c673dd6f5ad7c667eb3e0da1b79 Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Fri, 22 Mar 2024 22:32:14 +0800
Subject: [PATCH] enhance: simplify the build process.
---
.github/workflows/bump-up-version.yml | 33 ++
.gitignore | 17 +-
LICENSE | 2 +-
build/LICENSE | 21 -
.../{tools => }/VisualStudioToolsManifest.xml | 0
build/build-for-myget.nuspec | 279 -----------
build/build.Lang.template | 61 ---
build/build.cake | 438 ++++++++++++++++--
build/build.config.xml | 23 +
build/build.nuspec | 104 -----
build/build.ps1 | 256 ----------
build/create_lang_nuspec_file.py | 15 -
build/create_nupkg_file.ps1 | 4 -
build/lang.nuspec.template | 24 +
build/lib.nuspec.template | 25 +
build/myget.nuspec.template | 23 +
build/tools/packages.config | 4 -
build/version-bump-up-manual.md | 11 -
18 files changed, 528 insertions(+), 812 deletions(-)
create mode 100644 .github/workflows/bump-up-version.yml
delete mode 100644 build/LICENSE
rename build/{tools => }/VisualStudioToolsManifest.xml (100%)
delete mode 100644 build/build-for-myget.nuspec
delete mode 100644 build/build.Lang.template
create mode 100644 build/build.config.xml
delete mode 100644 build/build.nuspec
delete mode 100644 build/build.ps1
delete mode 100644 build/create_lang_nuspec_file.py
delete mode 100644 build/create_nupkg_file.ps1
create mode 100644 build/lang.nuspec.template
create mode 100644 build/lib.nuspec.template
create mode 100644 build/myget.nuspec.template
delete mode 100644 build/tools/packages.config
delete mode 100644 build/version-bump-up-manual.md
diff --git a/.github/workflows/bump-up-version.yml b/.github/workflows/bump-up-version.yml
new file mode 100644
index 00000000..dec88160
--- /dev/null
+++ b/.github/workflows/bump-up-version.yml
@@ -0,0 +1,33 @@
+name: Bump up version
+
+on:
+ workflow_dispatch:
+ inputs:
+ pre_release:
+ description: 'is preview'
+ type: boolean
+ required: true
+ default: false
+
+jobs:
+ bump-up-version:
+ runs-on: windows-latest
+ steps:
+ - name: Checkout repo
+ uses: actions/checkout@master
+ with:
+ ref: ${{ github.head_ref }}
+
+ - name: Setup .NET Core SDK
+ uses: actions/setup-dotnet@master
+ with:
+ dotnet-version: '8.0.x'
+ include-prerelease: true
+
+ - name: Build
+ working-directory: ./build
+ run: |
+ dotnet new tool-manifest
+ dotnet tool install cake.tool --version 4.0.0
+ dotnet tool install minver-cli --version 3.0.0
+ dotnet cake --username="${{ github.actor }}" --email="836904362@qq.com" --pre-release=${{ inputs.pre_release }}
diff --git a/.gitignore b/.gitignore
index 43384808..64fc0f13 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,19 +1,8 @@
.vs
+.config
*.user
-*.xml
[Bb]in/
[Oo]bj/
packages/
-build/*
-!build/build.cake
-!build/build.Lang.template
-!build/create_lang_nuspec_file.py
-!build/create_nupkg_file.ps1
-!build/build.ps1
-!build/version-bump-up-manual.md
-!build/LICENSE
-!build/icon.png
-!build/tools/
-build/tools/*
-!build/tools/packages.config
-!build/tools/VisualStudioToolsManifest.xml
+build/outputs
+build/tools
diff --git a/LICENSE b/LICENSE
index fce637b7..a1312849 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2018-2024 HandyOrg
+Copyright © HandyOrg 2018-2024
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/build/LICENSE b/build/LICENSE
deleted file mode 100644
index fce637b7..00000000
--- a/build/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2018-2024 HandyOrg
-
-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.
diff --git a/build/tools/VisualStudioToolsManifest.xml b/build/VisualStudioToolsManifest.xml
similarity index 100%
rename from build/tools/VisualStudioToolsManifest.xml
rename to build/VisualStudioToolsManifest.xml
diff --git a/build/build-for-myget.nuspec b/build/build-for-myget.nuspec
deleted file mode 100644
index 4ebdd54a..00000000
--- a/build/build-for-myget.nuspec
+++ /dev/null
@@ -1,279 +0,0 @@
-
-
-
- HandyControl
- 3.5.2
- HandyOrg
- HandyOrg
- HandyOrg
- true
- LICENSE
- icon.png
- https://github.com/NaBian/HandyControl
- Contains some simple and commonly used WPF controls
- Copyright © HandyOrg 2018-2024
- WPF C# Control
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build/build.Lang.template b/build/build.Lang.template
deleted file mode 100644
index c1c067bd..00000000
--- a/build/build.Lang.template
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
- HandyControl.Lang.{lang}
- 3.5.2
- HandyOrg
- HandyOrg
- HandyOrg
- true
- LICENSE
- icon.png
- https://github.com/HandyOrg/HandyControl
- Contains some simple and commonly used WPF controls
- Changes are detailed at https://github.com/HandyOrg/HandyControl/releases
- Copyright © HandyOrg 2018-2024
- WPF C# Control
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build/build.cake b/build/build.cake
index 599f985c..d5c3c79d 100644
--- a/build/build.cake
+++ b/build/build.cake
@@ -1,55 +1,409 @@
-var target = Argument("target", "Build");
+#addin nuget:?package=Cake.Git&version=4.0.0
+#addin nuget:?package=Cake.MinVer&version=3.0.0
+#tool nuget:?package=NuGet.CommandLine&version=6.9.1
-Task("Clean")
- .Does(() =>
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+using static System.IO.Directory;
+using static System.IO.File;
+using static System.IO.Path;
+
+const string HandyControlBirthYear = "2018";
+const string TagPrefix = "v";
+const string RepositoryFolder = "..";
+const string PropsFilePath = $"{RepositoryFolder}/src/Directory.Build.Props";
+const string LicenseFilePath = $"{RepositoryFolder}/LICENSE";
+const string LibNuspecTemplateFilePath = "lib.nuspec.template";
+const string LangNuspecTemplateFilePath = "lang.nuspec.template";
+const string ResxFileFolder = $"{RepositoryFolder}/src/Shared/HandyControl_Shared/Properties/Langs";
+const string ConfigFilePath = "build.config.xml";
+
+var target = Argument("target", "build");
+var preReleasePhase = Argument("pre-release-phase", "rc");
+var preRelease = Argument("pre-release", false);
+var username = Argument("username", "NaBian");
+var email = Argument("email, "836904362@qq.com");
+
+var libVersion = "";
+var nugetVersion = "";
+var nugetFolder = "";
+var year = $"{DateTime.Now.Year}";
+var copyright = $"Copyright © HandyOrg {HandyControlBirthYear}-{year}";
+var libNuspecFilePath = "";
+var langNuspecFilePath = "";
+var buildConfig = new BuildConfig();
+
+Setup(context =>
{
- CleanDirectory("lib");
+ buildConfig = LoadBuildConfig();
+ CleanDirectory(buildConfig.OutputsFolder);
+ CreateDirectory(nugetFolder);
+
+ context.Information($"preReleasePhase: {preReleasePhase}");
+ context.Information($"preRelease: {preRelease}");
+ FillVersions(GetAutoIncrement());
+ context.Information($"libVersion: {libVersion}");
+ context.Information($"nugetVersion: {nugetVersion}");
+
+ Copy(LibNuspecTemplateFilePath, libNuspecFilePath, true);
+ Copy(LangNuspecTemplateFilePath, langNuspecFilePath, true);
});
-Task("Build")
- .IsDependentOn("Clean")
+#region TASKS
+
+Task("update license")
.Does(() =>
{
- var settingsNet40 = new DotNetCoreBuildSettings
+ const int copyrightIndex = 2;
+
+ string[] lines = ReadAllLines(LicenseFilePath, Encoding.UTF8);
+ lines[copyrightIndex] = copyright;
+ WriteAllLines(LicenseFilePath, lines);
+});
+
+Task("update version")
+ .Does(() =>
+{
+ if (libVersion != "")
{
- Configuration = "Release-Net40",
- OutputDirectory = "lib/net40"
- };
+ var document = LoadXmlDocument(PropsFilePath);
+ document.DocumentElement.SelectSingleNode("//PropertyGroup/Version").InnerText = libVersion;
+ document.DocumentElement.SelectSingleNode("//PropertyGroup/FileVersion").InnerText = libVersion;
+ document.DocumentElement.SelectSingleNode("//PropertyGroup/AssemblyVersion").InnerText = libVersion;
+ SaveXmlDocument(document, PropsFilePath);
+ }
- DotNetCoreBuild("../src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj", settingsNet40);
-
- var frameworkList = new List
+ if (nugetVersion != "")
{
- "net45",
- "net451",
- "net452",
- "net46",
- "net461",
- "net462",
- "net47",
- "net471",
- "net472",
- "net48",
- "net481",
- "netcoreapp3.0",
- "netcoreapp3.1",
- "net5.0-windows",
- "net6.0-windows",
- "net7.0-windows",
- "net8.0-windows"
- };
-
- foreach (var framework in frameworkList)
- {
- var settings = new DotNetCoreBuildSettings
- {
- Configuration = "Release",
- Framework = framework,
- OutputDirectory = $"lib/{framework.Split('-')[0]}"
- };
-
- DotNetCoreBuild("../src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj", settings);
+ ReplaceFileText(libNuspecFilePath, "version", nugetVersion);
+ ReplaceFileText(langNuspecFilePath, "version", nugetVersion);
}
});
+Task("update copyright")
+ .Does(() =>
+{
+ var document = LoadXmlDocument(PropsFilePath);
+ document.DocumentElement.SelectSingleNode("//PropertyGroup/Copyright").InnerText = copyright;
+ SaveXmlDocument(document, PropsFilePath);
+
+ ReplaceFileText(libNuspecFilePath, "year", year);
+ ReplaceFileText(langNuspecFilePath, "year", year);
+});
+
+Task("commit files")
+ .Does(() =>
+{
+ GitAddAll(RepositoryFolder);
+ GitCommit(RepositoryFolder, username, email, $"chore: [AUTO] bump up version to {nugetVersion}.");
+});
+
+Task("create tag")
+ .Does(() =>
+{
+ GitTag(RepositoryFolder, $"{TagPrefix}{nugetVersion}");
+});
+
+Task("update nuget sha")
+ .Does(() =>
+{
+ var lastCommit = GitLogTip(RepositoryFolder);
+
+ ReplaceFileText(libNuspecFilePath, "commit", lastCommit.Sha);
+ ReplaceFileText(langNuspecFilePath, "commit", lastCommit.Sha);
+});
+
+Task("add nuget dependencies")
+ .Does(() =>
+{
+ AddDependenciesItem(libNuspecFilePath);
+ AddDependenciesItem(langNuspecFilePath);
+
+ void AddDependenciesItem(string xmlFilePath)
+ {
+ XmlDocument document = LoadXmlDocument(xmlFilePath);
+ foreach (BuildTask task in buildConfig.BuildTasks)
+ {
+ var frameworkItem = document.CreateElement("group");
+ frameworkItem.SetAttribute("targetFramework", task.Target);
+ document.DocumentElement.SelectSingleNode("//metadata/dependencies").AppendChild(frameworkItem);
+ SaveXmlDocument(document, xmlFilePath, indentation: 2);
+ }
+ }
+});
+
+Task("add nuget files")
+ .Does(() =>
+{
+ XmlDocument libDocument = LoadXmlDocument(libNuspecFilePath);
+ XmlDocument langDocument = LoadXmlDocument(langNuspecFilePath);
+
+ foreach (BuildTask task in buildConfig.BuildTasks)
+ {
+ var frameworkFolder = $@"lib\{task.OutputsFolder}";
+
+ if (!IsFramework(task.Framework))
+ {
+ AddFile(libDocument, $@"{frameworkFolder}\HandyControl.deps.json");
+ }
+ AddFile(libDocument, $@"{frameworkFolder}\HandyControl.dll");
+ AddFile(libDocument, $@"{frameworkFolder}\HandyControl.pdb");
+ AddFile(libDocument, $@"{frameworkFolder}\HandyControl.xml");
+ AddFile(langDocument, $@"{frameworkFolder}\{{lang}}\HandyControl.resources.dll");
+ }
+
+ SaveXmlDocument(libDocument, libNuspecFilePath, indentation: 2);
+ SaveXmlDocument(langDocument, langNuspecFilePath, indentation: 2);
+
+ void AddFile(XmlDocument document, string filePath)
+ {
+ var fileItem = document.CreateElement("file");
+ fileItem.SetAttribute("src", $@"..\{filePath}");
+ fileItem.SetAttribute("target", filePath);
+ document.DocumentElement.SelectSingleNode("//files").AppendChild(fileItem);
+ }
+});
+
+Task("build lib")
+ .Does(() =>
+{
+ foreach (var task in buildConfig.BuildTasks)
+ {
+ if (!task.BuildLib)
+ {
+ continue;
+ }
+
+ DotNetBuild
+ (
+ $"{RepositoryFolder}/src/{task.Domain}/HandyControl_{task.Domain}/HandyControl_{task.Domain}.csproj",
+ new DotNetBuildSettings
+ {
+ Configuration = task.Configuration,
+ Framework = task.Framework,
+ OutputDirectory = $"{buildConfig.OutputsFolder}/lib/{task.OutputsFolder}",
+ }
+ );
+ }
+});
+
+Task("build demo")
+ .Does(() =>
+{
+ foreach (var task in buildConfig.BuildTasks)
+ {
+ if (!task.BuildDemo)
+ {
+ continue;
+ }
+
+ DotNetBuild
+ (
+ $"{RepositoryFolder}/src/{task.Domain}/HandyControlDemo_{task.Domain}/HandyControlDemo_{task.Domain}.csproj",
+ new DotNetBuildSettings
+ {
+ Configuration = task.Configuration,
+ Framework = task.Framework,
+ OutputDirectory = $"{buildConfig.OutputsFolder}/demo/{task.OutputsFolder}",
+ }
+ );
+ }
+});
+
+Task("create lang nuspec files")
+ .Does(() =>
+{
+ string templateContent = ReadAllText(langNuspecFilePath, Encoding.UTF8);
+
+ foreach (string lang in GetAllLangs())
+ {
+ string langFilePath = Combine(nugetFolder, $"lang.{lang}.nuspec");
+ WriteAllText(langFilePath, templateContent.Replace("{lang}", lang));
+ }
+});
+
+Task("pack nuspec files")
+ .Does(() =>
+{
+ string nugetExePath = Context.Tools.Resolve("nuget.exe").FullPath;
+ StartProcess(nugetExePath, $"pack {nugetFolder}/lib.nuspec -Symbols -SymbolPackageFormat snupkg -OutputDirectory {nugetFolder}");
+ foreach (string nuspecFilePath in EnumerateFiles(nugetFolder, "lang.*.nuspec"))
+ {
+ StartProcess(nugetExePath, $"pack {nuspecFilePath} -OutputDirectory {nugetFolder}");
+ }
+});
+
+Task("build")
+ .IsDependentOn("update license")
+ .IsDependentOn("update version")
+ .IsDependentOn("update copyright")
+ .IsDependentOn("commit files")
+ .IsDependentOn("create tag")
+ .IsDependentOn("update nuget sha")
+ .IsDependentOn("add nuget dependencies")
+ .IsDependentOn("add nuget files")
+ .IsDependentOn("build lib")
+ .IsDependentOn("build demo")
+ .IsDependentOn("create lang nuspec files")
+ .IsDependentOn("pack nuspec files")
+ ;
+
RunTarget(target);
+
+#endregion
+
+#region HELP FUNCTIONS
+
+private XmlDocument LoadXmlDocument(string xmlFilePath)
+{
+ var document = new XmlDocument();
+
+ using (var reader = new XmlTextReader(xmlFilePath))
+ {
+ reader.Namespaces = false;
+ document.Load(reader);
+ }
+
+ return document;
+}
+
+private void SaveXmlDocument(XmlDocument document, string xmlFilePath, int indentation = 4)
+{
+ using (var writer = new XmlTextWriter(xmlFilePath, Encoding.UTF8))
+ {
+ writer.Formatting = Formatting.Indented;
+ writer.Indentation = indentation;
+ writer.Namespaces = false;
+ document.WriteContentTo(writer);
+ }
+}
+
+private void ReplaceFileText(string filePath, string key, string value)
+{
+ WriteAllText(
+ filePath,
+ ReadAllText(filePath, Encoding.UTF8).Replace($"{{{key}}}", value)
+ );
+}
+
+private void FillVersions(MinVerAutoIncrement? autoIncrement)
+{
+ if (autoIncrement is null)
+ {
+ return;
+ }
+
+ var settings = new MinVerSettings
+ {
+ TagPrefix = TagPrefix,
+ DefaultPreReleasePhase = preReleasePhase,
+ AutoIncrement = autoIncrement,
+ };
+ var minVer = MinVer(settings);
+
+ libVersion = minVer.FileVersion;
+ nugetVersion = preRelease
+ ? $"{minVer.Major}.{minVer.Minor}.{minVer.Patch}-{minVer.PreRelease}"
+ : $"{minVer.Major}.{minVer.Minor}.{minVer.Patch}";
+}
+
+private MinVerAutoIncrement? GetAutoIncrement()
+{
+ const string minorKey = "feat:";
+
+ var lastTag = GitTags(RepositoryFolder, true).Last();
+ var sha = lastTag.Target.ToString();
+ var logs = GitLog(RepositoryFolder, sha);
+
+ if (logs.Count == 0)
+ {
+ return null;
+ }
+
+ foreach (var log in logs.Take(logs.Count - 1))
+ {
+ if (log.Message.StartsWith(minorKey))
+ {
+ return MinVerAutoIncrement.Minor;
+ }
+ }
+
+ return MinVerAutoIncrement.Patch;
+}
+
+private bool IsFramework(string framework) => !framework.Contains(".");
+
+private IEnumerable GetAllLangs()
+{
+ foreach (string resxFilePath in EnumerateFiles(ResxFileFolder, "Lang.*.resx"))
+ {
+ yield return GetFileNameWithoutExtension(resxFilePath.Replace("Lang.", ""));
+ }
+}
+
+private BuildConfig LoadBuildConfig()
+{
+ var buildConfig = new BuildConfig();
+ var configDocument = LoadXmlDocument(ConfigFilePath);
+
+ var outputsItem = configDocument.DocumentElement.SelectSingleNode("//config/outputsFolder");
+ buildConfig.OutputsFolder = outputsItem.InnerText;
+ nugetFolder = $"{buildConfig.OutputsFolder}/nuget";
+ libNuspecFilePath = $"{nugetFolder}/{GetFileNameWithoutExtension(LibNuspecTemplateFilePath)}";
+ langNuspecFilePath = $"{nugetFolder}/{LangNuspecTemplateFilePath}";
+
+ var tasksItem = configDocument.DocumentElement.SelectSingleNode("//config/tasks");
+ foreach (XmlNode node in tasksItem.ChildNodes)
+ {
+ try
+ {
+ buildConfig.BuildTasks.Add(new BuildTask
+ {
+ Framework = node.Attributes["framework"].Value,
+ Target = node.Attributes["target"].Value,
+ OutputsFolder = node.Attributes["outputsFolder"].Value,
+ Configuration = node.Attributes["configuration"].Value,
+ Domain = node.Attributes["domain"].Value,
+ BuildLib = bool.Parse(node.Attributes["buildLib"].Value),
+ BuildDemo = bool.Parse(node.Attributes["buildDemo"].Value),
+ });
+ }
+ catch
+ {
+ // ignored
+ }
+ }
+
+ return buildConfig;
+}
+
+#endregion
+
+#region INNER TYPES
+
+public class BuildConfig
+{
+ public string OutputsFolder { get; set; }
+
+ public List BuildTasks { get; set; } = new();
+}
+
+public class BuildTask
+{
+ public string Framework { get; set; }
+
+ public string Target { get; set; }
+
+ public string OutputsFolder { get; set; }
+
+ public string Configuration { get; set; }
+
+ public string Domain { get; set; }
+
+ public bool BuildLib { get; set; }
+
+ public bool BuildDemo { get; set; }
+}
+
+#endregion
diff --git a/build/build.config.xml b/build/build.config.xml
new file mode 100644
index 00000000..62ed211a
--- /dev/null
+++ b/build/build.config.xml
@@ -0,0 +1,23 @@
+
+ outputs
+
+
+
+
+
diff --git a/build/build.nuspec b/build/build.nuspec
deleted file mode 100644
index 4df3cfa2..00000000
--- a/build/build.nuspec
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
- HandyControl
- 3.5.2
- HandyOrg
- HandyOrg
- HandyOrg
- true
- LICENSE
- icon.png
- https://github.com/HandyOrg/HandyControl
- Contains some simple and commonly used WPF controls
- Changes are detailed at https://github.com/HandyOrg/HandyControl/releases
- Copyright © HandyOrg 2018-2024
- WPF C# Control
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build/build.ps1 b/build/build.ps1
deleted file mode 100644
index 23a48b73..00000000
--- a/build/build.ps1
+++ /dev/null
@@ -1,256 +0,0 @@
-##########################################################################
-# This is the Cake bootstrapper script for PowerShell.
-# This file was downloaded from https://github.com/cake-build/resources
-# Feel free to change this file to fit your needs.
-##########################################################################
-
-<#
-
-.SYNOPSIS
-This is a Powershell script to bootstrap a Cake build.
-
-.DESCRIPTION
-This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
-and execute your Cake build script with the parameters you provide.
-
-.PARAMETER Script
-The build script to execute.
-.PARAMETER Target
-The build script target to run.
-.PARAMETER Configuration
-The build configuration to use.
-.PARAMETER Verbosity
-Specifies the amount of information to be displayed.
-.PARAMETER ShowDescription
-Shows description about tasks.
-.PARAMETER DryRun
-Performs a dry run.
-.PARAMETER SkipToolPackageRestore
-Skips restoring of packages.
-.PARAMETER ScriptArgs
-Remaining arguments are added here.
-
-.LINK
-https://cakebuild.net
-
-#>
-
-[CmdletBinding()]
-Param(
- [string]$Script = "build.cake",
- [string]$Target,
- [string]$Configuration,
- [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
- [string]$Verbosity,
- [switch]$ShowDescription,
- [Alias("WhatIf", "Noop")]
- [switch]$DryRun,
- [switch]$SkipToolPackageRestore,
- [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
- [string[]]$ScriptArgs
-)
-
-# Attempt to set highest encryption available for SecurityProtocol.
-# PowerShell will not set this by default (until maybe .NET 4.6.x). This
-# will typically produce a message for PowerShell v2 (just an info
-# message though)
-try {
- # Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48)
- # Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
- # exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
- # installed (.NET 4.5 is an in-place upgrade).
- # PowerShell Core already has support for TLS 1.2 so we can skip this if running in that.
- if (-not $IsCoreCLR) {
- [System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
- }
- } catch {
- Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3'
- }
-
-[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
-function MD5HashFile([string] $filePath)
-{
- if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf))
- {
- return $null
- }
-
- [System.IO.Stream] $file = $null;
- [System.Security.Cryptography.MD5] $md5 = $null;
- try
- {
- $md5 = [System.Security.Cryptography.MD5]::Create()
- $file = [System.IO.File]::OpenRead($filePath)
- return [System.BitConverter]::ToString($md5.ComputeHash($file))
- }
- finally
- {
- if ($file -ne $null)
- {
- $file.Dispose()
- }
- }
-}
-
-function GetProxyEnabledWebClient
-{
- $wc = New-Object System.Net.WebClient
- $proxy = [System.Net.WebRequest]::GetSystemWebProxy()
- $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
- $wc.Proxy = $proxy
- return $wc
-}
-
-Write-Host "Preparing to run build script..."
-
-if(!$PSScriptRoot){
- $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
-}
-
-$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
-$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins"
-$MODULES_DIR = Join-Path $TOOLS_DIR "Modules"
-$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
-$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
-$NUGET_URL = "https://github.com/HandyOrg/HandyOrgResource/blob/master/Tools/nuget.exe?raw=true"
-$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
-$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
-$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config"
-$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"
-
-# Make sure tools folder exists
-if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
- Write-Verbose -Message "Creating tools directory..."
- New-Item -Path $TOOLS_DIR -Type Directory | Out-Null
-}
-
-# Make sure that packages.config exist.
-if (!(Test-Path $PACKAGES_CONFIG)) {
- Write-Verbose -Message "Downloading packages.config..."
- try {
- $wc = GetProxyEnabledWebClient
- $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG)
- } catch {
- Throw "Could not download packages.config."
- }
-}
-
-# Try find NuGet.exe in path if not exists
-if (!(Test-Path $NUGET_EXE)) {
- Write-Verbose -Message "Trying to find nuget.exe in PATH..."
- $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) }
- $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
- if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
- Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
- $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
- }
-}
-
-# Try download NuGet.exe if not exists
-if (!(Test-Path $NUGET_EXE)) {
- Write-Verbose -Message "Downloading NuGet.exe..."
- try {
- $wc = GetProxyEnabledWebClient
- $wc.DownloadFile($NUGET_URL, $NUGET_EXE)
- } catch {
- Throw "Could not download NuGet.exe."
- }
-}
-
-# Save nuget.exe path to environment to be available to child processed
-$env:NUGET_EXE = $NUGET_EXE
-$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
- "mono `"$NUGET_EXE`""
-} else {
- "`"$NUGET_EXE`""
-}
-
-# Restore tools from NuGet?
-if(-Not $SkipToolPackageRestore.IsPresent) {
- Push-Location
- Set-Location $TOOLS_DIR
-
- # Check for changes in packages.config and remove installed tools if true.
- [string] $md5Hash = MD5HashFile $PACKAGES_CONFIG
- if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
- ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
- Write-Verbose -Message "Missing or changed package.config hash..."
- Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery |
- Remove-Item -Recurse -Force
- }
-
- Write-Verbose -Message "Restoring tools from NuGet..."
-
- $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
-
- if ($LASTEXITCODE -ne 0) {
- Throw "An error occurred while restoring NuGet tools."
- }
- else
- {
- $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
- }
- Write-Verbose -Message ($NuGetOutput | Out-String)
-
- Pop-Location
-}
-
-# Restore addins from NuGet
-if (Test-Path $ADDINS_PACKAGES_CONFIG) {
- Push-Location
- Set-Location $ADDINS_DIR
-
- Write-Verbose -Message "Restoring addins from NuGet..."
- $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
-
- if ($LASTEXITCODE -ne 0) {
- Throw "An error occurred while restoring NuGet addins."
- }
-
- Write-Verbose -Message ($NuGetOutput | Out-String)
-
- Pop-Location
-}
-
-# Restore modules from NuGet
-if (Test-Path $MODULES_PACKAGES_CONFIG) {
- Push-Location
- Set-Location $MODULES_DIR
-
- Write-Verbose -Message "Restoring modules from NuGet..."
- $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
-
- if ($LASTEXITCODE -ne 0) {
- Throw "An error occurred while restoring NuGet modules."
- }
-
- Write-Verbose -Message ($NuGetOutput | Out-String)
-
- Pop-Location
-}
-
-# Make sure that Cake has been installed.
-if (!(Test-Path $CAKE_EXE)) {
- Throw "Could not find Cake.exe at $CAKE_EXE"
-}
-
-$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
- "mono `"$CAKE_EXE`""
-} else {
- "`"$CAKE_EXE`""
-}
-
- # Build an array (not a string) of Cake arguments to be joined later
-$cakeArguments = @()
-if ($Script) { $cakeArguments += "`"$Script`"" }
-if ($Target) { $cakeArguments += "-target=`"$Target`"" }
-if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
-if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
-if ($ShowDescription) { $cakeArguments += "-showdescription" }
-if ($DryRun) { $cakeArguments += "-dryrun" }
-$cakeArguments += $ScriptArgs
-
-# Start Cake
-Write-Host "Running build script..."
-Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")"
-exit $LASTEXITCODE
diff --git a/build/create_lang_nuspec_file.py b/build/create_lang_nuspec_file.py
deleted file mode 100644
index 91372f2e..00000000
--- a/build/create_lang_nuspec_file.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from pathlib import Path
-
-
-def main():
- with open('build.Lang.template', 'r', encoding='utf-8') as template_file:
- template_content = template_file.read()
-
- resx_file_folder = Path('../src/Shared/HandyControl_Shared/Properties/Langs')
- for lang in [path.stem.lstrip('Lang.') for path in resx_file_folder.glob('Lang.*.resx')]:
- with open(f'build.Lang.{lang}.nuspec', 'w', encoding='utf-8') as nuspec_file:
- nuspec_file.write(template_content.format(lang=lang))
-
-
-if __name__ == '__main__':
- main()
diff --git a/build/create_nupkg_file.ps1 b/build/create_nupkg_file.ps1
deleted file mode 100644
index d6029abb..00000000
--- a/build/create_nupkg_file.ps1
+++ /dev/null
@@ -1,4 +0,0 @@
-./tools/nuget pack build.nuspec -Symbols -SymbolPackageFormat snupkg
-Get-ChildItem -Path ./build.Lang.*.nuspec | ForEach-Object {
- ./tools/nuget pack $_
-}
diff --git a/build/lang.nuspec.template b/build/lang.nuspec.template
new file mode 100644
index 00000000..5b0268e3
--- /dev/null
+++ b/build/lang.nuspec.template
@@ -0,0 +1,24 @@
+
+
+
+ HandyControl.Lang.{lang}
+ {version}
+ HandyOrg
+ HandyOrg
+ HandyOrg
+ true
+ LICENSE
+ icon.png
+ https://github.com/HandyOrg/HandyControl
+ Contains some simple and commonly used WPF controls
+ Changes are detailed at https://github.com/HandyOrg/HandyControl/releases
+ Copyright © HandyOrg 2018-{year}
+ WPF C# Control
+
+
+
+
+
+
+
+
diff --git a/build/lib.nuspec.template b/build/lib.nuspec.template
new file mode 100644
index 00000000..c1d5ecb8
--- /dev/null
+++ b/build/lib.nuspec.template
@@ -0,0 +1,25 @@
+
+
+
+ HandyControl
+ {version}
+ HandyOrg
+ HandyOrg
+ HandyOrg
+ true
+ LICENSE
+ icon.png
+ https://github.com/HandyOrg/HandyControl
+ Contains some simple and commonly used WPF controls
+ Changes are detailed at https://github.com/HandyOrg/HandyControl/releases
+ Copyright © HandyOrg 2018-{year}
+ WPF C# Control
+
+
+
+
+
+
+
+
+
diff --git a/build/myget.nuspec.template b/build/myget.nuspec.template
new file mode 100644
index 00000000..fc31a5fd
--- /dev/null
+++ b/build/myget.nuspec.template
@@ -0,0 +1,23 @@
+
+
+
+ HandyControl
+ {version}
+ HandyOrg
+ HandyOrg
+ HandyOrg
+ true
+ LICENSE
+ icon.png
+ https://github.com/HandyOrg/HandyControl
+ Contains some simple and commonly used WPF controls
+ Copyright © HandyOrg 2018-{year}
+ WPF C# Control
+
+
+
+
+
+
+
+
diff --git a/build/tools/packages.config b/build/tools/packages.config
deleted file mode 100644
index ec87d006..00000000
--- a/build/tools/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/build/version-bump-up-manual.md b/build/version-bump-up-manual.md
deleted file mode 100644
index b699e84d..00000000
--- a/build/version-bump-up-manual.md
+++ /dev/null
@@ -1,11 +0,0 @@
-- modify copyright of LICENSE
-- modify copyright of build/LICENSE
-- modify version and copyright of src/Directory.Build.Props
-- modify version, copyright and repository of build/build.nuspec
-- modify version, copyright and repository of build/build.Lang.template
-- modify version and copyright of build/build-for-myget.nuspec
-- run build/build.ps1
-- run create_lang_nuspec_file.py
-- run create_nupkg_file.ps1
-- upload nupkg and snupkg to nuget
-- draft and publish a new release on github.