Skip to content
Open
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
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "2.0.0",
"commands": [
"dotnet-cake"
]
}
}
}
91 changes: 91 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# indentation
[*]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 4
insert_final_newline = true
charset = utf-8-bom

# Xml project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2

# Xml config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2

# JSON files
[*.json]
indent_size = 2

# YML files
[*.yml]
indent_size = 2

# Dotnet code style settings:
[*.{cs,vb}]
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
# Avoid "this." and "Me." if not necessary
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

# Use language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion

# Suggest more modern language features when available
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion

# CSharp code style settings:
[*.cs]
# Prefer "var" everywhere
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion

# Prefer method-like constructs to have a block body
csharp_style_expression_bodied_methods = false:none
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_operators = false:none

# Prefer property-like constructs to have an expression-body
csharp_style_expression_bodied_properties = true:none
csharp_style_expression_bodied_indexers = true:none
csharp_style_expression_bodied_accessors = true:none

# Suggest more modern language features when available
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion

# Newline settings
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true

# Stylecop
dotnet_diagnostic.SA1101.severity = none
dotnet_diagnostic.SA1309.severity = none
dotnet_diagnostic.SA1600.severity = none
dotnet_diagnostic.SA1633.severity = none
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Build script
init:
- git config --global core.autocrlf true
image: Visual Studio 2019

image: Visual Studio 2022

# Build script
build_script:
- cmd: powershell -NoProfile -ExecutionPolicy unrestricted -Command .\build.ps1 -Target "AppVeyor"
- cmd: powershell -NoProfile -ExecutionPolicy unrestricted -Command .\build.ps1 --target AppVeyor

# Tests
test: off
Expand Down
249 changes: 9 additions & 240 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,244 +1,13 @@
<#
.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.
.LINK
https://cakebuild.net
$ErrorActionPreference = 'Stop'

.PARAMETER Script
The build script file to run.
.PARAMETER Tools
The tools directory to use.
Set-Location -LiteralPath $PSScriptRoot

.PARAMETER Target
The build script target to run.
.PARAMETER Configuration
The build configuration to use.
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1'
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
$env:DOTNET_NOLOGO = '1'

.PARAMETER Verbosity
Specifies the amount of information to be displayed.
.PARAMETER WhatIf
Performs a dry run of the build script.
No tasks will be executed.
dotnet tool restore
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

.PARAMETER ScriptArgs
Remaining arguments are added here.
#>





###########################################################################
# Define Parameters
###########################################################################

[CmdletBinding()]
Param(
[string]$Script = "build.cake",
[string]$Tools,

[string]$Target = "Default",
[ValidateSet("Release", "Debug")]
[string]$Configuration = "Release",
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]

[string]$Verbosity = "Verbose",
[switch]$WhatIf,

[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)



$CakeVersion = "1.0.0"
$DotNetChannel = "Current";
$DotNetVersion = "5.0.103";
$DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1";
$NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"

# Temporarily skip verification and opt-in to new in-proc NuGet
$ENV:CAKE_SETTINGS_SKIPPACKAGEVERSIONCHECK='true'

# Use TLS 1.2
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;





###########################################################################
# Define Paths
###########################################################################

# Get Script root
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent

# Find tools
if($Tools)
{
# Parameter
Write-Verbose -Message "Using tools parameter"
$TOOLS_DIR = Join-Path $PSScriptRoot $Tools
}
elseif (Test-Path "C:/Tools/")
{
# Shared location
Write-Verbose -Message "Using shared tools"
$TOOLS_DIR = "C:/Tools"
}
else
{
# Local path
Write-Verbose -Message "Using local tools"
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
}

# Make sure tools folder exists
if (!(Test-Path $TOOLS_DIR))
{
Write-Verbose "Creating tools directory..."
New-Item -Path $TOOLS_DIR -Type directory | out-null
}



# Define directories
$ADDINS_DIR = Join-Path $TOOLS_DIR "/Addins"
$MODULES_DIR = Join-Path $TOOLS_DIR "/Modules"

Write-Verbose -Message $ADDINS_DIR

# Save paths to environment for use in child processes
$ENV:CAKE_PATHS_TOOLS = $TOOLS_DIR
$ENV:CAKE_PATHS_ADDINS = $ADDINS_DIR
$ENV:CAKE_PATHS_MODULES = $MODULES_DIR





###########################################################################
# INSTALL .NET CORE CLI
###########################################################################

Function Remove-PathVariable([string]$VariableToRemove)
{
$SplitChar = ';'
if ($IsMacOS -or $IsLinux) {
$SplitChar = ':'
}

$path = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($path -ne $null)
{
$newItems = $path.Split($SplitChar, [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join($SplitChar, $newItems), "User")
}

$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
if ($path -ne $null)
{
$newItems = $path.Split($SplitChar, [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join($SplitChar, $newItems), "Process")
}
}



# Get .NET Core CLI path if installed.
$FoundDotNetCliVersion = $null;

if (Get-Command dotnet -ErrorAction SilentlyContinue)
{
$FoundDotNetCliVersion = dotnet --version;
}

if($FoundDotNetCliVersion -ne $DotNetVersion)
{
$InstallPath = Join-Path $TOOLS_DIR "DotNet"
if (!(Test-Path $InstallPath)) {
New-Item -Path $InstallPath -ItemType Directory -Force | Out-Null;
}

if ($IsMacOS -or $IsLinux) {
$ScriptPath = Join-Path $InstallPath 'dotnet-install.sh'
(New-Object System.Net.WebClient).DownloadFile($DotNetUnixInstallerUri, $ScriptPath);
& bash $ScriptPath --version "$DotNetVersion" --install-dir "$InstallPath" --channel "$DotNetChannel" --no-path

Remove-PathVariable "$InstallPath"
$env:PATH = "$($InstallPath):$env:PATH"
}
else {
$ScriptPath = Join-Path $InstallPath 'dotnet-install.ps1'
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, $ScriptPath);
& $ScriptPath -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;

Remove-PathVariable "$InstallPath"
$env:PATH = "$InstallPath;$env:PATH"
}
$env:DOTNET_ROOT=$InstallPath
}





###########################################################################
# INSTALL NUGET
###########################################################################

# Make sure nuget.exe exists.
$NugetPath = Join-Path $TOOLS_DIR "nuget.exe"

if (!(Test-Path $NugetPath))
{
Write-Host "Downloading NuGet.exe..."
(New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath);
}





###########################################################################
# INSTALL CAKE
###########################################################################

# Make sure Cake has been installed.
$CakePath = Join-Path $TOOLS_DIR "Cake.$CakeVersion/Cake.exe"

if (!(Test-Path $CakePath))
{
Write-Host "Installing Cake..."
Invoke-Expression "&`"$NugetPath`" install Cake -Version $CakeVersion -OutputDirectory `"$TOOLS_DIR`"" | Out-Null;

if ($LASTEXITCODE -ne 0)
{
Throw "An error occured while restoring Cake from NuGet."
}
}




###########################################################################
# RUN BUILD SCRIPT
###########################################################################

# Build the argument list.
$Arguments = @{
target=$Target;
configuration=$Configuration;
verbosity=$Verbosity;
dryrun=$WhatIf;
}.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value };

# Start Cake
Write-Host "Running build script..."
Invoke-Expression "& `"$CakePath`" `"$Script`" $Arguments $ScriptArgs"

exit $LASTEXITCODE
dotnet cake @args
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Loading