Skip to content

Commit

Permalink
Merge pull request #6 from plioi/dotnet-core-rc2
Browse files Browse the repository at this point in the history
Converted project to .NET Core RC2
  • Loading branch information
plioi authored Jun 14, 2016
2 parents 55d0a5d + ad6b0c4 commit 0bf6671
Show file tree
Hide file tree
Showing 27 changed files with 226 additions and 452 deletions.
13 changes: 4 additions & 9 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
*.sln text eol=crlf
*.xproj text
*.cs text diff=csharp
*.json text
*.txt text
*.md text

*.cmd text
*.ps1 text

*.sln text eol=crlf merge=union
*.csproj text merge=union
*.cs text diff=csharp
*.config text
*.nuspec text

*.exe binary
*.dll binary
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/artifacts
bin/
obj/
/package/
/src/.vs/
/src/packages/
*.DotSettings.user
*.csproj.user
/.vs/
*.xproj.user
project.lock.json
39 changes: 39 additions & 0 deletions Parsley.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C902614B-5143-4941-9B54-EDB3404B8BF3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DCEC42EC-44D3-4E1B-9F5A-E792B5476B18}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Parsley", "src\Parsley\Parsley.xproj", "{432C32EC-8A54-49A6-900E-C0BA38CB3DF4}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Parsley.Tests", "src\Parsley.Tests\Parsley.Tests.xproj", "{21999188-73BC-4C1A-9E9F-1D3E13A472F2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{432C32EC-8A54-49A6-900E-C0BA38CB3DF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{432C32EC-8A54-49A6-900E-C0BA38CB3DF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{432C32EC-8A54-49A6-900E-C0BA38CB3DF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{432C32EC-8A54-49A6-900E-C0BA38CB3DF4}.Release|Any CPU.Build.0 = Release|Any CPU
{21999188-73BC-4C1A-9E9F-1D3E13A472F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21999188-73BC-4C1A-9E9F-1D3E13A472F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21999188-73BC-4C1A-9E9F-1D3E13A472F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21999188-73BC-4C1A-9E9F-1D3E13A472F2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{432C32EC-8A54-49A6-900E-C0BA38CB3DF4} = {C902614B-5143-4941-9B54-EDB3404B8BF3}
{21999188-73BC-4C1A-9E9F-1D3E13A472F2} = {C902614B-5143-4941-9B54-EDB3404B8BF3}
EndGlobalSection
EndGlobal
24 changes: 24 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '{build}'
pull_requests:
do_not_increment_build_number: true
branches:
only:
- master
init:
- cmd: git config --global core.autocrlf true
cache: '%USERPROFILE%\.nuget\packages -> **\project.json'
nuget:
disable_publish_on_pr: true
build_script:
- ps: .\build.ps1
test: off
artifacts:
- path: .\artifacts\**\*.nupkg
name: NuGet
deploy:
- provider: NuGet
api_key:
secure: uZjEAcNGvpxiTjzUDui5CRQcbr9187WEhqUlPxFpDa7VxU3+n4OY+9uQ73cRSYtK
on:
branch: master
appveyor_repo_tag: true
199 changes: 32 additions & 167 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,135 +1,39 @@
param([string]$target)

$birthYear = 2011
$maintainers = "Patrick Lioi"
$configuration = 'Release'
$version = '0.0.7'

function main {
try {
step { Restore }
step { AssemblyInfo }
step { License }
step { Compile }
step { Test }
step { Restore }
step { Build }
step { Test }

if ($target -eq "package") {
step { Package }
}

write-host
write-host "Build Succeeded!" -fore GREEN
write-host
summarize-steps
exit 0
} catch [Exception] {
write-host
write-host $_.Exception.Message -fore RED
write-host
write-host "Build Failed!" -fore RED
exit 1
if ($env:APPVEYOR_BUILD_NUMBER -ne $NULL) {
step { Pack }
}
}

function Restore {
tools\NuGet.exe restore src\Parsley.sln -source "https://nuget.org/api/v2/" -RequireConsent -o "src\packages"
exec { & dotnet restore --verbosity Warning }
}

function Package {
rd package -recurse -force -ErrorAction SilentlyContinue | out-null
mkdir package -ErrorAction SilentlyContinue | out-null
exec { & tools\NuGet.exe pack src\Parsley\Parsley.csproj -Symbols -Prop Configuration=$configuration -OutputDirectory package }

write-host
write-host "To publish these packages, issue the following command:"
write-host " tools\NuGet push package\Parsley.$version.nupkg"
function Build() {
exec { & dotnet build .\src\Parsley --configuration Release }
exec { & dotnet build .\src\Parsley.Tests --configuration Release }
}

function Test {
$testRunners = @(gci src\packages -rec -filter xunit.console.exe)

if ($testRunners.Length -ne 1) {
throw "Expected to find 1 xunit.console.exe, but found $($testRunners.Length)."
}

$testRunner = $testRunners[0].FullName

$projects = @(gci src -rec -filter *.csproj)
foreach ($project in $projects) {
$projectName = [System.IO.Path]::GetFileNameWithoutExtension($project)

if ($projectName.EndsWith("Tests")) {
$testAssembly = "$($project.Directory)\bin\$configuration\$projectName.dll"
exec { & $testRunner $testAssembly }
}
}
exec { & dotnet test .\src\Parsley.Tests --configuration Release }
}

function Compile {
Set-Alias msbuild (get-msbuild-path)
exec { msbuild /t:clean /v:q /nologo /p:Configuration=$configuration src\Parsley.sln }
exec { msbuild /t:build /v:q /nologo /p:Configuration=$configuration src\Parsley.sln }
}

function AssemblyInfo {
$assemblyVersion = $version
if ($assemblyVersion.Contains("-")) {
$assemblyVersion = $assemblyVersion.Substring(0, $assemblyVersion.IndexOf("-"))
}

$copyright = get-copyright

$projects = @(gci src -rec -filter *.csproj)
foreach ($project in $projects) {
$projectName = [System.IO.Path]::GetFileNameWithoutExtension($project)

regenerate-file "$($project.DirectoryName)\Properties\AssemblyInfo.cs" @"
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
[assembly: AssemblyProduct("Parsley")]
[assembly: AssemblyTitle("$projectName")]
[assembly: AssemblyVersion("$assemblyVersion")]
[assembly: AssemblyFileVersion("$assemblyVersion")]
[assembly: AssemblyInformationalVersion("$version")]
[assembly: AssemblyCopyright("$copyright")]
[assembly: AssemblyCompany("$maintainers")]
[assembly: AssemblyConfiguration("$configuration")]
"@
function Pack {
if ([System.IO.Directory]::Exists(".\artifacts")) {
[System.IO.Directory]::Delete(".\artifacts", $true)
}
$revision = $env:APPVEYOR_BUILD_NUMBER
$revision = "{0:D4}" -f [convert]::ToInt32($revision, 10)
exec { & dotnet pack .\src\Parsley --configuration Release --output .\artifacts --version-suffix=$revision }
}

function License {
$copyright = get-copyright

regenerate-file "LICENSE.txt" @"
The MIT License (MIT)
$copyright
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"@
}

function get-copyright {
$date = Get-Date
$year = $date.Year
$copyrightSpan = if ($year -eq $birthYear) { $year } else { "$birthYear-$year" }
return "Copyright © $copyrightSpan $maintainers"
}

function regenerate-file($path, $newContent) {
$oldContent = [IO.File]::ReadAllText($path)

if ($newContent -ne $oldContent) {
$relativePath = Resolve-Path -Relative $path
write-host "Generating $relativePath"
[System.IO.File]::WriteAllText($path, $newContent, [System.Text.Encoding]::UTF8)
}
function step($block) {
$name = $block.ToString().Trim().Split(' ')[0]
write-host "Executing $name" -fore CYAN
&$block
}

function exec($cmd) {
Expand All @@ -140,54 +44,15 @@ function exec($cmd) {
}
}

function get-msbuild-path {
[cmdletbinding()]
param(
[Parameter(Position=0)]
[ValidateSet('32bit','64bit')]
[string]$bitness = '32bit'
)
process{

# Find the highest installed version of msbuild.exe.

$regLocalKey = $null

if($bitness -eq '32bit') {
$regLocalKey = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,[Microsoft.Win32.RegistryView]::Registry32)
} else {
$regLocalKey = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,[Microsoft.Win32.RegistryView]::Registry64)
}

$versionKeyName = $regLocalKey.OpenSubKey('SOFTWARE\Microsoft\MSBuild\ToolsVersions\').GetSubKeyNames() | Sort-Object {[double]$_} -Descending

$keyToReturn = ('SOFTWARE\Microsoft\MSBuild\ToolsVersions\{0}' -f $versionKeyName)

$path = ( '{0}msbuild.exe' -f $regLocalKey.OpenSubKey($keyToReturn).GetValue('MSBuildToolsPath'))

return $path
}
}

function step($block) {
$name = $block.ToString().Trim()
write-host "Executing $name" -fore CYAN
$sw = [Diagnostics.Stopwatch]::StartNew()
&$block
$sw.Stop()

if (!$script:timings) {
$script:timings = @()
}

$script:timings += new-object PSObject -property @{
Name = $name;
Duration = $sw.Elapsed
}
}

function summarize-steps {
$script:timings | format-table -autoSize -property Name,Duration | out-string -stream | where-object { $_ }
}

main
try {
main
write-host
write-host "Build Succeeded!" -fore GREEN
exit 0
} catch [Exception] {
write-host
write-host $_.Exception.Message -fore DARKRED
write-host
write-host "Build Failed!" -fore DARKRED
exit 1
}
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview1-002702"
}
}
7 changes: 7 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
1 change: 1 addition & 0 deletions src/Parsley.Tests/ErrorMessageListTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using Shouldly;
using Xunit;
using ErrorMessage = Parsley.ErrorMessage;

public class ErrorMessageListTests
{
Expand Down
1 change: 1 addition & 0 deletions src/Parsley.Tests/ErrorMessageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using Shouldly;
using Xunit;
using ErrorMessage = Parsley.ErrorMessage;

public class ErrorMessageTests
{
Expand Down
1 change: 1 addition & 0 deletions src/Parsley.Tests/ErrorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using Shouldly;
using Xunit;
using ErrorMessage = Parsley.ErrorMessage;

public class ErrorTests
{
Expand Down
1 change: 1 addition & 0 deletions src/Parsley.Tests/LambdaParserTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Parsley.Tests
{
using Xunit;
using ErrorMessage = Parsley.ErrorMessage;

public class LambdaParserTests
{
Expand Down
1 change: 1 addition & 0 deletions src/Parsley.Tests/ParsedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using Shouldly;
using Xunit;
using ErrorMessage = Parsley.ErrorMessage;

public class ParsedTests
{
Expand Down
Loading

0 comments on commit 0bf6671

Please sign in to comment.