From 16720fb1ca7f48d24d24949cf48e6d9ca695592d Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Thu, 15 Dec 2022 02:05:34 -0800 Subject: [PATCH] Remove old cake build based files XAML Styler check removed see #203 --- build/Build.bat | 4 - build/Clean.bat | 1 - build/StyleXaml.bat | 3 - build/UpdateHeaders.bat | 3 - build/build.cake | 274 ------------------------------------ build/build.ps1 | 232 ------------------------------ build/header.txt | 3 - build/tools/packages.config | 4 - 8 files changed, 524 deletions(-) delete mode 100644 build/Build.bat delete mode 100644 build/Clean.bat delete mode 100644 build/StyleXaml.bat delete mode 100644 build/UpdateHeaders.bat delete mode 100644 build/build.cake delete mode 100644 build/build.ps1 delete mode 100644 build/header.txt delete mode 100644 build/tools/packages.config diff --git a/build/Build.bat b/build/Build.bat deleted file mode 100644 index bc1cd8c..0000000 --- a/build/Build.bat +++ /dev/null @@ -1,4 +0,0 @@ -@pushd %~dp0 -@PowerShell.exe -file "%~dp0build.ps1" %* -@popd -@PAUSE \ No newline at end of file diff --git a/build/Clean.bat b/build/Clean.bat deleted file mode 100644 index 0afbf41..0000000 --- a/build/Clean.bat +++ /dev/null @@ -1 +0,0 @@ -@call "%~dp0build.bat" -t:Clean %* diff --git a/build/StyleXaml.bat b/build/StyleXaml.bat deleted file mode 100644 index b03dcbd..0000000 --- a/build/StyleXaml.bat +++ /dev/null @@ -1,3 +0,0 @@ -@ECHO OFF -PowerShell.exe -file "%~dp0build.ps1" -target=StyleXaml -PAUSE \ No newline at end of file diff --git a/build/UpdateHeaders.bat b/build/UpdateHeaders.bat deleted file mode 100644 index 166ea21..0000000 --- a/build/UpdateHeaders.bat +++ /dev/null @@ -1,3 +0,0 @@ -@ECHO OFF -PowerShell.exe -file "%~dp0build.ps1" -target=UpdateHeaders -PAUSE \ No newline at end of file diff --git a/build/build.cake b/build/build.cake deleted file mode 100644 index 2afc594..0000000 --- a/build/build.cake +++ /dev/null @@ -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 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("// ")) - { - 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 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 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); diff --git a/build/build.ps1 b/build/build.ps1 deleted file mode 100644 index dcc512f..0000000 --- a/build/build.ps1 +++ /dev/null @@ -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 \ No newline at end of file diff --git a/build/header.txt b/build/header.txt deleted file mode 100644 index 45274ba..0000000 --- a/build/header.txt +++ /dev/null @@ -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. diff --git a/build/tools/packages.config b/build/tools/packages.config deleted file mode 100644 index 7d7c17d..0000000 --- a/build/tools/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file