1
1
using System . IO ;
2
2
using System . Linq ;
3
3
using System . Text ;
4
+ using System . Xml ;
5
+ using System . Xml . Xsl ;
4
6
using Cake . Common ;
5
7
using Cake . Common . Build ;
6
8
using Cake . Common . Build . AppVeyor ;
@@ -41,6 +43,7 @@ public class BuildContext : FrostingContext
41
43
public DirectoryPath DocfxDirectory { get ; }
42
44
public FilePath DocfxExeFile { get ; }
43
45
public FilePath DocfxJsonFile { get ; }
46
+ public DirectoryPath TestOutputDirectory { get ; }
44
47
45
48
public DirectoryPath ChangeLogDirectory { get ; }
46
49
public DirectoryPath ChangeLogGenDirectory { get ; }
@@ -72,6 +75,7 @@ public BuildContext(ICakeContext context)
72
75
DocfxDirectory = ToolsDirectory . Combine ( "docfx" ) ;
73
76
DocfxExeFile = DocfxDirectory . CombineWithFilePath ( "docfx.exe" ) ;
74
77
DocfxJsonFile = DocsDirectory . CombineWithFilePath ( "docfx.json" ) ;
78
+ TestOutputDirectory = RootDirectory . Combine ( "TestResults" ) ;
75
79
76
80
ChangeLogDirectory = RootDirectory . Combine ( "docs" ) . Combine ( "changelog" ) ;
77
81
ChangeLogGenDirectory = RootDirectory . Combine ( "docs" ) . Combine ( "_changelog" ) ;
@@ -93,21 +97,29 @@ public BuildContext(ICakeContext context)
93
97
MsBuildSettings . WithProperty ( "UseSharedCompilation" , "false" ) ;
94
98
}
95
99
96
- public DotNetCoreTestSettings GetTestSettingsParameters ( string tfm )
100
+ private DotNetCoreTestSettings GetTestSettingsParameters ( FilePath logFile , string tfm )
97
101
{
98
102
return new DotNetCoreTestSettings
99
103
{
100
104
Configuration = BuildConfiguration ,
101
105
Framework = tfm ,
102
106
NoBuild = true ,
103
107
NoRestore = true ,
104
- Loggers = new [ ] { "trx" }
108
+ Loggers = new [ ] { "trx" , $ "trx;LogFileName= { logFile . FullPath } " }
105
109
} ;
106
110
}
107
111
112
+ public void RunTests ( FilePath projectFile , string alias , string tfm )
113
+ {
114
+ var xUnitXmlFile = TestOutputDirectory . CombineWithFilePath ( alias + "-" + tfm + ".trx" ) ;
115
+ this . Information ( $ "Run tests for { projectFile } ({ tfm } ), result file: '{ xUnitXmlFile } '") ;
116
+ var settings = GetTestSettingsParameters ( xUnitXmlFile , tfm ) ;
117
+ this . DotNetTest ( projectFile . FullPath , settings ) ;
118
+ }
119
+
108
120
public void DocfxChangelogDownload ( string version , string versionPrevious , string lastCommit = "" )
109
121
{
110
- this . Verbose ( "DocfxChangelogDownload: " + version ) ;
122
+ this . Information ( "DocfxChangelogDownload: " + version ) ;
111
123
// Required environment variables: GITHIB_PRODUCT, GITHUB_TOKEN
112
124
var changeLogBuilderDirectory = ChangeLogGenDirectory . Combine ( "ChangeLogBuilder" ) ;
113
125
var changeLogBuilderProjectFile = changeLogBuilderDirectory . CombineWithFilePath ( "ChangeLogBuilder.csproj" ) ;
@@ -121,12 +133,12 @@ public void DocfxChangelogDownload(string version, string versionPrevious, strin
121
133
var src = changeLogBuilderDirectory . CombineWithFilePath ( version + ".md" ) ;
122
134
var dest = ChangeLogGenDirectory . Combine ( "details" ) . CombineWithFilePath ( version + ".md" ) ;
123
135
this . CopyFile ( src , dest ) ;
124
- this . Verbose ( $ "Changelog for { version } : { dest } ") ;
136
+ this . Information ( $ "Changelog for { version } : { dest } ") ;
125
137
}
126
138
127
139
public void DocfxChangelogGenerate ( string version )
128
140
{
129
- this . Verbose ( "DocfxChangelogGenerate: " + version ) ;
141
+ this . Information ( "DocfxChangelogGenerate: " + version ) ;
130
142
var header = ChangeLogGenDirectory . Combine ( "header" ) . CombineWithFilePath ( version + ".md" ) ;
131
143
var footer = ChangeLogGenDirectory . Combine ( "footer" ) . CombineWithFilePath ( version + ".md" ) ;
132
144
var details = ChangeLogGenDirectory . Combine ( "details" ) . CombineWithFilePath ( version + ".md" ) ;
@@ -281,15 +293,12 @@ public override bool ShouldRun(BuildContext context)
281
293
282
294
public override void Run ( BuildContext context )
283
295
{
284
- var targetVersions = context . IsRunningOnWindows ( )
296
+ var targetFrameworks = context . IsRunningOnWindows ( )
285
297
? new [ ] { "net461" , "net5.0" }
286
298
: new [ ] { "net5.0" } ;
287
299
288
- foreach ( var version in targetVersions )
289
- {
290
- var dotNetTestSettings = context . GetTestSettingsParameters ( version ) ;
291
- context . DotNetTest ( context . UnitTestsProjectFile . FullPath , dotNetTestSettings ) ;
292
- }
300
+ foreach ( var targetFramework in targetFrameworks )
301
+ context . RunTests ( context . UnitTestsProjectFile , "UnitTests" , targetFramework ) ;
293
302
}
294
303
}
295
304
@@ -304,7 +313,7 @@ public override bool ShouldRun(BuildContext context)
304
313
305
314
public override void Run ( BuildContext context )
306
315
{
307
- context . DotNetTest ( context . IntegrationTestsProjectFile . FullPath , context . GetTestSettingsParameters ( " net461") ) ;
316
+ context . RunTests ( context . IntegrationTestsProjectFile , "IntegrationTests" , " net461") ;
308
317
}
309
318
}
310
319
@@ -319,7 +328,7 @@ public override bool ShouldRun(BuildContext context)
319
328
320
329
public override void Run ( BuildContext context )
321
330
{
322
- context . DotNetTest ( context . IntegrationTestsProjectFile . FullPath , context . GetTestSettingsParameters ( " net5.0") ) ;
331
+ context . RunTests ( context . IntegrationTestsProjectFile , "IntegrationTests" , " net5.0") ;
323
332
}
324
333
}
325
334
@@ -355,41 +364,9 @@ public override void Run(BuildContext context)
355
364
}
356
365
}
357
366
358
- [ TaskName ( "CiPack" ) ]
359
- [ IsDependentOn ( typeof ( PackTask ) ) ]
360
- public class CiPackTask : FrostingTask < BuildContext >
361
- {
362
- public override bool ShouldRun ( BuildContext context )
363
- {
364
- return context . IsCiBuild && context . IsOnAppVeyorAndNotPr && context . IsRunningOnWindows ( ) ;
365
- }
366
- }
367
-
368
- [ TaskName ( "Ci" ) ]
369
- [ IsDependentOn ( typeof ( AllTestsTask ) ) ]
370
- [ IsDependentOn ( typeof ( CiPackTask ) ) ]
371
- public class CiTask : FrostingTask < BuildContext >
372
- {
373
- public override bool ShouldRun ( BuildContext context )
374
- {
375
- return context . IsCiBuild ;
376
- }
377
- }
378
-
379
- [ TaskName ( "Local" ) ]
367
+ [ TaskName ( "Default" ) ]
380
368
[ IsDependentOn ( typeof ( AllTestsTask ) ) ]
381
369
[ IsDependentOn ( typeof ( PackTask ) ) ]
382
- public class LocalTask : FrostingTask < BuildContext >
383
- {
384
- public override bool ShouldRun ( BuildContext context )
385
- {
386
- return context . IsLocalBuild ;
387
- }
388
- }
389
-
390
- [ TaskName ( "Default" ) ]
391
- [ IsDependentOn ( typeof ( LocalTask ) ) ]
392
- [ IsDependentOn ( typeof ( CiTask ) ) ]
393
370
public class DefaultTask : FrostingTask
394
371
{
395
372
}
0 commit comments