11#tool "nuget:?package=GitVersion.CommandLine"
22#tool "nuget:?package=xunit.runner.console"
3- #tool "nuget:?package=OpenCover "
4- #tool "nuget:?package=coveralls.net "
3+ #tool "nuget:?package=JetBrains.dotCover.CommandLineTools "
4+ #tool "nuget:?package=coveralls.io.dotcover "
55#addin "Cake.Coveralls" ;
66
77var target = Argument ( "target" , "Default" ) ;
@@ -26,7 +26,10 @@ Task("Build")
2626 . Does ( ( ) =>
2727{
2828 foreach ( var project in GetFiles ( "src/*/*.csproj" ) . Concat ( GetFiles ( "test/*/*.csproj" ) ) )
29- DotNetCoreBuild ( project . FullPath ) ;
29+ DotNetCoreBuild ( project . FullPath , new DotNetCoreBuildSettings
30+ {
31+ Configuration = configuration
32+ } ) ;
3033} ) ;
3134
3235Task ( "Test" )
@@ -42,41 +45,76 @@ Task("Test")
4245 Arguments = new ProcessArgumentBuilder ( )
4346 . Append ( "xunit" )
4447 . Append ( "-noshadow" )
48+ . AppendSwitch ( "-configuration" , configuration )
4549 . AppendSwitchQuotedSecret ( "-xml" , string . Format ( "{0}/tests/{1}.xml" , artifacts , testProject . GetFilenameWithoutExtension ( ) ) )
4650 . AppendSwitchQuotedSecret ( "-html" , string . Format ( "{0}/tests/{1}.html" , artifacts , testProject . GetFilenameWithoutExtension ( ) ) )
4751 } ) ;
4852 }
4953} ) ;
5054
5155Task ( "Coverage" )
52- . IsDependentOn ( "Build" )
56+ // .IsDependentOn("Build")
5357 . Does ( ( ) =>
5458{
59+ CleanDirectory ( artifacts + "/coverage" ) ;
5560 EnsureDirectoryExists ( artifacts + "/coverage" ) ;
5661
5762 foreach ( var testProject in GetFiles ( "test/*/*.csproj" ) ) {
58- OpenCover ( tool => {
63+ DotCoverCover ( tool => {
64+ // tool.XUnit2()
65+ // tool.StartProcess(Context.Tools.Resolve("dotnet.exe"), new ProcessSettings() {
66+ // WorkingDirectory = testProject.GetDirectory(),
67+ // Arguments = new ProcessArgumentBuilder()
68+ // .Append("test")
69+ // .AppendSwitch("-c", configuration)
70+ // .Append("--no-build")
71+ // .Append("-f net46")
72+ // });
5973 tool . StartProcess ( Context . Tools . Resolve ( "dotnet.exe" ) , new ProcessSettings ( ) {
6074 WorkingDirectory = testProject . GetDirectory ( ) ,
6175 Arguments = new ProcessArgumentBuilder ( )
62- . Append ( "test" )
63- . Append ( "--no-build" )
64- . Append ( "-f net46" )
65-
76+ . Append ( "xunit" )
77+ . Append ( "-noshadow" )
78+ . AppendSwitch ( "-configuration" , configuration )
79+ . AppendSwitch ( "-framework" , "net46" )
80+ . AppendSwitchQuotedSecret ( "-xml" , string . Format ( "{0}/tests/{1}.xml" , artifacts , testProject . GetFilenameWithoutExtension ( ) ) )
81+ . AppendSwitchQuotedSecret ( "-html" , string . Format ( "{0}/tests/{1}.html" , artifacts , testProject . GetFilenameWithoutExtension ( ) ) )
6682 } ) ;
6783 } ,
68- artifacts + "/coverage/coverage.opencover" ,
69- new OpenCoverSettings ( ) {
70- Register = "user" ,
71- MergeOutput = true ,
72- OldStyle = true ,
84+ artifacts + "/coverage/coverage-" + testProject . GetFilenameWithoutExtension ( ) + ".dcvr" ,
85+ new DotCoverCoverSettings ( ) {
86+ // Register = "user",
87+ // MergeOutput = true,
88+ // OldStyle = true,
89+ TargetWorkingDir = testProject . GetDirectory ( ) ,
7390 WorkingDirectory = testProject . GetDirectory ( ) ,
91+ // ReportType = DotCoverReportType.XML
7492 }
75- . WithFilter ( "+[JsonRpc*]*" )
76- . WithFilter ( "+[Lsp*]*" )
77- . WithFilter ( "-[*.Tests]*" )
93+ . WithFilter ( "+:JsonRpc" )
94+ . WithFilter ( "+:Lsp" )
7895 ) ;
7996 }
97+
98+ DotCoverMerge (
99+ GetFiles ( artifacts + "/coverage/*.dcvr" ) ,
100+ artifacts + "/coverage/coverage.dcvr"
101+ ) ;
102+
103+ DotCoverReport (
104+ artifacts + "/coverage/coverage.dcvr" ,
105+ new FilePath ( artifacts + "/coverage/coverage.html" ) ,
106+ new DotCoverReportSettings {
107+ ReportType = DotCoverReportType . HTML
108+ }
109+ ) ;
110+
111+ DotCoverReport (
112+ artifacts + "/coverage/coverage.dcvr" ,
113+ new FilePath ( artifacts + "/coverage/coverage.xml" ) ,
114+ new DotCoverReportSettings {
115+ ReportType = DotCoverReportType . DetailedXML
116+ }
117+ ) ;
80118} ) ;
81119
82120Task ( "Coveralls [AppVeyor]" )
0 commit comments