Родитель
4313ad7f69
Коммит
16720fb1ca
|
@ -1,4 +0,0 @@
|
|||
@pushd %~dp0
|
||||
@PowerShell.exe -file "%~dp0build.ps1" %*
|
||||
@popd
|
||||
@PAUSE
|
|
@ -1 +0,0 @@
|
|||
@call "%~dp0build.bat" -t:Clean %*
|
|
@ -1,3 +0,0 @@
|
|||
@ECHO OFF
|
||||
PowerShell.exe -file "%~dp0build.ps1" -target=StyleXaml
|
||||
PAUSE
|
|
@ -1,3 +0,0 @@
|
|||
@ECHO OFF
|
||||
PowerShell.exe -file "%~dp0build.ps1" -target=UpdateHeaders
|
||||
PAUSE
|
274
build/build.cake
274
build/build.cake
|
@ -1,274 +0,0 @@
|
|||
#module nuget:?package=Cake.LongPath.Module&version=1.0.1
|
||||
|
||||
#addin nuget:?package=Cake.FileHelpers&version=4.0.1
|
||||
#addin nuget:?package=Cake.Powershell&version=1.0.1
|
||||
#load nuget:?package=System.Buffers&version=4.0.0
|
||||
#addin nuget:?package=Cake.GitVersioning&version=3.5.119
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ARGUMENTS
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
var target = Argument("target", "Default");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// VERSIONS
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
var inheritDocVersion = "2.5.2";
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// VARIABLES
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
var baseDir = MakeAbsolute(Directory("../")).ToString();
|
||||
var buildDir = baseDir + "/build";
|
||||
var Solution = baseDir + "/Windows-Toolkit-Graph-Controls.sln";
|
||||
var toolsDir = buildDir + "/tools";
|
||||
|
||||
var binDir = baseDir + "/bin";
|
||||
var nupkgDir = binDir + "/nupkg";
|
||||
|
||||
var styler = toolsDir + "/XamlStyler.Console/tools/xstyler.exe";
|
||||
var stylerFile = baseDir + "/settings.xamlstyler";
|
||||
|
||||
string Version = null;
|
||||
|
||||
var inheritDoc = toolsDir + "/InheritDoc/tools/InheritDoc.exe";
|
||||
|
||||
// Ignoring NerdBank until this is merged and we can use a new version of inheridoc:
|
||||
// https://github.com/firesharkstudios/InheritDoc/pull/27
|
||||
var inheritDocExclude = "Nerdbank.GitVersioning.ManagedGit.GitRepository";
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// METHODS
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
void VerifyHeaders(bool Replace)
|
||||
{
|
||||
var header = FileReadText("header.txt") + "\r\n";
|
||||
bool hasMissing = false;
|
||||
|
||||
Func<IFileSystemInfo, bool> exclude_objDir =
|
||||
fileSystemInfo => !fileSystemInfo.Path.Segments.Contains("obj");
|
||||
|
||||
var globberSettings = new GlobberSettings
|
||||
{
|
||||
Predicate = exclude_objDir
|
||||
};
|
||||
|
||||
var files = GetFiles(baseDir + "/**/*.cs", globberSettings).Where(file =>
|
||||
{
|
||||
var path = file.ToString();
|
||||
return !(path.EndsWith(".g.cs") || path.EndsWith(".i.cs") || System.IO.Path.GetFileName(path).Contains("TemporaryGeneratedFile"));
|
||||
});
|
||||
|
||||
Information("\nChecking " + files.Count() + " file header(s)");
|
||||
foreach(var file in files)
|
||||
{
|
||||
var oldContent = FileReadText(file);
|
||||
if(oldContent.Contains("// <auto-generated>"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var rgx = new Regex("^(//.*\r?\n)*\r?\n");
|
||||
var newContent = header + rgx.Replace(oldContent, "");
|
||||
|
||||
if(!newContent.Equals(oldContent, StringComparison.Ordinal))
|
||||
{
|
||||
if(Replace)
|
||||
{
|
||||
Information("\nUpdating " + file + " header...");
|
||||
FileWriteText(file, newContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Error("\nWrong/missing header on " + file);
|
||||
hasMissing = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!Replace && hasMissing)
|
||||
{
|
||||
throw new Exception("Please run UpdateHeaders.bat or '.\\build.ps1 -target=UpdateHeaders' and commit the changes.");
|
||||
}
|
||||
}
|
||||
|
||||
void RetrieveVersion()
|
||||
{
|
||||
Information("\nRetrieving version...");
|
||||
Version = GitVersioningGetVersion().NuGetPackageVersion;
|
||||
Information("\nBuild Version: " + Version);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// DEFAULT TASK
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
Task("Clean")
|
||||
.Description("Clean the output folder")
|
||||
.Does(() =>
|
||||
{
|
||||
if(DirectoryExists(binDir))
|
||||
{
|
||||
Information("\nCleaning Working Directory");
|
||||
CleanDirectory(binDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateDirectory(binDir);
|
||||
}
|
||||
});
|
||||
|
||||
Task("Verify")
|
||||
.Description("Run pre-build verifications")
|
||||
.IsDependentOn("Clean")
|
||||
.Does(() =>
|
||||
{
|
||||
VerifyHeaders(false);
|
||||
|
||||
StartPowershellFile("./Find-WindowsSDKVersions.ps1");
|
||||
});
|
||||
|
||||
Task("Version")
|
||||
.Description("Updates the version information in all Projects")
|
||||
.IsDependentOn("Verify")
|
||||
.Does(() =>
|
||||
{
|
||||
RetrieveVersion();
|
||||
});
|
||||
|
||||
Task("Build")
|
||||
.Description("Build all projects and get the assemblies")
|
||||
.IsDependentOn("Version")
|
||||
.Does(() =>
|
||||
{
|
||||
Information("\nBuilding Solution");
|
||||
var buildSettings = new MSBuildSettings
|
||||
{
|
||||
MaxCpuCount = 0,
|
||||
ToolVersion = MSBuildToolVersion.VS2022
|
||||
}
|
||||
.SetConfiguration("CI")
|
||||
.WithTarget("Restore");
|
||||
|
||||
MSBuild(Solution, buildSettings);
|
||||
|
||||
EnsureDirectoryExists(nupkgDir);
|
||||
|
||||
// Build once with normal dependency ordering
|
||||
buildSettings = new MSBuildSettings
|
||||
{
|
||||
MaxCpuCount = 0,
|
||||
ToolVersion = MSBuildToolVersion.VS2022
|
||||
}
|
||||
.SetConfiguration("CI")
|
||||
.WithTarget("Build")
|
||||
.WithProperty("GenerateLibraryLayout", "true");
|
||||
|
||||
MSBuild(Solution, buildSettings);
|
||||
});
|
||||
|
||||
Task("InheritDoc")
|
||||
.Description("Updates <inheritdoc /> tags from base classes, interfaces, and similar methods")
|
||||
.IsDependentOn("Build")
|
||||
.Does(() =>
|
||||
{
|
||||
Information("\nDownloading InheritDoc...");
|
||||
var installSettings = new NuGetInstallSettings {
|
||||
ExcludeVersion = true,
|
||||
Version = inheritDocVersion,
|
||||
OutputDirectory = toolsDir
|
||||
};
|
||||
|
||||
NuGetInstall(new []{"InheritDoc"}, installSettings);
|
||||
|
||||
var args = new ProcessArgumentBuilder()
|
||||
.AppendSwitchQuoted("-b", baseDir)
|
||||
.AppendSwitch("-o", "")
|
||||
.AppendSwitchQuoted("-x", inheritDocExclude);
|
||||
|
||||
var result = StartProcess(inheritDoc, new ProcessSettings { Arguments = args });
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
throw new InvalidOperationException("InheritDoc failed!");
|
||||
}
|
||||
|
||||
Information("\nFinished generating documentation with InheritDoc");
|
||||
});
|
||||
|
||||
Task("Package")
|
||||
.Description("Pack the NuPkg")
|
||||
.IsDependentOn("InheritDoc")
|
||||
.Does(() =>
|
||||
{
|
||||
// Invoke the pack target in the end
|
||||
var buildSettings = new MSBuildSettings {
|
||||
MaxCpuCount = 0,
|
||||
ToolVersion = MSBuildToolVersion.VS2022
|
||||
}
|
||||
.SetConfiguration("CI")
|
||||
.WithTarget("Pack")
|
||||
.WithProperty("GenerateLibraryLayout", "true")
|
||||
.WithProperty("PackageOutputPath", nupkgDir);
|
||||
|
||||
MSBuild(Solution, buildSettings);
|
||||
});
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// TASK TARGETS
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
Task("Default")
|
||||
.IsDependentOn("Package");
|
||||
|
||||
Task("UpdateHeaders")
|
||||
.Description("Updates the headers in *.cs files")
|
||||
.Does(() =>
|
||||
{
|
||||
VerifyHeaders(true);
|
||||
});
|
||||
|
||||
Task("StyleXaml")
|
||||
.Description("Ensures XAML Formatting is Clean")
|
||||
.Does(() =>
|
||||
{
|
||||
Information("\nDownloading XamlStyler...");
|
||||
var installSettings = new NuGetInstallSettings {
|
||||
ExcludeVersion = true,
|
||||
OutputDirectory = toolsDir
|
||||
};
|
||||
|
||||
NuGetInstall(new []{"xamlstyler.console"}, installSettings);
|
||||
|
||||
Func<IFileSystemInfo, bool> exclude_objDir =
|
||||
fileSystemInfo => !fileSystemInfo.Path.Segments.Contains("obj");
|
||||
|
||||
var globberSettings = new GlobberSettings
|
||||
{
|
||||
Predicate = exclude_objDir
|
||||
};
|
||||
|
||||
var files = GetFiles(baseDir + "/**/*.xaml", globberSettings);
|
||||
Information("\nChecking " + files.Count() + " file(s) for XAML Structure");
|
||||
foreach(var file in files)
|
||||
{
|
||||
StartProcess(styler, "-f \"" + file + "\" -c \"" + stylerFile + "\"");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// EXECUTION
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
RunTarget(target);
|
232
build/build.ps1
232
build/build.ps1
|
@ -1,232 +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 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 Experimental
|
||||
Tells Cake to use the latest Roslyn release.
|
||||
.PARAMETER WhatIf
|
||||
Performs a dry run of the build script.
|
||||
No tasks will be executed.
|
||||
.PARAMETER Mono
|
||||
Tells Cake to use the Mono scripting engine.
|
||||
.PARAMETER SkipToolPackageRestore
|
||||
Skips restoring of packages.
|
||||
.PARAMETER ScriptArgs
|
||||
Remaining arguments are added here.
|
||||
|
||||
.LINK
|
||||
https://cakebuild.net
|
||||
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
[string]$Target = "Default",
|
||||
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
|
||||
[string]$Verbosity = "Verbose",
|
||||
[switch]$Experimental,
|
||||
[Alias("DryRun","Noop")]
|
||||
[switch]$WhatIf,
|
||||
[switch]$Mono,
|
||||
[switch]$SkipToolPackageRestore,
|
||||
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
|
||||
[string[]]$ScriptArgs
|
||||
)
|
||||
|
||||
[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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Preparing to run build script..."
|
||||
|
||||
if(!$PSScriptRoot){
|
||||
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
|
||||
}
|
||||
|
||||
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
|
||||
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
|
||||
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
|
||||
$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
|
||||
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
|
||||
$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
|
||||
$MODULES_DIR = Join-Path $PSScriptRoot "tools/modules"
|
||||
$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"
|
||||
$MODULES_PACKAGES_CONFIG_MD5 = Join-Path $MODULES_DIR "packages.config.md5sum"
|
||||
|
||||
# Should we use mono?
|
||||
$UseMono = "";
|
||||
if($Mono.IsPresent) {
|
||||
Write-Verbose -Message "Using the Mono based scripting engine."
|
||||
$UseMono = "--mono"
|
||||
}
|
||||
|
||||
# Should we use the new Roslyn?
|
||||
$UseExperimental = "";
|
||||
if($Experimental.IsPresent -and !($Mono.IsPresent)) {
|
||||
Write-Verbose -Message "Using experimental version of Roslyn."
|
||||
$UseExperimental = "--experimental"
|
||||
}
|
||||
|
||||
# Is this a dry run?
|
||||
$UseDryRun = "";
|
||||
if($WhatIf.IsPresent) {
|
||||
$UseDryRun = "--dryrun"
|
||||
}
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
# Fix to force PS to use TLS12
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
# Make sure that packages.config exist.
|
||||
if (!(Test-Path $PACKAGES_CONFIG)) {
|
||||
Write-Verbose -Message "Downloading packages.config..."
|
||||
try { (New-Object System.Net.WebClient).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 {
|
||||
(New-Object System.Net.WebClient).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
|
||||
|
||||
# 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..."
|
||||
Remove-Item * -Recurse -Exclude packages.config,nuget.exe
|
||||
}
|
||||
|
||||
Write-Verbose -Message "Restoring tools from NuGet..."
|
||||
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Throw "An error occured while restoring NuGet tools."
|
||||
}
|
||||
else
|
||||
{
|
||||
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
|
||||
}
|
||||
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"
|
||||
}
|
||||
|
||||
# Make sure modules folder exists
|
||||
if ((Test-Path $PSScriptRoot) -and !(Test-Path $MODULES_DIR)) {
|
||||
Write-Verbose -Message "Creating tools/modules directory..."
|
||||
New-Item -Path $MODULES_DIR -Type directory | out-null
|
||||
}
|
||||
|
||||
# Restore modules from NuGet?
|
||||
if(-Not $SkipToolPackageRestore.IsPresent) {
|
||||
Push-Location
|
||||
Set-Location $MODULES_DIR
|
||||
|
||||
# Check for changes in modules packages.config and remove installed tools if true.
|
||||
[string] $md5Hash = MD5HashFile($MODULES_PACKAGES_CONFIG)
|
||||
if((!(Test-Path $MODULES_PACKAGES_CONFIG_MD5)) -Or
|
||||
($md5Hash -ne (Get-Content $MODULES_PACKAGES_CONFIG_MD5 ))) {
|
||||
Write-Verbose -Message "Missing or changed modules package.config hash..."
|
||||
Remove-Item * -Recurse -Exclude packages.config,packages.config.md5sum,nuget.exe
|
||||
}
|
||||
|
||||
Write-Verbose -Message "Restoring modules from NuGet..."
|
||||
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Throw "An error occured while restoring NuGet modules."
|
||||
}
|
||||
else
|
||||
{
|
||||
$md5Hash | Out-File $MODULES_PACKAGES_CONFIG_MD5 -Encoding "ASCII"
|
||||
}
|
||||
Write-Verbose -Message ($NuGetOutput | out-string)
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
# Start Cake
|
||||
$path = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||
$Script = "$path/build.cake"
|
||||
|
||||
Write-Host "Bootstrapping Cake..."
|
||||
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" --bootstrap"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "An error occured while bootstrapping Cake."
|
||||
}
|
||||
|
||||
Write-Host "Running build script..."
|
||||
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" --verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
|
||||
exit $LASTEXITCODE
|
|
@ -1,3 +0,0 @@
|
|||
// 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.
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Cake" version="1.3.0" />
|
||||
</packages>
|
Загрузка…
Ссылка в новой задаче