Updated nuke

This commit is contained in:
Benjamin Höglinger-Stelzer 2019-12-27 19:54:38 +01:00
parent 9968888362
commit c9a1de27ca
7 changed files with 79 additions and 63 deletions

1
.nuke
View File

@ -0,0 +1 @@
PInvokeSerialPort.sln

View File

@ -1,9 +1,9 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio Version 16
VisualStudioVersion = 15.0.28307.106 VisualStudioVersion = 16.0.29613.14
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PInvokeSerialPort", "PInvokeSerialPort\PInvokeSerialPort.csproj", "{AEC711A5-AA9B-4127-A82C-C4D8FDA9741A}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PInvokeSerialPort", "PInvokeSerialPort\PInvokeSerialPort.csproj", "{AEC711A5-AA9B-4127-A82C-C4D8FDA9741A}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{99052083-B245-462F-8778-4C94662ABABE}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{99052083-B245-462F-8778-4C94662ABABE}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
@ -17,7 +17,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PInvokeSerialPort.Test", "P
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PInvokeSerialPort.Sample", "PInvokeSerialPort.Sample\PInvokeSerialPort.Sample.csproj", "{76FAB402-7515-4A9B-8605-4FEC0736C78A}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PInvokeSerialPort.Sample", "PInvokeSerialPort.Sample\PInvokeSerialPort.Sample.csproj", "{76FAB402-7515-4A9B-8605-4FEC0736C78A}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{00930300-354F-4060-9A3C-9EB73D7678D7}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{74EBF183-3069-4E47-865A-8EB76FBCD0C6}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -61,14 +61,16 @@ Global
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|Mixed Platforms.Build.0 = Release|x86 {76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|Mixed Platforms.Build.0 = Release|x86
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|x86.ActiveCfg = Release|x86 {76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|x86.ActiveCfg = Release|x86
{76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|x86.Build.0 = Release|x86 {76FAB402-7515-4A9B-8605-4FEC0736C78A}.Release|x86.Build.0 = Release|x86
{00930300-354F-4060-9A3C-9EB73D7678D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {74EBF183-3069-4E47-865A-8EB76FBCD0C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00930300-354F-4060-9A3C-9EB73D7678D7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {74EBF183-3069-4E47-865A-8EB76FBCD0C6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{00930300-354F-4060-9A3C-9EB73D7678D7}.Debug|x86.ActiveCfg = Debug|Any CPU {74EBF183-3069-4E47-865A-8EB76FBCD0C6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{00930300-354F-4060-9A3C-9EB73D7678D7}.Debug|x86.Build.0 = Debug|Any CPU {74EBF183-3069-4E47-865A-8EB76FBCD0C6}.Debug|x86.ActiveCfg = Debug|Any CPU
{00930300-354F-4060-9A3C-9EB73D7678D7}.Release|Any CPU.ActiveCfg = Release|Any CPU {74EBF183-3069-4E47-865A-8EB76FBCD0C6}.Debug|x86.Build.0 = Debug|Any CPU
{00930300-354F-4060-9A3C-9EB73D7678D7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {74EBF183-3069-4E47-865A-8EB76FBCD0C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00930300-354F-4060-9A3C-9EB73D7678D7}.Release|x86.ActiveCfg = Release|Any CPU {74EBF183-3069-4E47-865A-8EB76FBCD0C6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{00930300-354F-4060-9A3C-9EB73D7678D7}.Release|x86.Build.0 = Release|Any CPU {74EBF183-3069-4E47-865A-8EB76FBCD0C6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{74EBF183-3069-4E47-865A-8EB76FBCD0C6}.Release|x86.ActiveCfg = Release|Any CPU
{74EBF183-3069-4E47-865A-8EB76FBCD0C6}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -1,11 +1,10 @@
[CmdletBinding()] [CmdletBinding()]
Param( Param(
#[switch]$CustomParam,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$BuildArguments [string[]]$BuildArguments
) )
Write-Output "Windows PowerShell $($Host.Version)" Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { exit 1 } Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { exit 1 }
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
@ -23,7 +22,6 @@ $DotNetChannel = "Current"
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 $env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
$env:NUGET_XMLDOC_MODE = "skip"
########################################################################### ###########################################################################
# EXECUTION # EXECUTION
@ -36,11 +34,14 @@ function ExecSafe([scriptblock] $cmd) {
# If global.json exists, load expected version # If global.json exists, load expected version
if (Test-Path $DotNetGlobalFile) { if (Test-Path $DotNetGlobalFile) {
$DotNetVersion = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json).sdk.version $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 is installed locally, and expected version is not set or installation matches the expected version
if ((Get-Command "dotnet" -ErrorAction SilentlyContinue) -ne $null -and ` if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
(!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) { (!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) {
$env:DOTNET_EXE = (Get-Command "dotnet").Path $env:DOTNET_EXE = (Get-Command "dotnet").Path
} }
@ -50,7 +51,7 @@ else {
# Download install script # Download install script
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
md -force $TempDirectory > $null New-Item -ItemType Directory -Path $TempDirectory | Out-Null
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
# Install by channel or version # Install by channel or version
@ -63,4 +64,5 @@ else {
Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)" Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile -- $BuildArguments } ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false }
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }

View File

@ -2,16 +2,6 @@
echo $(bash --version 2>&1 | head -n 1) echo $(bash --version 2>&1 | head -n 1)
#CUSTOMPARAM=0
BUILD_ARGUMENTS=()
for i in "$@"; do
case $(echo $1 | awk '{print tolower($0)}') in
# -custom-param) CUSTOMPARAM=1;;
*) BUILD_ARGUMENTS+=("$1") ;;
esac
shift
done
set -eo pipefail set -eo pipefail
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
@ -28,23 +18,25 @@ DOTNET_CHANNEL="Current"
export DOTNET_CLI_TELEMETRY_OPTOUT=1 export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export NUGET_XMLDOC_MODE="skip"
########################################################################### ###########################################################################
# EXECUTION # EXECUTION
########################################################################### ###########################################################################
function FirstJsonValue { 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 global.json exists, load expected version
if [ -f "$DOTNET_GLOBAL_FILE" ]; then if [ -f "$DOTNET_GLOBAL_FILE" ]; then
DOTNET_VERSION=$(FirstJsonValue "version" $(cat "$DOTNET_GLOBAL_FILE")) DOTNET_VERSION=$(FirstJsonValue "version" $(cat "$DOTNET_GLOBAL_FILE"))
if [ "$DOTNET_VERSION" == "" ]; then
unset DOTNET_VERSION
fi
fi fi
# If dotnet is installed locally, and expected version is not set or installation matches the expected version # 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) == "$DOTNET_VERSION") ]]; then if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version 2>&1) == "$DOTNET_VERSION") ]]; then
export DOTNET_EXE="$(command -v dotnet)" export DOTNET_EXE="$(command -v dotnet)"
else else
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
@ -66,4 +58,5 @@ fi
echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)" echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)"
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" -- ${BUILD_ARGUMENTS[@]} "$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"

10
build/.editorconfig Normal file
View File

@ -0,0 +1,10 @@
[*.cs]
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning
dotnet_style_require_accessibility_modifiers = never:warning
csharp_style_expression_bodied_properties = true:warning
csharp_style_expression_bodied_indexers = true:warning
csharp_style_expression_bodied_accessors = true:warning

View File

@ -2,53 +2,60 @@ using System;
using System.Linq; using System.Linq;
using Nuke.Common; using Nuke.Common;
using Nuke.Common.CI.AppVeyor; using Nuke.Common.CI.AppVeyor;
using Nuke.Common.Execution;
using Nuke.Common.Git; using Nuke.Common.Git;
using Nuke.Common.ProjectModel; using Nuke.Common.ProjectModel;
using Nuke.Common.Tools.GitVersion; using Nuke.Common.Tooling;
using Nuke.Common.Tools.MSBuild; using Nuke.Common.Tools.DotNet;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.EnvironmentInfo; using static Nuke.Common.EnvironmentInfo;
using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction; using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.MSBuild.MSBuildTasks; using static Nuke.Common.Tools.DotNet.DotNetTasks;
[CheckBuildProjectConfigurations]
[UnsetVisualStudioEnvironmentVariables]
class Build : NukeBuild class Build : NukeBuild
{ {
/// Support plugins are available for:
/// - JetBrains ReSharper https://nuke.build/resharper
/// - JetBrains Rider https://nuke.build/rider
/// - Microsoft VisualStudio https://nuke.build/visualstudio
/// - Microsoft VSCode https://nuke.build/vscode
public static int Main () => Execute<Build>(x => x.Compile); public static int Main () => Execute<Build>(x => x.Compile);
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly string Configuration = IsLocalBuild ? "Debug" : "Release"; readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
[Solution("PInvokeSerialPort.sln")] readonly Solution Solution; [Solution] readonly Solution Solution;
[GitRepository] readonly GitRepository GitRepository; [GitRepository] readonly GitRepository GitRepository;
[GitVersion] readonly GitVersion GitVersion;
Target Clean => _ => _ Target Clean => _ => _
.Before(Restore)
.Executes(() => .Executes(() =>
{ {
}); });
Target Restore => _ => _ Target Restore => _ => _
.DependsOn(Clean)
.Executes(() => .Executes(() =>
{ {
MSBuild(s => s DotNetRestore(_ => _
.SetTargetPath(Solution) .SetProjectFile(Solution));
.SetTargets("Restore"));
}); });
Target Compile => _ => _ Target Compile => _ => _
.DependsOn(Restore) .DependsOn(Restore)
.Executes(() => .Executes(() =>
{ {
MSBuild(s => s DotNetBuild(_ => _
.SetTargetPath(Solution) .SetProjectFile(Solution)
.SetTargets("Rebuild")
.SetConfiguration(Configuration) .SetConfiguration(Configuration)
.EnableNoRestore()
.SetAssemblyVersion(AppVeyor.Instance.BuildVersion) .SetAssemblyVersion(AppVeyor.Instance.BuildVersion)
.SetFileVersion(AppVeyor.Instance.BuildVersion) .SetFileVersion(AppVeyor.Instance.BuildVersion)
.SetInformationalVersion(AppVeyor.Instance.BuildVersion) .SetVersionSuffix(AppVeyor.Instance.BuildVersion)
.SetMaxCpuCount(Environment.ProcessorCount) .SetVersion(AppVeyor.Instance.BuildVersion));
.SetNodeReuse(IsLocalBuild));
}); });
} }

View File

@ -11,27 +11,28 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Nuke.Common" Version="0.23.4" /> <PackageReference Include="Nuke.Common" Version="0.23.4" />
<PackageReference Include="GitVersion.CommandLine.DotNetCore" Version="5.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<NukeMetadata Include="**\*.json" Exclude="bin\**;obj\**" /> <NukeSpecificationFiles Include="**\*.json" Exclude="bin\**;obj\**" />
<NukeExternalFiles Include="**\*.*.ext" Exclude="bin\**;obj\**" /> <NukeExternalFiles Include="**\*.*.ext" Exclude="bin\**;obj\**" />
<None Remove="*.csproj.DotSettings;*.ref.*.txt" /> <None Remove="*.csproj.DotSettings;*.ref.*.txt" />
<!-- Common build related files --> <!-- Common build related files -->
<None Include="..\build.ps1" /> <None Include="..\build.ps1" />
<None Include="..\build.sh" /> <None Include="..\build.sh" />
<None Include="..\.nuke" />
<None Include="..\global.json" Condition="Exists('..\global.json')" /> <None Include="..\.nuke" LinkBase="config" />
<None Include="..\nuget.config" Condition="Exists('..\nuget.config')" /> <None Include="..\global.json" LinkBase="config" Condition="Exists('..\global.json')" />
<None Include="..\Jenkinsfile" Condition="Exists('..\Jenkinsfile')" /> <None Include="..\nuget.config" LinkBase="config" Condition="Exists('..\nuget.config')" />
<None Include="..\appveyor.yml" Condition="Exists('..\appveyor.yml')" /> <None Include="..\GitVersion.yml" LinkBase="config" Condition="Exists('..\GitVersion.yml')" />
<None Include="..\.travis.yml" Condition="Exists('..\.travis.yml')" />
<None Include="..\GitVersion.yml" Condition="Exists('..\GitVersion.yml')" /> <None Include="..\.teamcity\settings.kts" LinkBase="ci" Condition="Exists('..\.teamcity\settings.kts')" />
<None Include="..\.github\workflows\*.yml" LinkBase="ci" />
<None Include="..\azure-pipelines.yml" LinkBase="ci" Condition="Exists('..\azure-pipelines.yml')" />
<None Include="..\Jenkinsfile" LinkBase="ci" Condition="Exists('..\Jenkinsfile')" />
<None Include="..\appveyor.yml" LinkBase="ci" Condition="Exists('..\appveyor.yml')" />
<None Include="..\.travis.yml" LinkBase="ci" Condition="Exists('..\.travis.yml')" />
</ItemGroup> </ItemGroup>
</Project> </Project>