@@ -14,91 +14,87 @@ Task("Clean")
1414 CleanDirectory ( artifacts ) ;
1515} ) ;
1616
17- Task ( "Restore" )
17+ Task ( "Restore (Unix)" )
18+ . WithCriteria ( IsRunningOnUnix )
1819 . Does ( ( ) =>
1920{
20- DotNetCoreRestore ( ) ;
21+ MSBuild ( "./LSP.sln" , settings => settings . SetConfiguration ( configuration ) . WithTarget ( "Restore" ) ) ;
2122} ) ;
2223
23- Task ( "Build " )
24- . IsDependentOn ( "Restore" )
24+ Task ( "Restore (Windows) " )
25+ . WithCriteria ( IsRunningOnWindows )
2526 . Does ( ( ) =>
2627{
27- foreach ( var project in GetFiles ( "src/*/*.csproj" ) . Concat ( GetFiles ( "test/*/*.csproj" ) ) )
28- DotNetCoreBuild ( project . FullPath , new DotNetCoreBuildSettings
29- {
30- Configuration = configuration ,
31- EnvironmentVariables = GitVersionEnvironmentVariables ,
32- } ) ;
28+ DotNetCoreRestore ( ) ;
3329} ) ;
3430
35- Task ( "Test" )
31+ Task ( "Restore" )
32+ . IsDependentOn ( "Restore (Unix)" )
33+ . IsDependentOn ( "Restore (Windows)" ) ;
34+
35+ Task ( "Build" )
36+ . IsDependentOn ( "Restore" )
37+ . DoesForEach ( GetFiles ( "src/**/*.csproj" ) . Concat ( GetFiles ( "test/**/*.csproj" ) ) , ( project ) =>
38+ {
39+ MSBuild ( project , settings =>
40+ settings
41+ . SetConfiguration ( configuration )
42+ . WithTarget ( "Build" ) ) ;
43+ } ) ;
44+
45+ Task ( "TestSetup" )
46+ . Does ( ( ) => {
47+ CleanDirectory ( artifacts + "/tests" ) ;
48+ CleanDirectory ( artifacts + "/coverage" ) ;
49+ EnsureDirectoryExists ( artifacts + "/tests" ) ;
50+ EnsureDirectoryExists ( artifacts + "/coverage" ) ;
51+ } ) ;
52+
53+ Task ( "Test (No Coverage)" )
54+ . WithCriteria ( IsRunningOnUnix )
55+ . WithCriteria ( false ) // TODO: Make work on travis
56+ . IsDependentOn ( "TestSetup" )
3657 . IsDependentOn ( "Build" )
37- . Does ( ( ) =>
58+ . DoesForEach ( GetFiles ( "test/*/*.csproj" ) , ( testProject ) =>
3859{
39- EnsureDirectoryExists ( artifacts + "/tests" ) ;
40- EnsureDirectoryExists ( artifacts + "/coverage" ) ;
41-
42- foreach ( var testProject in GetFiles ( "test/*/*.csproj" ) ) {
43- StartProcess ( "dotnet" , new ProcessSettings ( ) {
44- WorkingDirectory = testProject . GetDirectory ( ) ,
60+ DotNetCoreTest (
61+ testProject . GetDirectory ( ) . FullPath ,
62+ new DotNetCoreTestSettings ( ) {
63+ NoBuild = true ,
64+ Framework = "netcoreapp2.0" ,
4565 EnvironmentVariables = GitVersionEnvironmentVariables ,
46- Arguments = new ProcessArgumentBuilder ( )
47- . Append ( "xunit" )
48- . Append ( "-noshadow" )
49- . AppendSwitch ( "-configuration" , configuration )
50- . AppendSwitchQuotedSecret ( "-xml" , string . Format ( "{0}/tests/{1}.xml" , artifacts , testProject . GetFilenameWithoutExtension ( ) ) )
51- . AppendSwitchQuotedSecret ( "-html" , string . Format ( "{0}/tests/{1}.html" , artifacts , testProject . GetFilenameWithoutExtension ( ) ) )
52- } ) ;
53- }
66+ } ) ;
5467} ) ;
5568
56- Task ( "Coverage" )
57- //.IsDependentOn("Build")
58- . Does ( ( ) =>
69+ Task ( "Test (Coverage)" )
70+ . WithCriteria ( IsRunningOnWindows )
71+ . IsDependentOn ( "TestSetup" )
72+ . IsDependentOn ( "Build" )
73+ . DoesForEach ( GetFiles ( "test/*/*.csproj" ) , ( testProject ) =>
5974{
60- CleanDirectory ( artifacts + "/coverage" ) ;
61- EnsureDirectoryExists ( artifacts + "/coverage" ) ;
62-
63- foreach ( var testProject in GetFiles ( "test/*/*.csproj" ) ) {
64- DotCoverCover ( tool => {
65- // tool.XUnit2()
66- // tool.StartProcess(Context.Tools.Resolve("dotnet.exe"), new ProcessSettings() {
67- // WorkingDirectory = testProject.GetDirectory(),
68- // Arguments = new ProcessArgumentBuilder()
69- // .Append("test")
70- // .AppendSwitch("-c", configuration)
71- // .Append("--no-build")
72- // .Append("-f net46")
73- // });
74- tool . StartProcess ( Context . Tools . Resolve ( "dotnet.exe" ) , new ProcessSettings ( ) {
75- WorkingDirectory = testProject . GetDirectory ( ) ,
76- EnvironmentVariables = GitVersionEnvironmentVariables ,
77- Arguments = new ProcessArgumentBuilder ( )
78- . Append ( "xunit" )
79- . Append ( "-noshadow" )
80- . Append ( "-noautoreporters" )
81- // .AppendSwitch("-maxthreads", "1")
82- . AppendSwitch ( "-configuration" , configuration )
83- . AppendSwitch ( "-framework" , "net46" )
84- . AppendSwitchQuotedSecret ( "-xml" , string . Format ( "{0}/tests/{1}.xml" , artifacts , testProject . GetFilenameWithoutExtension ( ) ) )
85- . AppendSwitchQuotedSecret ( "-html" , string . Format ( "{0}/tests/{1}.html" , artifacts , testProject . GetFilenameWithoutExtension ( ) ) )
86- } ) ;
87- } ,
88- artifacts + "/coverage/coverage-" + testProject . GetFilenameWithoutExtension ( ) + ".dcvr" ,
89- new DotCoverCoverSettings ( ) {
90- // Register = "user",
91- // MergeOutput = true,
92- // OldStyle = true,
93- TargetWorkingDir = testProject . GetDirectory ( ) ,
94- WorkingDirectory = testProject . GetDirectory ( ) ,
95- // ReportType = DotCoverReportType.XML
96- }
97- . WithFilter ( "+:JsonRpc" )
98- . WithFilter ( "+:Lsp" )
99- ) ;
100- }
101-
75+ DotCoverCover ( tool => {
76+ tool . DotNetCoreTool (
77+ testProject . GetDirectory ( ) . FullPath ,
78+ "xunit" ,
79+ new ProcessArgumentBuilder ( )
80+ . AppendSwitchQuoted ( "-xml" , string . Format ( "{0}/tests/{1}.xml" , artifacts , testProject . GetFilenameWithoutExtension ( ) ) )
81+ . AppendSwitch ( "-configuration" , configuration )
82+ . Append ( "-noshadow" ) ,
83+ new DotNetCoreToolSettings ( ) {
84+ EnvironmentVariables = GitVersionEnvironmentVariables ,
85+ } ) ;
86+ } ,
87+ artifacts + "/coverage/coverage-" + testProject . GetFilenameWithoutExtension ( ) + ".dcvr" ,
88+ new DotCoverCoverSettings ( ) {
89+ TargetWorkingDir = testProject . GetDirectory ( ) ,
90+ WorkingDirectory = testProject . GetDirectory ( ) ,
91+ EnvironmentVariables = GitVersionEnvironmentVariables ,
92+ }
93+ . WithFilter ( "+:JsonRpc" )
94+ . WithFilter ( "+:Lsp" )
95+ ) ;
96+ } )
97+ . Finally ( ( ) => {
10298 DotCoverMerge (
10399 GetFiles ( artifacts + "/coverage/*.dcvr" ) ,
104100 artifacts + "/coverage/coverage.dcvr"
@@ -124,18 +120,22 @@ Task("Coverage")
124120 System . IO . File . WriteAllText ( artifacts + "/coverage/coverage.xml" , withBom . Replace ( _byteOrderMarkUtf8 , "" ) ) ;
125121} ) ;
126122
123+ Task ( "Test" )
124+ . IsDependentOn ( "Test (Coverage)" )
125+ . IsDependentOn ( "Test (No Coverage)" ) ;
126+
127127Task ( "Pack" )
128+ . WithCriteria ( IsRunningOnWindows ) // TODO: Make work on travis
128129 . IsDependentOn ( "Build" )
129- . Does ( ( ) => {
130- EnsureDirectoryExists ( artifacts + "/nuget" ) ;
131- foreach ( var project in GetFiles ( "src/*/*.csproj" ) )
132- DotNetCorePack ( project . FullPath , new DotNetCorePackSettings
133- {
134- NoBuild = true ,
135- Configuration = configuration ,
136- EnvironmentVariables = GitVersionEnvironmentVariables ,
137- OutputDirectory = artifacts + "/nuget"
138- } ) ;
130+ . Does ( ( ) => EnsureDirectoryExists ( artifacts + "/nuget" ) )
131+ . DoesForEach ( GetFiles ( "src/*/*.csproj" ) , ( project ) => {
132+ DotNetCorePack ( project . FullPath , new DotNetCorePackSettings
133+ {
134+ NoBuild = true ,
135+ Configuration = configuration ,
136+ EnvironmentVariables = GitVersionEnvironmentVariables ,
137+ OutputDirectory = artifacts + "/nuget"
138+ } ) ;
139139 } ) ;
140140
141141Task ( "GitVersion" )
@@ -150,7 +150,6 @@ Task("Default")
150150 . IsDependentOn ( "Clean" )
151151 . IsDependentOn ( "Build" )
152152 . IsDependentOn ( "Test" )
153- . IsDependentOn ( "Coverage" )
154153 . IsDependentOn ( "Pack" ) ;
155154
156155RunTarget ( target ) ;
0 commit comments