Skip to content

Commit

Permalink
.Net Standard (#15)
Browse files Browse the repository at this point in the history
* remove obsolete file

* convert project to .net standard

* styleop update

* revert (supported in standard 1.5)

* remove gitlink

* xunit, stylecop, specflow

* fix usages of scenario context

* dotnet xunit

* use choco opencover on appveyor

* opecover dotnet.exe path

* fix path fix

* -oldstyle codecov

* full pdbs required by codecov

* ps exit code

* xunit -noshadow

* cake to test

* no need for opencover in appveyor

* fix build of docu.csproj

* fail if tests fail

* indent fix

* brig back stylecop settings for codefactor.io

* try to make open cover fail the build

* fix null return

* added gitlink to cake

* add gitlink to appveyor

* move all build scripts to cake

* fix appveyor cake script

* fix cake params

* haave gitversion update build number

* gitverions prerelease

* twaek gitversion task when on CI

* no need twice

* temporary workaround for context resolver

* fix test

* split tests in context readme

* typo and test for both method and property
  • Loading branch information
tpluscode committed Jan 3, 2019
1 parent 753ba07 commit 21be4e0
Show file tree
Hide file tree
Showing 66 changed files with 2,283 additions and 1,318 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ _TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover
opencover.xml

# NCrunch
_NCrunch_*
Expand Down Expand Up @@ -135,7 +136,7 @@ publish/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
**/packages/
# except build/, which is used as an MSBuild target.
!**/packages/build/
# If using the old MSBuild-Integrated Package Restore, uncomment this:
Expand Down Expand Up @@ -237,3 +238,7 @@ $RECYCLE.BIN/
src/JsonLD.Entities.Tests/ParsingTests
VersionAssemblyInfo.cs
.paket/paket.exe

!tools/
tools/*
!tools/llite/
40 changes: 31 additions & 9 deletions .paket/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<!-- Step 1 Check if lockfile is properly restored -->
<PropertyGroup>
<PaketRestoreRequired>true</PaketRestoreRequired>
<NoWarn>$(NoWarn);NU1603</NoWarn>
<NoWarn>$(NoWarn);NU1603;NU1604;NU1605;NU1608</NoWarn>
</PropertyGroup>

<!-- Because ReadAllText is slow on osx/linux, try to find shasum and awk -->
Expand All @@ -60,6 +60,9 @@
<Output TaskParameter="ConsoleOutput" PropertyName="PaketRestoreLockFileHash" />
</Exec>

<!-- Debug whats going on -->
<Message Importance="low" Text="calling paket restore with targetframework=$(TargetFramework) targetframeworks=$(TargetFrameworks)" />

<PropertyGroup Condition="Exists('$(PaketRestoreCacheFile)') ">
<!-- if no hash has been done yet fall back to just reading in the files and comparing them -->
<PaketRestoreCachedHash Condition=" '$(PaketRestoreCachedHash)' == '' ">$([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))</PaketRestoreCachedHash>
Expand All @@ -69,11 +72,22 @@
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
</PropertyGroup>

<PropertyGroup Condition="'$(PaketPropsVersion)' != '5.174.2' ">
<PaketRestoreRequired>true</PaketRestoreRequired>
</PropertyGroup>

<!-- Do a global restore if required -->
<Exec Command='$(PaketBootStrapperCommand)' Condition="Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))" ContinueOnError="false" />
<Exec Command='$(PaketCommand) restore' Condition=" '$(PaketRestoreRequired)' == 'true' " ContinueOnError="false" />

<!-- Step 2 Detect project specific changes -->
<ItemGroup>
<MyTargetFrameworks Condition="'$(TargetFramework)' != '' " Include="$(TargetFramework)"></MyTargetFrameworks>
<!-- Don't include all frameworks when msbuild explicitly asks for a single one -->
<MyTargetFrameworks Condition="'$(TargetFrameworks)' != '' AND '$(TargetFramework)' == '' " Include="$(TargetFrameworks)"></MyTargetFrameworks>
<PaketResolvedFilePaths Include="@(MyTargetFrameworks -> '$(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).%(Identity).paket.resolved')"></PaketResolvedFilePaths>
</ItemGroup>
<Message Importance="low" Text="MyTargetFrameworks=@(MyTargetFrameworks) PaketResolvedFilePaths=@(PaketResolvedFilePaths)" />
<PropertyGroup>
<PaketReferencesCachedFilePath>$(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).paket.references.cached</PaketReferencesCachedFilePath>
<!-- MyProject.fsproj.paket.references has the highest precedence -->
Expand All @@ -82,7 +96,9 @@
<PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketOriginalReferencesFilePath>
<!-- paket.references -->
<PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\paket.references</PaketOriginalReferencesFilePath>
<PaketResolvedFilePath>$(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).$(TargetFramework).paket.resolved</PaketResolvedFilePath>

<DoAllResolvedFilesExist>false</DoAllResolvedFilesExist>
<DoAllResolvedFilesExist Condition="Exists(%(PaketResolvedFilePaths.Identity))">true</DoAllResolvedFilesExist>
<PaketRestoreRequired>true</PaketRestoreRequired>
<PaketRestoreRequiredReason>references-file-or-cache-not-found</PaketRestoreRequiredReason>
</PropertyGroup>
Expand All @@ -101,33 +117,39 @@
</PropertyGroup>

<!-- Step 2 b detect relevant changes in project file (new targetframework) -->
<PropertyGroup Condition=" !Exists('$(PaketResolvedFilePath)') AND '$(TargetFramework)' != '' ">
<PropertyGroup Condition=" '$(DoAllResolvedFilesExist)' != 'true' ">
<PaketRestoreRequired>true</PaketRestoreRequired>
<PaketRestoreRequiredReason>target-framework '$(TargetFramework)'</PaketRestoreRequiredReason>
<PaketRestoreRequiredReason>target-framework '$(TargetFramework)' or '$(TargetFrameworks)' files @(PaketResolvedFilePaths)</PaketRestoreRequiredReason>
</PropertyGroup>

<!-- Step 3 Restore project specific stuff if required -->
<Message Condition=" '$(PaketRestoreRequired)' == 'true' " Importance="low" Text="Detected a change ('$(PaketRestoreRequiredReason)') in the project file '$(MSBuildProjectFullPath)', calling paket restore" />
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)"' Condition=" '$(PaketRestoreRequired)' == 'true' " ContinueOnError="false" />
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)" --target-framework "$(TargetFrameworks)"' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(TargetFramework)' == '' " ContinueOnError="false" />
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)" --target-framework "$(TargetFramework)"' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(TargetFramework)' != '' " ContinueOnError="false" />

<!-- This shouldn't actually happen, but just to be sure. -->
<Error Condition=" !Exists('$(PaketResolvedFilePath)') AND '$(TargetFramework)' != '' AND '$(ResolveNuGetPackages)' != 'False' " Text="Paket file '$(PaketResolvedFilePath)' is missing while restoring $(MSBuildProjectFile). Please delete 'paket-files/paket.restore.cached' and call 'paket restore'." />
<PropertyGroup>
<DoAllResolvedFilesExist>false</DoAllResolvedFilesExist>
<DoAllResolvedFilesExist Condition="Exists(%(PaketResolvedFilePaths.Identity))">true</DoAllResolvedFilesExist>
</PropertyGroup>
<Error Condition=" '$(DoAllResolvedFilesExist)' != 'true' AND '$(ResolveNuGetPackages)' != 'False' " Text="One Paket file '@(PaketResolvedFilePaths)' is missing while restoring $(MSBuildProjectFile). Please delete 'paket-files/paket.restore.cached' and call 'paket restore'." />

<!-- Step 4 forward all msbuild properties (PackageReference, DotNetCliToolReference) to msbuild -->
<ReadLinesFromFile Condition="Exists('$(PaketResolvedFilePath)')" File="$(PaketResolvedFilePath)" >
<ReadLinesFromFile Condition="($(DesignTimeBuild) != true OR '$(PaketPropsLoaded)' != 'true') AND '@(PaketResolvedFilePaths)' != ''" File="%(PaketResolvedFilePaths.Identity)" >
<Output TaskParameter="Lines" ItemName="PaketReferencesFileLines"/>
</ReadLinesFromFile>

<ItemGroup Condition=" Exists('$(PaketResolvedFilePath)') AND '@(PaketReferencesFileLines)' != '' " >
<ItemGroup Condition="($(DesignTimeBuild) != true OR '$(PaketPropsLoaded)' != 'true') AND '@(PaketReferencesFileLines)' != '' " >
<PaketReferencesFileLinesInfo Include="@(PaketReferencesFileLines)" >
<PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>
<PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion>
<AllPrivateAssets>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])</AllPrivateAssets>
</PaketReferencesFileLinesInfo>
<PackageReference Include="%(PaketReferencesFileLinesInfo.PackageName)">
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
<PrivateAssets Condition="%(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'true'">All</PrivateAssets>
<PrivateAssets Condition=" ('%(PaketReferencesFileLinesInfo.AllPrivateAssets)' == 'true') Or ('$(PackAsTool)' == 'true') ">All</PrivateAssets>
<ExcludeAssets Condition="%(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'exclude'">runtime</ExcludeAssets>
<Publish Condition=" '$(PackAsTool)' == 'true' ">true</Publish>
</PackageReference>
</ItemGroup>

Expand Down
Binary file modified .paket/paket.bootstrapper.exe
Binary file not shown.
72 changes: 72 additions & 0 deletions .paket/paket.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
<PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath>
<PaketRootPath>$(MSBuildThisFileDirectory)..\</PaketRootPath>
<PaketLockFilePath>$(PaketRootPath)paket.lock</PaketLockFilePath>
<PaketRestoreCacheFile>$(PaketRootPath)paket-files\paket.restore.cached</PaketRestoreCacheFile>
<MonoPath Condition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
<MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
</PropertyGroup>

<PropertyGroup>
<!-- Paket command -->
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe')">$(PaketRootPath)paket.exe</PaketExePath>
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
<PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand>
</PropertyGroup>

<Choose> <!-- MyProject.fsproj.paket.references has the highest precedence -->
<When Condition="Exists('$(MSBuildProjectFullPath).paket.references')">
<PropertyGroup>
<PaketReferences>$(MSBuildProjectFullPath).paket.references</PaketReferences>
</PropertyGroup>
</When> <!-- MyProject.paket.references -->
<When Condition="Exists('$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references')">
<PropertyGroup>
<PaketReferences>$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketReferences>
</PropertyGroup>
</When> <!-- paket.references -->
<When Condition="Exists('$(MSBuildProjectDirectory)\paket.references')">
<PropertyGroup>
<PaketReferences>$(MSBuildProjectDirectory)\paket.references</PaketReferences>
</PropertyGroup>
</When> <!-- Set to empty if a reference file isn't found matching one of the 3 format options -->
<Otherwise>
<PropertyGroup>
<PaketReferences></PaketReferences>
</PropertyGroup>
</Otherwise>
</Choose>

<PropertyGroup>
<!-- Commands -->
<RestoreCommand>$(PaketCommand) restore --references-file "$(PaketReferences)"</RestoreCommand>
<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">RestorePackages; $(BuildDependsOn);</BuildDependsOn>
</PropertyGroup>
<Target Name="RestorePackages">
<PropertyGroup>
<PaketRestoreRequired>true</PaketRestoreRequired>
</PropertyGroup>

<PropertyGroup Condition="Exists('$(PaketRestoreCacheFile)') ">
<PaketRestoreCachedHash>$([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))</PaketRestoreCachedHash>
<PaketRestoreLockFileHash>$([System.IO.File]::ReadAllText('$(PaketLockFilePath)'))</PaketRestoreLockFileHash>
<PaketRestoreRequired>true</PaketRestoreRequired>
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '$(PaketRestoreCachedHash)' ">false</PaketRestoreRequired>
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
</PropertyGroup>

<Exec Command="$(RestoreCommand)"
IgnoreStandardErrorWarningFormat="true"
WorkingDirectory="$(PaketRootPath)"
ContinueOnError="false"
Condition=" '$(PaketRestoreRequired)' == 'true' AND Exists('$(PaketReferences)') AND '$(PaketReferences)' != '' "
/>
</Target>
</Project>
18 changes: 11 additions & 7 deletions JsonLd.Entities.sln
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2037
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonLD.Entities", "src\JsonLD.Entities\JsonLD.Entities.csproj", "{CCB7B927-5AD6-4B98-ABA3-92EA18351B7D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonLD.Entities", "src\JsonLD.Entities\JsonLD.Entities.csproj", "{CCB7B927-5AD6-4B98-ABA3-92EA18351B7D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EAFC3ABA-17B5-4557-86A7-545A17506D30}"
ProjectSection(SolutionItems) = preProject
after.JsonLd.Entities.sln.targets = after.JsonLd.Entities.sln.targets
.gitignore = .gitignore
appveyor.yml = appveyor.yml
src\Common\Common.props = src\Common\Common.props
build.cake = build.cake
build.ps1 = build.ps1
GitVersionConfig.yaml = GitVersionConfig.yaml
paket.dependencies = paket.dependencies
paket.lock = paket.lock
Settings.StyleCop = Settings.StyleCop
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonLD.Entities.Tests", "src\JsonLD.Entities.Tests\JsonLD.Entities.Tests.csproj", "{AE56D865-7892-4A1B-B09D-D697E7F6F894}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonLD.Entities.Tests", "src\JsonLD.Entities.Tests\JsonLD.Entities.Tests.csproj", "{AE56D865-7892-4A1B-B09D-D697E7F6F894}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Documentation", "src\Documentation\Documentation.csproj", "{AF6A37F7-16E9-4DC9-B56C-1667BD88F2AC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Documentation", "src\Documentation\Documentation.csproj", "{AF6A37F7-16E9-4DC9-B56C-1667BD88F2AC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -42,4 +43,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A94662AA-C848-451B-808C-9519B2558FB5}
EndGlobalSection
EndGlobal
7 changes: 0 additions & 7 deletions after.JsonLd.Entities.sln.targets

This file was deleted.

24 changes: 3 additions & 21 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
install:
- choco install gitversion.portable -pre -y
- choco install codecov

before_build:
- .paket\paket.bootstrapper.exe
- .paket\paket.exe restore
- ps: gitversion /l console /output buildserver

build:
project: JsonLd.Entities.sln

configuration: Release

after_build:
- .paket\paket.exe pack output nugets include-referenced-projects version %GitVersion_NuGetVersion%

after_test:
- .\packages\OpenCover\tools\OpenCover.Console.exe -register:user -target:nunit3-console.exe -targetargs:"src\JsonLD.Entities.Tests\bin\Release\JsonLD.Entities.Tests.dll src\Documentation\bin\Release\JsonLD.Docu.dll" -returntargetcode -filter:"+[JsonLD.Entities]*" -hideskipped:All -output:.\JsonLD.Entities_coverage.xml
- codecov -f "JsonLD.Entities_coverage.xml"

build_script:
- ps: .\build.ps1 -Target CI -verbosity Verbose -configuration Release

artifacts:
- path: 'nugets\*.nupkg'

Expand Down
99 changes: 99 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#tool paket:?package=OpenCover
#tool paket:?package=codecov
#tool paket:?package=gitlink
#tool paket:?package=GitVersion.CommandLine&prerelease
#addin paket:?package=Cake.Paket
#addin paket:?package=Cake.Codecov

var target = Argument("target", "Build");
var configuration = Argument("Configuration", "Debug");

GitVersion version;

Task("CI")
.IsDependentOn("Pack")
.IsDependentOn("Codecov").Does(() => {});

Task("Pack")
.IsDependentOn("Build")
.Does(() => {
PaketPack("nugets", new PaketPackSettings {
Version = version.NuGetVersion
});
});

Task("GitVersion")
.Does(() => {
version = GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = true,
});
if (BuildSystem.IsLocalBuild == false)
{
GitVersion(new GitVersionSettings {
OutputType = GitVersionOutput.BuildServer
});
}
});

Task("Build")
.IsDependentOn("GitVersion")
.Does(() => {
DotNetCoreBuild("JsonLd.Entities.sln", new DotNetCoreBuildSettings {
Configuration = configuration
});
})
.DoesForEach(GetFiles("**/JsonLD.Entities.pdb"),
pdb => GitLink3(pdb, new GitLink3Settings {
RepositoryUrl = "https://github.com/wikibus/JsonLd.Entities",
}));

Task("Codecov")
.IsDependentOn("Test")
.Does(() => {
Codecov("opencover.xml");
});

Task("Test")
.IsDependentOn("Build")
.Does(() => {
var openCoverSettings = new OpenCoverSettings
{
OldStyle = true,
MergeOutput = true,
MergeByHash = true,
Register = "user",
ReturnTargetCodeOffset = 0
}
.WithFilter("+[JsonLD.Entities]*");
bool success = true;
foreach(var projectFile in new [] { "documentation.csproj", "jsonld.entities.tests.csproj" }.SelectMany(f => GetFiles($"**\\{f}")))
{
try
{
openCoverSettings.WorkingDirectory = projectFile.GetDirectory();
OpenCover(context => {
context.DotNetCoreTool(
projectPath: projectFile.FullPath,
command: "xunit",
arguments: $"-noshadow");
},
"opencover.xml",
openCoverSettings);
}
catch(Exception ex)
{
success = false;
Error("There was an error while running the tests", ex);
}
}
if(success == false)
{
throw new CakeException("There was an error while running the tests");
}
});

RunTarget(target);
Loading

0 comments on commit 21be4e0

Please sign in to comment.