Skip to content
This repository has been archived by the owner on Nov 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #85 from gep13/feature/GH-80
Browse files Browse the repository at this point in the history
Add build.sh for building on posix
  • Loading branch information
devlead authored Jun 30, 2020
2 parents cad3083 + 4c4fc1e commit ce93b64
Show file tree
Hide file tree
Showing 18 changed files with 333 additions and 129 deletions.
24 changes: 23 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://EditorConfig.org


root = true

[*]
end_of_line = CRLF
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{sln,csproj}]
end_of_line = crlf

[*.md]
trim_trailing_whitespace = false

[*.ps1]
indent_style = space
indent_size = 2
charset = utf-8-bom
end_of_line = crlf

[*.{yml,yaml}]
indent_size = 2
indent_style = space

# Files that need to be crlf eol to work
[tasks.json]
end_of_line = crlf

[*.cs]
indent_style = space
Expand Down
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.301'

- name: Run Frosting Build
env:
DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX: 2
run: |
dotnet run --project ./build/Build.csproj
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ packages

# Windows
Thumbs.db

.DS_Store
14 changes: 10 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# Image used
image: Visual Studio 2019
image:
- Visual Studio 2019
- Ubuntu

environment:
APPVEYOR_YML_DISABLE_PS_LINUX: true

# Build script
init:
- git config --global core.autocrlf true
- ps: git config --global core.autocrlf true

# Build script
build_script:
- ps: .\build.ps1 -Target "AppVeyor"
- ps: .\build.ps1 --target="AppVeyor"
- sh: ./build.sh --target="AppVeyor"

# Tests
test: off
Expand All @@ -24,4 +30,4 @@ branches:

# Build cache
cache:
- tools -> build.ps1, global.json
- tools -> build.ps1, global.json, build.sh, build.config
2 changes: 2 additions & 0 deletions build.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
DOTNET_VERSION=3.1.301
90 changes: 20 additions & 70 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
<#
.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 WhatIf
Performs a dry run of the build script.
No tasks will be executed.
.PARAMETER ScriptArgs
Remaining arguments are added here.
.LINK
https://cakebuild.net
#>
#!/usr/bin/env pwsh
$DotNetInstallerUri = 'https://dot.net/v1/dotnet-install.ps1';
$DotNetUnixInstallerUri = 'https://dot.net/v1/dotnet-install.sh'
$DotNetChannel = 'LTS'
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent

[string] $DotNetVersion= ''
foreach($line in Get-Content (Join-Path $PSScriptRoot 'build.config'))
{
if ($line -like 'DOTNET_VERSION=*') {
$DotNetVersion =$line.SubString(15)
}
}

[CmdletBinding()]
Param(
[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
)

$DotNetVersion = "3.1.301";
if ([string]::IsNullOrEmpty($DotNetVersion)) {
'Failed to parse .NET Core SDK Version'
exit 1
}

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

# Make sure tools folder exists
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
Expand Down Expand Up @@ -77,44 +62,9 @@ if($FoundDotNetCliVersion -ne $DotNetVersion) {
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
}

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

# Make sure nuget.exe exists.
$NugetPath = Join-Path $ToolPath "nuget.exe"
if (!(Test-Path $NugetPath)) {
Write-Host "Downloading NuGet.exe..."
(New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath);
}

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

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

try {
Push-Location
Set-Location build
Write-Host "Restoring packages..."
Invoke-Expression "dotnet restore"
if($LASTEXITCODE -eq 0) {
Write-Output "Compiling build..."
Invoke-Expression "dotnet publish -c Debug /v:q /nologo"
if($LASTEXITCODE -eq 0) {
Write-Output "Running build..."
Invoke-Expression "bin/Debug/net461/publish/Build.exe $Arguments"
}
}
}
finally {
Pop-Location
exit $LASTEXITCODE;
}
dotnet run --project build/Build.csproj -- $args
exit $LASTEXITCODE;
38 changes: 38 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Define varibles
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source $SCRIPT_DIR/build.config

if [ "$DOTNET_VERSION" = "" ]; then
echo "An error occured while parsing .NET Core SDK version."
exit 1
fi

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

export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
export DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2

DOTNET_INSTALLED_VERSION=$(dotnet --version 2>&1)

if [ "$DOTNET_VERSION" != "$DOTNET_INSTALLED_VERSION" ]; then
echo "Installing .NET CLI..."
if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then
mkdir "$SCRIPT_DIR/.dotnet"
fi
curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://dot.net/v1/dotnet-install.sh
bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version $DOTNET_VERSION --install-dir .dotnet --no-path
export PATH="$SCRIPT_DIR/.dotnet":$PATH
export DOTNET_ROOT="$SCRIPT_DIR/.dotnet"
fi

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

echo "Running build script.."
dotnet run --project ./build/Build.csproj -- "$@"
7 changes: 5 additions & 2 deletions build/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>

<!-- Make sure start same folder .NET Core CLI and Visual Studio -->
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Frosting" Version="0.33.0" />
<PackageReference Include="Cake.Frosting" Version="0.38.2" />
</ItemGroup>

</Project>
23 changes: 13 additions & 10 deletions build/Build.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26127.3
# Visual Studio Version 16
VisualStudioVersion = 16.0.30204.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Build", "Build.csproj", "{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}"
EndProject
Expand All @@ -17,18 +17,21 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x64.ActiveCfg = Debug|x64
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x64.Build.0 = Debug|x64
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x86.ActiveCfg = Debug|x86
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x86.Build.0 = Debug|x86
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x64.ActiveCfg = Debug|Any CPU
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x64.Build.0 = Debug|Any CPU
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x86.ActiveCfg = Debug|Any CPU
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Debug|x86.Build.0 = Debug|Any CPU
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|Any CPU.Build.0 = Release|Any CPU
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x64.ActiveCfg = Release|x64
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x64.Build.0 = Release|x64
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x86.ActiveCfg = Release|x86
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x86.Build.0 = Release|x86
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x64.ActiveCfg = Release|Any CPU
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x64.Build.0 = Release|Any CPU
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x86.ActiveCfg = Release|Any CPU
{0F5ED648-CEE0-47EB-8CDD-A881159B4F8E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {062A93C5-869B-4AE7-8B68-B69E878C1507}
EndGlobalSection
EndGlobal
Loading

0 comments on commit ce93b64

Please sign in to comment.