11#tool "nuget:?package=xunit.runner.console&version=2.2.0"
2+ #tool nuget : ? package= Codecov
3+ #addin nuget: ? package= Cake . Codecov
4+ #addin nuget: ? package = Cake . Coverlet
25///////////////////////////////////////////////////////////////////////////////
36// ARGUMENTS
47///////////////////////////////////////////////////////////////////////////////
@@ -17,6 +20,7 @@ var nuspecFile = $"./{project}/{project}.nuspec";
1720var tests = $"./{project}.Tests/{project}.Tests.csproj" ;
1821var publishPath = MakeAbsolute( Directory( "./output" ) ) ;
1922var nugetPackageDir = MakeAbsolute( Directory( "./nuget" ) ) ;
23+ var codeCoverageOutput = MakeAbsolute( Directory( "./code-coverage/" ) ) ;
2024
2125///////////////////////////////////////////////////////////////////////////////
2226// TASKS
@@ -49,12 +53,29 @@ Task("Test")
4953 . IsDependentOn ( "Build" )
5054 . Does ( ( ) => {
5155
56+ var coverletSettings = new CoverletSettings {
57+ CollectCoverage = true ,
58+ CoverletOutputDirectory = codeCoverageOutput ,
59+ CoverletOutputFormat = CoverletOutputFormat . opencover ,
60+ CoverletOutputName = $ "coverage.xml"
61+ } ;
62+
5263 DotNetCoreTest ( tests ,
53- new DotNetCoreTestSettings {
54- NoBuild = true ,
55- NoRestore = true ,
56- Configuration = configuration
57- } ) ;
64+ new DotNetCoreTestSettings {
65+ NoBuild = true ,
66+ NoRestore = true ,
67+ Configuration = configuration
68+ } , coverletSettings ) ;
69+
70+ Information ( "Print all files: " ) ;
71+ foreach ( var file in GetFiles ( $ ".\\ **\\ **\\ **\\ *.*") )
72+ {
73+ Information ( file . FullPath ) ;
74+ }
75+
76+
77+ // Upload a coverage report.
78+ Codecov ( $ "{ codeCoverageOutput } \\ coverage.xml") ;
5879} ) ;
5980
6081Task( "Publish" )
@@ -78,7 +99,7 @@ Task("Publish-NuGet")
7899 {
79100 BasePath = publishPath ,
80101 OutputDirectory = nugetPackageDir ,
81- IncludeReferencedProjects = true ,
102+ IncludeReferencedProjects = false ,
82103
83104 Properties = new Dictionary < string , string >
84105 {
0 commit comments