diff --git a/README.md b/README.md index e69de29..e69fe0f 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,7 @@ +# DotNetLocalizer + +AppVeyor: + +[![Build status](https://ci.appveyor.com/api/projects/status/6lshcksp3oh9craj?svg=true)](https://ci.appveyor.com/project/Baklap4/dotnetlocalizer) + +# TBA ..... \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..4eb6643 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,15 @@ +version: 1.0.{build} +pull_requests: + do_not_increment_build_number: true +build_script: +- ps: '& ./build.ps1 -target pack' +test_script: +- ps: '& ./build.ps1 -target test' +artifacts: +- path: output\*.nupkg + name: NuGet +deploy: +- provider: Environment + name: NuGet + on: + branch: master \ No newline at end of file diff --git a/build.cake b/build.cake new file mode 100644 index 0000000..8fc452b --- /dev/null +++ b/build.cake @@ -0,0 +1,91 @@ +#addin "Cake.Powershell" + +var target = Argument("target", "Default"); +var configuration = Argument("configuration", "Release"); + +var versionSuffix = "nuget-test"; + +var isRunningOnAppVeyor = AppVeyor.IsRunningOnAppVeyor; + +Task("Clean") + .Does(() => +{ + CleanDirectories("./src/**/bin"); + CleanDirectories("./src/**/obj"); +}); + +Task("Restore") + .IsDependentOn("Clean") + .Does(() => +{ + DotNetCoreRestore("./src/DotNetLocalizer.Core"); + DotNetCoreRestore("./src/DotNetLocalizer.Json"); + DotNetCoreRestore("./src/DotNetLocalizer.Yaml"); +}); + +Task("Build") + .IsDependentOn("Restore") + .Does(() => +{ + var settings = new DotNetCoreBuildSettings + { + Configuration = configuration, + VersionSuffix = versionSuffix + }; + + DotNetCoreBuild("./src/DotNetLocalizer.Core", settings); + DotNetCoreBuild("./src/DotNetLocalizer.Json", settings); + DotNetCoreBuild("./src/DotNetLocalizer.Yaml", settings); +}); + +Task("Test") + .IsDependentOn("Build") + .Does(() => +{ + // TODO +}); + +Task("Version") + .Does(() => +{ + if (!isRunningOnAppVeyor) + { + throw new InvalidOperationException("Can only set version when running on AppVeyor"); + } + + var version = AppVeyor.Environment.Build.Version; + + StartPowershellFile("./update-version.ps1", args => + { + args.Append("projectFile", "./src/DotNetLocalizer.Core/DotNetLocalizer.Core.csproj").Append("version", version); + }); + StartPowershellFile("./update-version.ps1", args => + { + args.Append("projectFile", "./src/DotNetLocalizer.Json/DotNetLocalizer.Json.csproj").Append("version", version); + }); + StartPowershellFile("./update-version.ps1", args => + { + args.Append("projectFile", "./src/DotNetLocalizer.Yaml/DotNetLocalizer.Yaml.csproj").Append("version", version); + }); +}); + +Task("Pack") + .IsDependentOn("Version") + .IsDependentOn("Build") + .Does(() => +{ + var settings = new DotNetCorePackSettings + { + Configuration = "Release", + OutputDirectory = "./output/" + }; + + DotNetCorePack("./src/DotNetLocalizer.Core", settings); + DotNetCorePack("./src/DotNetLocalizer.Json", settings); + DotNetCorePack("./src/DotNetLocalizer.Yaml", settings); +}); + +Task("Default") + .IsDependentOn("Test"); + +RunTarget(target); \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..abec05c --- /dev/null +++ b/build.ps1 @@ -0,0 +1,140 @@ +<# + +.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 Script +The build script to execute. +.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. + +.LINK +http://cakebuild.net + +#> + +[CmdletBinding()] +Param( + [string]$Script = "build.cake", + [string]$Target = "Default", + [string]$Configuration = "Release", + [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 +) + +Write-Host "Preparing to run build script..." + +$PS_SCRIPT_ROOT = split-path -parent $MyInvocation.MyCommand.Definition; +$TOOLS_DIR = Join-Path $PSScriptRoot "tools" +$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" +$NUGET_URL = "http://dist.nuget.org/win-x86-commandline/latest/nuget.exe" +$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" +$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" + +# 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 +} + +# Make sure that packages.config exist. +if (!(Test-Path $PACKAGES_CONFIG)) { + Write-Verbose -Message "Downloading packages.config..." + try { Invoke-WebRequest -Uri http://cakebuild.net/download/bootstrapper/packages -OutFile $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 $_) } + $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) +{ + # Restore packages from NuGet. + Push-Location + Set-Location $TOOLS_DIR + + Write-Verbose -Message "Restoring tools from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" + Write-Verbose -Message ($NuGetOutput | out-string) + + Pop-Location + if ($LASTEXITCODE -ne 0) + { + exit $LASTEXITCODE + } +} + +# Make sure that Cake has been installed. +if (!(Test-Path $CAKE_EXE)) { + Throw "Could not find Cake.exe at $CAKE_EXE" +} + +# Start Cake +Write-Host "Running build script..." +Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs" +exit $LASTEXITCODE \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..b03e92a --- /dev/null +++ b/build.sh @@ -0,0 +1,63 @@ +#!/bin/bash +############################################################### +# This is the Cake bootstrapper script that is responsible for +# downloading Cake and all specified tools from NuGet. +############################################################### + +# Define directories. +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +TOOLS_DIR=$SCRIPT_DIR/tools +NUGET_EXE=$TOOLS_DIR/nuget.exe +CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe + +# Define default arguments. +SCRIPT="build.cake" +TARGET="Default" +CONFIGURATION="Release" +VERBOSITY="verbose" +DRYRUN=false +SHOW_VERSION=false + +# Parse arguments. +for i in "$@"; do + case $1 in + -s|--script) SCRIPT="$2"; shift ;; + -t|--target) TARGET="$2"; shift ;; + -c|--configuration) CONFIGURATION="$2"; shift ;; + -v|--verbosity) VERBOSITY="$2"; shift ;; + -d|--dryrun) DRYRUN=true ;; + --version) SHOW_VERSION=true ;; + esac + shift +done + +# Download NuGet if it does not exist. +if [ ! -f $NUGET_EXE ]; then + echo "Downloading NuGet..." + curl -Lsfo $NUGET_EXE https://www.nuget.org/nuget.exe + if [ $? -ne 0 ]; then + echo "An error occured while downloading nuget.exe." + exit 1 + fi +fi + +# Restore tools from NuGet. +pushd $TOOLS_DIR >/dev/null +mono $NUGET_EXE install -ExcludeVersion +popd >/dev/null + +# Make sure that Cake has been installed. +if [ ! -f $CAKE_EXE ]; then + echo "Could not find Cake.exe." + exit 1 +fi + +# Start Cake +if $SHOW_VERSION; then + mono $CAKE_EXE -version +elif $DRYRUN; then + mono $CAKE_EXE $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET -dryrun +else + mono $CAKE_EXE $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET +fi +exit $? \ No newline at end of file diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..edc9b38 --- /dev/null +++ b/nuget.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/DotNetLocalizer.Core/DotNetLocalizer.Core.csproj b/src/DotNetLocalizer.Core/DotNetLocalizer.Core.csproj index 3ae62fd..cd36ce1 100644 --- a/src/DotNetLocalizer.Core/DotNetLocalizer.Core.csproj +++ b/src/DotNetLocalizer.Core/DotNetLocalizer.Core.csproj @@ -2,6 +2,7 @@ netcoreapp1.1 + 1.0.0 diff --git a/src/DotNetLocalizer.Json/DotNetLocalizer.Json.csproj b/src/DotNetLocalizer.Json/DotNetLocalizer.Json.csproj index 13b239a..76bf1ce 100644 --- a/src/DotNetLocalizer.Json/DotNetLocalizer.Json.csproj +++ b/src/DotNetLocalizer.Json/DotNetLocalizer.Json.csproj @@ -1,15 +1,14 @@  - netcoreapp1.1 + 1.0.0 - + - + - + - + - \ No newline at end of file diff --git a/src/DotNetLocalizer.Yaml/DotNetLocalizer.Yaml.csproj b/src/DotNetLocalizer.Yaml/DotNetLocalizer.Yaml.csproj index f269fd2..37c8415 100644 --- a/src/DotNetLocalizer.Yaml/DotNetLocalizer.Yaml.csproj +++ b/src/DotNetLocalizer.Yaml/DotNetLocalizer.Yaml.csproj @@ -1,11 +1,10 @@  - netcoreapp1.1 + 1.0.0 - \ No newline at end of file diff --git a/tools/packages.config b/tools/packages.config new file mode 100644 index 0000000..403e579 --- /dev/null +++ b/tools/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/update-version.ps1 b/update-version.ps1 new file mode 100644 index 0000000..466f668 --- /dev/null +++ b/update-version.ps1 @@ -0,0 +1,23 @@ +param( + [Parameter(Mandatory=$true)] + [string] + $projectFile, + + [Parameter(Mandatory=$true)] + [string] + $version +) + +trap +{ + write-output $_ + exit 1 +} + +if (-Not (Test-Path $projectFile)) { + throw "Could not file project file '$projectFile'" +} + +$xml = [xml](Get-Content $projectFile) +$xml.Project.PropertyGroup.Version = "$version" +$xml.Save($projectFile) \ No newline at end of file