From d3bb5186991ebff1f8176e5bdfbb4958cd62a6b0 Mon Sep 17 00:00:00 2001 From: Patrick Klaeren Date: Wed, 9 Jun 2021 20:48:33 +0100 Subject: [PATCH 1/3] Updates for .NET 5 and Nuke --- .nuke | 1 - .nuke/parameters.json | 4 ++++ build.cmd | 5 +++-- build.ps1 | 30 +++++++++++++------------- build.sh | 34 +++++++++++++++--------------- build/Build.cs | 22 +++++++------------ build/Configuration.cs | 16 ++++++++++++++ build/Directory.Build.props | 8 +++++++ build/Directory.Build.targets | 8 +++++++ build/_build.csproj | 6 +++--- global.json | 2 +- src/MassHub.CLI/GitHubService.cs | 9 ++++---- src/MassHub.CLI/MassHub.CLI.csproj | 8 +++---- src/MassHub.CLI/Program.cs | 4 ++-- 14 files changed, 94 insertions(+), 63 deletions(-) delete mode 100644 .nuke create mode 100644 .nuke/parameters.json create mode 100644 build/Configuration.cs create mode 100644 build/Directory.Build.props create mode 100644 build/Directory.Build.targets diff --git a/.nuke b/.nuke deleted file mode 100644 index 5962448..0000000 --- a/.nuke +++ /dev/null @@ -1 +0,0 @@ -MassHub.sln \ No newline at end of file diff --git a/.nuke/parameters.json b/.nuke/parameters.json new file mode 100644 index 0000000..2713255 --- /dev/null +++ b/.nuke/parameters.json @@ -0,0 +1,4 @@ +{ + "$schema": "./build.schema.json", + "Solution": "MassHub.sln" +} \ No newline at end of file diff --git a/build.cmd b/build.cmd index f9683e7..b08cc59 100755 --- a/build.cmd +++ b/build.cmd @@ -1,6 +1,7 @@ :; set -eo pipefail -:; ./build.sh "$@" +:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) +:; ${SCRIPT_DIR}/build.sh "$@" :; exit $? @ECHO OFF -powershell -ExecutionPolicy ByPass -NoProfile %0\..\build.ps1 %* +powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %* diff --git a/build.ps1 b/build.ps1 index 2e6b4ae..bbaa118 100755 --- a/build.ps1 +++ b/build.ps1 @@ -14,7 +14,7 @@ $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent ########################################################################### $BuildProjectFile = "$PSScriptRoot\build\_build.csproj" -$TempDirectory = "$PSScriptRoot\\.tmp" +$TempDirectory = "$PSScriptRoot\\.nuke\temp" $DotNetGlobalFile = "$PSScriptRoot\\global.json" $DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1" @@ -22,6 +22,7 @@ $DotNetChannel = "Current" $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 $env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 +$env:DOTNET_MULTILEVEL_LOOKUP = 0 ########################################################################### # EXECUTION @@ -32,38 +33,37 @@ function ExecSafe([scriptblock] $cmd) { if ($LASTEXITCODE) { exit $LASTEXITCODE } } -# If global.json exists, load expected version -if (Test-Path $DotNetGlobalFile) { - $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json) - if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) { - $DotNetVersion = $DotNetGlobal.sdk.version - } -} - -# If dotnet is installed locally, and expected version is not set or installation matches the expected version +# If dotnet CLI is installed globally and it matches requested version, use for execution if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` - (!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) { + $(dotnet --version) -and $LASTEXITCODE -eq 0) { $env:DOTNET_EXE = (Get-Command "dotnet").Path } else { - $DotNetDirectory = "$TempDirectory\dotnet-win" - $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" - # Download install script $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) + # If global.json exists, load expected version + if (Test-Path $DotNetGlobalFile) { + $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json) + if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) { + $DotNetVersion = $DotNetGlobal.sdk.version + } + } + # Install by channel or version + $DotNetDirectory = "$TempDirectory\dotnet-win" if (!(Test-Path variable:DotNetVersion)) { ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } } else { ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } } + $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" } Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)" -ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false -nologo -clp:NoSummary --verbosity quiet } +ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet } ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments } diff --git a/build.sh b/build.sh index 94ae8bd..e8961f9 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -echo $(bash --version 2>&1 | head -n 1) +bash --version 2>&1 | head -n 1 set -eo pipefail SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) @@ -10,7 +10,7 @@ SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) ########################################################################### BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj" -TEMP_DIRECTORY="$SCRIPT_DIR//.tmp" +TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp" DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json" DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh" @@ -18,45 +18,45 @@ DOTNET_CHANNEL="Current" export DOTNET_CLI_TELEMETRY_OPTOUT=1 export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +export DOTNET_MULTILEVEL_LOOKUP=0 ########################################################################### # EXECUTION ########################################################################### function FirstJsonValue { - perl -nle 'print $1 if m{"'$1'": "([^"]+)",?}' <<< ${@:2} + perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}" } -# If global.json exists, load expected version -if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then - DOTNET_VERSION=$(FirstJsonValue "version" $(cat "$DOTNET_GLOBAL_FILE")) - if [[ "$DOTNET_VERSION" == "" ]]; then - unset DOTNET_VERSION - fi -fi - -# If dotnet is installed locally, and expected version is not set or installation matches the expected version -if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version 2>&1) == "$DOTNET_VERSION") ]]; then +# If dotnet CLI is installed globally and it matches requested version, use for execution +if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then export DOTNET_EXE="$(command -v dotnet)" else - DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" - export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" - # Download install script DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh" mkdir -p "$TEMP_DIRECTORY" curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL" chmod +x "$DOTNET_INSTALL_FILE" + # If global.json exists, load expected version + if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then + DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")") + if [[ "$DOTNET_VERSION" == "" ]]; then + unset DOTNET_VERSION + fi + fi + # Install by channel or version + DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" if [[ -z ${DOTNET_VERSION+x} ]]; then "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path else "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path fi + export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" fi echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)" -"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false -nologo -clp:NoSummary --verbosity quiet +"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet "$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@" diff --git a/build/Build.cs b/build/Build.cs index 87936cb..2e96e99 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -2,7 +2,6 @@ using Nuke.Common.CI; using Nuke.Common.CI.GitHubActions; using Nuke.Common.Execution; -using Nuke.Common.Git; using Nuke.Common.IO; using Nuke.Common.ProjectModel; using Nuke.Common.Tooling; @@ -13,13 +12,13 @@ using static Nuke.Common.Tools.DotNet.DotNetTasks; [CheckBuildProjectConfigurations] -[UnsetVisualStudioEnvironmentVariables] +[ShutdownDotNetAfterServerBuild] [GitHubActions("Release", GitHubActionsImage.WindowsLatest, GitHubActionsImage.MacOsLatest, GitHubActionsImage.UbuntuLatest, AutoGenerate = false, - OnPushBranches = new[] {"master"}, + OnPushBranches = new[] { "master" }, InvokedTargets = new[] { @@ -35,7 +34,8 @@ class Build : NukeBuild /// - JetBrains Rider https://nuke.build/rider /// - Microsoft VisualStudio https://nuke.build/visualstudio /// - Microsoft VSCode https://nuke.build/vscode - public static int Main() => Execute(x => x.Compile); + + public static int Main () => Execute(x => x.Compile); [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; @@ -43,11 +43,8 @@ class Build : NukeBuild [Parameter("RID for publishing")] readonly string Runtime = "win-x64"; [Solution] readonly Solution Solution; - [GitRepository] readonly GitRepository GitRepository; [GitVersion] readonly GitVersion GitVersion; - [CI] readonly GitHubActions Hello; - AbsolutePath SourceDirectory => RootDirectory / "src"; AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; @@ -60,8 +57,6 @@ class Build : NukeBuild }); Target Restore => _ => _ - .DependsOn(Clean) - .After(Clean) .Executes(() => { DotNetRestore(s => s @@ -71,7 +66,6 @@ class Build : NukeBuild Target Compile => _ => _ .DependsOn(Restore) - .Triggers(Publish) .Executes(() => { DotNetBuild(s => s @@ -82,7 +76,7 @@ class Build : NukeBuild .SetFileVersion(GitVersion.AssemblySemFileVer) .SetInformationalVersion(GitVersion.InformationalVersion) .SetAuthors("Inzanit") - .SetCopyright("Copyright © 2020 Inzanit. All rights reserved.") + .SetCopyright("Copyright © 2021 Patrick Klaeren. All rights reserved.") .EnableNoRestore()); }); @@ -95,14 +89,14 @@ class Build : NukeBuild var selfContainedSingleFile = GetBaseSettings() .SetOutput(ArtifactsDirectory / $"self-contained-single-{Runtime}") .EnableSelfContained() - .SetArgumentConfigurator(x => + .SetProcessArgumentConfigurator(x => x.Add( "-p:PublishReadyToRun=true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None")); var selfContained = GetBaseSettings() .SetOutput(ArtifactsDirectory / $"self-contained-{Runtime}") .EnableSelfContained() - .SetArgumentConfigurator(x => x.Add("-p:PublishTrimmed=true -p:DebugType=None")); + .SetProcessArgumentConfigurator(x => x.Add("-p:PublishTrimmed=true -p:DebugType=None")); DotNetPublish(s => selfContainedSingleFile); DotNetPublish(s => selfContained); @@ -117,4 +111,4 @@ DotNetPublishSettings GetBaseSettings() .EnableNoBuild(); } }); -} \ No newline at end of file +} diff --git a/build/Configuration.cs b/build/Configuration.cs new file mode 100644 index 0000000..9c08b1a --- /dev/null +++ b/build/Configuration.cs @@ -0,0 +1,16 @@ +using System; +using System.ComponentModel; +using System.Linq; +using Nuke.Common.Tooling; + +[TypeConverter(typeof(TypeConverter))] +public class Configuration : Enumeration +{ + public static Configuration Debug = new Configuration { Value = nameof(Debug) }; + public static Configuration Release = new Configuration { Value = nameof(Release) }; + + public static implicit operator string(Configuration configuration) + { + return configuration.Value; + } +} diff --git a/build/Directory.Build.props b/build/Directory.Build.props new file mode 100644 index 0000000..e147d63 --- /dev/null +++ b/build/Directory.Build.props @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/build/Directory.Build.targets b/build/Directory.Build.targets new file mode 100644 index 0000000..2532609 --- /dev/null +++ b/build/Directory.Build.targets @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/build/_build.csproj b/build/_build.csproj index 16b8392..e4a09a9 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + net5.0 CS0649;CS0169 .. @@ -10,8 +10,8 @@ - - + + diff --git a/global.json b/global.json index 70a59a3..e43fedd 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.1.201" + "version": "5.0.203" } } \ No newline at end of file diff --git a/src/MassHub.CLI/GitHubService.cs b/src/MassHub.CLI/GitHubService.cs index 7eff623..a5f122b 100644 --- a/src/MassHub.CLI/GitHubService.cs +++ b/src/MassHub.CLI/GitHubService.cs @@ -138,7 +138,7 @@ internal async Task UpdateBranches() var branchesToUpdate = new List(); - if (!string.IsNullOrWhiteSpace(response)) + if (!string.IsNullOrWhiteSpace(branchUpdateResponse)) { branchesToUpdate = branchUpdateResponse.Split(',').ToList(); Log.Debug("Updating {NumberOfBranches} branches: {IgnoredRepositories}", branchesToUpdate.Count, branchesToUpdate); @@ -219,7 +219,7 @@ internal async Task UpdateBranches() enableCodeOwners ?? currentProtection.RequiredPullRequestReviews.RequireCodeOwnerReviews, numberOfReviewsRequired ?? currentProtection.RequiredPullRequestReviews.RequiredApprovingReviewCount); - BranchProtectionPushRestrictionsUpdate pushRestrictions = null; + BranchProtectionPushRestrictionsUpdate? pushRestrictions = null; if (teamsToSetAsBranchProtectors.Any()) { @@ -263,7 +263,8 @@ internal async Task UpdateTeamRepositories() Console.WriteLine("Enter permission for team on given repositories one of READ/WRITE/ADMIN"); var permissionResponse = Console.ReadLine(); - if (!acceptedTerms.Any(x => x.Equals(permissionResponse, StringComparison.CurrentCultureIgnoreCase))) + if (string.IsNullOrWhiteSpace(permissionResponse) + || !acceptedTerms.Any(x => x.Equals(permissionResponse, StringComparison.CurrentCultureIgnoreCase))) continue; teamPermission = permissionResponse.ToUpper() switch @@ -281,7 +282,7 @@ internal async Task UpdateTeamRepositories() Log.Debug("Getting repositories for organisation {Organisation}", _organisationName); - if (repositoryResponse != "*") + if (!string.IsNullOrWhiteSpace(repositoryResponse) && repositoryResponse != "*") { Log.Debug("Updating single repository {RepositoryName}", repositoryResponse); await AddRepositoryToTeam(repositoryResponse); diff --git a/src/MassHub.CLI/MassHub.CLI.csproj b/src/MassHub.CLI/MassHub.CLI.csproj index 3d4e4e6..6dee738 100644 --- a/src/MassHub.CLI/MassHub.CLI.csproj +++ b/src/MassHub.CLI/MassHub.CLI.csproj @@ -1,14 +1,14 @@ - + Exe - netcoreapp3.1 + net5.0 enable - - + + diff --git a/src/MassHub.CLI/Program.cs b/src/MassHub.CLI/Program.cs index a8976d2..42080f3 100644 --- a/src/MassHub.CLI/Program.cs +++ b/src/MassHub.CLI/Program.cs @@ -110,7 +110,7 @@ private static async Task RunGitHubService(string gitHubToken, string productHea var response = Console.ReadLine(); - Func operation; + Func? operation; if (int.TryParse(response, out var parsedIndex)) { @@ -127,7 +127,7 @@ private static async Task RunGitHubService(string gitHubToken, string productHea .SingleOrDefault(); } - if (operation != null) + if (operation is not null) { await operation(); } From 4802970ea3d3059044bcdc39fa6362d8c4ca76f9 Mon Sep 17 00:00:00 2001 From: Patrick Klaeren Date: Wed, 6 Jul 2022 16:04:58 +0100 Subject: [PATCH 2/3] Move to .NET 6 --- .nuke/build.schema.json | 116 +++++++++++++++++++++++++++++ build.ps1 | 6 +- build.sh | 2 +- build/Build.cs | 20 ++--- build/_build.csproj | 10 ++- build/_build.csproj.DotSettings | 3 +- global.json | 2 +- src/MassHub.CLI/MassHub.CLI.csproj | 12 +-- src/MassHub.CLI/Program.cs | 24 ++++-- 9 files changed, 161 insertions(+), 34 deletions(-) create mode 100644 .nuke/build.schema.json diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json new file mode 100644 index 0000000..03474b6 --- /dev/null +++ b/.nuke/build.schema.json @@ -0,0 +1,116 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Build Schema", + "$ref": "#/definitions/build", + "definitions": { + "build": { + "type": "object", + "properties": { + "Configuration": { + "type": "string", + "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", + "enum": [ + "Debug", + "Release" + ] + }, + "Continue": { + "type": "boolean", + "description": "Indicates to continue a previously failed build attempt" + }, + "Help": { + "type": "boolean", + "description": "Shows the help text for this build assembly" + }, + "Host": { + "type": "string", + "description": "Host for execution. Default is 'automatic'", + "enum": [ + "AppVeyor", + "AzurePipelines", + "Bamboo", + "Bitbucket", + "Bitrise", + "GitHubActions", + "GitLab", + "Jenkins", + "Rider", + "SpaceAutomation", + "TeamCity", + "Terminal", + "TravisCI", + "VisualStudio", + "VSCode" + ] + }, + "NoLogo": { + "type": "boolean", + "description": "Disables displaying the NUKE logo" + }, + "Partition": { + "type": "string", + "description": "Partition to use on CI" + }, + "Plan": { + "type": "boolean", + "description": "Shows the execution plan (HTML)" + }, + "Profile": { + "type": "array", + "description": "Defines the profiles to load", + "items": { + "type": "string" + } + }, + "Root": { + "type": "string", + "description": "Root directory during build execution" + }, + "Runtime": { + "type": "string", + "description": "RID for publishing" + }, + "Skip": { + "type": "array", + "description": "List of targets to be skipped. Empty list skips all dependencies", + "items": { + "type": "string", + "enum": [ + "Clean", + "Compile", + "Publish", + "Restore" + ] + } + }, + "Solution": { + "type": "string", + "description": "Path to a solution file that is automatically loaded" + }, + "Target": { + "type": "array", + "description": "List of targets to be invoked. Default is '{default_target}'", + "items": { + "type": "string", + "enum": [ + "Clean", + "Compile", + "Publish", + "Restore" + ] + } + }, + "Verbosity": { + "type": "string", + "description": "Logging verbosity during build execution. Default is 'Normal'", + "enum": [ + "Minimal", + "Normal", + "Quiet", + "Verbose" + ] + } + } + } + } +} \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index bbaa118..8c52d63 100755 --- a/build.ps1 +++ b/build.ps1 @@ -56,14 +56,14 @@ else { # Install by channel or version $DotNetDirectory = "$TempDirectory\dotnet-win" if (!(Test-Path variable:DotNetVersion)) { - ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } + ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } } else { - ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } + ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } } $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" } -Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)" +Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)" ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet } ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments } diff --git a/build.sh b/build.sh index e8961f9..1f3ba09 100755 --- a/build.sh +++ b/build.sh @@ -56,7 +56,7 @@ else export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" fi -echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)" +echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)" "$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet "$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@" diff --git a/build/Build.cs b/build/Build.cs index 2e96e99..b5f740d 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -1,7 +1,5 @@ using Nuke.Common; -using Nuke.Common.CI; using Nuke.Common.CI.GitHubActions; -using Nuke.Common.Execution; using Nuke.Common.IO; using Nuke.Common.ProjectModel; using Nuke.Common.Tooling; @@ -11,8 +9,6 @@ using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.Tools.DotNet.DotNetTasks; -[CheckBuildProjectConfigurations] -[ShutdownDotNetAfterServerBuild] [GitHubActions("Release", GitHubActionsImage.WindowsLatest, GitHubActionsImage.MacOsLatest, @@ -36,14 +32,18 @@ class Build : NukeBuild /// - Microsoft VSCode https://nuke.build/vscode public static int Main () => Execute(x => x.Compile); + + [Solution] + readonly Solution Solution; + + [GitVersion] + readonly GitVersion GitVersion; [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; - [Parameter("RID for publishing")] readonly string Runtime = "win-x64"; - - [Solution] readonly Solution Solution; - [GitVersion] readonly GitVersion GitVersion; + [Parameter("RID for publishing")] + readonly string Runtime = "win-x64"; AbsolutePath SourceDirectory => RootDirectory / "src"; AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; @@ -75,8 +75,8 @@ class Build : NukeBuild .SetAssemblyVersion(GitVersion.AssemblySemVer) .SetFileVersion(GitVersion.AssemblySemFileVer) .SetInformationalVersion(GitVersion.InformationalVersion) - .SetAuthors("Inzanit") - .SetCopyright("Copyright © 2021 Patrick Klaeren. All rights reserved.") + .SetAuthors("Patrick Klaeren") + .SetCopyright("Copyright © 2022 Patrick Klaeren. All rights reserved.") .EnableNoRestore()); }); diff --git a/build/_build.csproj b/build/_build.csproj index e4a09a9..0e87362 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -2,16 +2,20 @@ Exe - net5.0 + net6.0 CS0649;CS0169 .. .. + 1 - - + + + + + diff --git a/build/_build.csproj.DotSettings b/build/_build.csproj.DotSettings index 7bc2848..c8947fc 100644 --- a/build/_build.csproj.DotSettings +++ b/build/_build.csproj.DotSettings @@ -1,4 +1,4 @@ - + DO_NOT_SHOW DO_NOT_SHOW DO_NOT_SHOW @@ -20,7 +20,6 @@ True True True - True True True True diff --git a/global.json b/global.json index e43fedd..726ce1b 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "5.0.203" + "version": "6.0.201" } } \ No newline at end of file diff --git a/src/MassHub.CLI/MassHub.CLI.csproj b/src/MassHub.CLI/MassHub.CLI.csproj index 6dee738..16b9210 100644 --- a/src/MassHub.CLI/MassHub.CLI.csproj +++ b/src/MassHub.CLI/MassHub.CLI.csproj @@ -2,16 +2,16 @@ Exe - net5.0 + net6.0 enable - - - - - + + + + + diff --git a/src/MassHub.CLI/Program.cs b/src/MassHub.CLI/Program.cs index 42080f3..ccd421c 100644 --- a/src/MassHub.CLI/Program.cs +++ b/src/MassHub.CLI/Program.cs @@ -37,18 +37,26 @@ __ __ __ .MinimumLevel.ControlledBy(levelSwitch) .WriteTo.Console(); + var tokenOption = new Option("--token", () => null, "Set output to be verbose"); + var orgOption = new Option(new[] { "--org", "-o" }, () => null, + "Set organisation to use for all requests"); + var productHeaderOption = new Option(new[] { "--product-header" }, () => "mass-hub", + "Optionally set a custom product header used when interacting with GitHub API"); + var verboseOption = new Option("--verbose", () => false, "Set output to be verbose"); + var logFileOption = new Option("--log-file", () => null, "Path to log file"); + var rootCommand = new RootCommand { - new Option("--token", () => null, "Set output to be verbose"), - new Option(new[] {"--org", "-o"}, () => null, "Set organisation to use for all requests"), - new Option(new[] {"--product-header"}, () => "mass-hub", "Optionally set a custom product header used when interacting with GitHub API"), - new Option("--verbose", () => false, "Set output to be verbose"), - new Option("--log-file", () => null, "Path to log file"), + tokenOption, + orgOption, + productHeaderOption, + verboseOption, + logFileOption }; rootCommand.Description = "MassHub - GitHub Management en masse"; - - rootCommand.Handler = CommandHandler.Create(async (token, org, productHeader, verbose, logFile) => + + rootCommand.SetHandler(async (token, org, productHeader, verbose, logFile) => { if (verbose) { @@ -86,7 +94,7 @@ __ __ __ Log.Information("Contacting GitHub with provided token under product header {Header}", productHeader); await RunGitHubService(token!, productHeader, org!); - }); + }, tokenOption, orgOption, productHeaderOption, verboseOption, logFileOption); await rootCommand.InvokeAsync(args); } From 39356be3c10122d63c2e8ec118bf63c5d6a58c92 Mon Sep 17 00:00:00 2001 From: Patrick Klaeren Date: Wed, 6 Jul 2022 16:07:59 +0100 Subject: [PATCH 3/3] Change to build --- build/Build.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/build/Build.cs b/build/Build.cs index b5f740d..8e3c325 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -60,7 +60,6 @@ class Build : NukeBuild .Executes(() => { DotNetRestore(s => s - .SetRuntime(Runtime) .SetProjectFile(Solution)); }); @@ -70,14 +69,12 @@ class Build : NukeBuild { DotNetBuild(s => s .SetProjectFile(Solution) - .SetRuntime(Runtime) .SetConfiguration(Configuration) .SetAssemblyVersion(GitVersion.AssemblySemVer) .SetFileVersion(GitVersion.AssemblySemFileVer) .SetInformationalVersion(GitVersion.InformationalVersion) .SetAuthors("Patrick Klaeren") - .SetCopyright("Copyright © 2022 Patrick Klaeren. All rights reserved.") - .EnableNoRestore()); + .SetCopyright("Copyright © 2022 Patrick Klaeren. All rights reserved.")); }); Target Publish => _ => _ @@ -106,9 +103,7 @@ DotNetPublishSettings GetBaseSettings() return new DotNetPublishSettings() .SetProject(SourceDirectory / "MassHub.CLI" / "MassHub.CLI.csproj") .SetRuntime(Runtime) - .SetConfiguration(Configuration) - .EnableNoRestore() - .EnableNoBuild(); + .SetConfiguration(Configuration); } }); }