11// Install tools.
22#tool dotnet : ? package= GitVersion . Tool & version = 5.6 .6
3- #tool nuget: ? package = GitReleaseManager & version = 0.11 .0
3+ #tool nuget: ? package = GitReleaseManager & version = 0.12 .1
44#tool nuget: ? package = OpenCover & version = 4.7 .1221
55#tool nuget: ? package = ReportGenerator & version = 4.8 .12
66#tool nuget: ? package = coveralls . io & version = 1.4 .2
77#tool nuget: ? package = xunit . runner . console & version = 2.4 .1
88
99// Install addins.
1010#addin nuget: ? package = Cake . Coveralls & version = 1.1 .0
11- #addin nuget: ? package = Cake . Git & version = 1.0 .1
11+ #addin nuget: ? package = Cake . Git & version = 1.1 .0
1212
1313
1414///////////////////////////////////////////////////////////////////////////////
@@ -67,14 +67,22 @@ var isTagged = (
6767) ;
6868var isBenchmarkPresent = FileExists( benchmarkProject ) ;
6969
70+ // Generally speaking, we want to honor all the TFM configured in the source project and the unit test project.
71+ // However, there are a few scenarios where a single framework is sufficient. Here are a few examples that come to mind:
72+ // - when building source project on Ubuntu
73+ // - when running unit tests on Ubuntu
74+ // - when calculating code coverage
75+ // FYI, this will cause an error if the source project and/or the unit test project are not configured to target this desired framework:
76+ var desiredFramework = IsRunningOnWindows( ) ? null : "net5.0 ";
77+
7078
7179///////////////////////////////////////////////////////////////////////////////
7280// SETUP / TEARDOWN
7381///////////////////////////////////////////////////////////////////////////////
7482
7583Setup ( context =>
7684{
77- if ( isMainBranch && ( context . Log . Verbosity != Verbosity . Diagnostic ) )
85+ if ( ! isLocalBuild && context . Log . Verbosity != Verbosity . Diagnostic )
7886 {
7987 Information ( "Increasing verbosity to diagnostic." ) ;
8088 context . Log . Verbosity = Verbosity . Diagnostic ;
@@ -200,9 +208,14 @@ Task("Build")
200208 DotNetCoreBuild ( solutionFile , new DotNetCoreBuildSettings
201209 {
202210 Configuration = configuration ,
211+ Framework = desiredFramework ,
203212 NoRestore = true ,
204- ArgumentCustomization = args => args . Append ( "/p:SemVer=" + versionInfo . LegacySemVerPadded ) ,
205- Framework = IsRunningOnWindows ( ) ? null : "net5.0"
213+ ArgumentCustomization = args =>
214+ {
215+ return args
216+ . Append ( "/p:SemVer={0}" , versionInfo . LegacySemVerPadded )
217+ . Append ( "/p:ContinuousIntegrationBuild={0}" , BuildSystem . IsLocalBuild ? "false" : "true" ) ;
218+ }
206219 } ) ;
207220} ) ;
208221
@@ -215,19 +228,14 @@ Task("Run-Unit-Tests")
215228 NoBuild = true ,
216229 NoRestore = true ,
217230 Configuration = configuration ,
218- Framework = IsRunningOnWindows ( ) ? null : "net5.0"
231+ Framework = desiredFramework
219232 } ) ;
220233} ) ;
221234
222235Task( "Run-Code-Coverage" )
223236 . IsDependentOn ( "Build" )
224237 . Does ( ( ) =>
225238{
226- // For the purpose of calculating code coverage, a single target will suffice.
227- // FYI, this will cause an error if the unit test project is not configured
228- // to target this desired framework:
229- var desiredFramework = "net5.0" ;
230-
231239 Action < ICakeContext > testAction = ctx => ctx . DotNetCoreTest ( unitTestsProject , new DotNetCoreTestSettings
232240 {
233241 NoBuild = true ,
@@ -254,7 +262,14 @@ Task("Upload-Coverage-Result")
254262 . IsDependentOn ( "Run-Code-Coverage" )
255263 . Does ( ( ) =>
256264{
257- CoverallsIo ( $ "{ codeCoverageDir } coverage.xml") ;
265+ try
266+ {
267+ CoverallsIo ( $ "{ codeCoverageDir } coverage.xml") ;
268+ }
269+ catch ( Exception e )
270+ {
271+ Warning ( e . Message ) ;
272+ }
258273} ) ;
259274
260275Task( "Generate-Code-Coverage-Report" )
@@ -285,10 +300,10 @@ Task("Create-NuGet-Package")
285300 NoRestore = true ,
286301 NoDependencies = true ,
287302 OutputDirectory = outputDir ,
303+ SymbolPackageFormat = "snupkg" ,
288304 ArgumentCustomization = ( args ) =>
289305 {
290306 return args
291- . Append ( "/p:SymbolPackageFormat=snupkg" )
292307 . Append ( "/p:PackageReleaseNotes=\" {0}\" " , releaseNotesUrl )
293308 . Append ( "/p:Version={0}" , versionInfo . LegacySemVerPadded )
294309 . Append ( "/p:AssemblyVersion={0}" , versionInfo . MajorMinorPatch )
@@ -304,11 +319,11 @@ Task("Upload-AppVeyor-Artifacts")
304319 . WithCriteria ( ( ) => AppVeyor . IsRunningOnAppVeyor )
305320 . Does ( ( ) =>
306321{
307- foreach ( var file in GetFiles ( $ "{ outputDir } *.*") )
308- {
309- AppVeyor . UploadArtifact ( file . FullPath ) ;
310- }
311- foreach ( var file in GetFiles ( $ " { benchmarkDir } results/*.*" ) )
322+ var allFiles = GetFiles ( $ "{ outputDir } *.*") +
323+ GetFiles ( $ " { benchmarkDir } results/*.*" ) +
324+ GetFiles ( $ " { codeCoverageDir } *.*" ) ;
325+
326+ foreach ( var file in allFiles )
312327 {
313328 AppVeyor . UploadArtifact ( file . FullPath ) ;
314329 }
@@ -453,7 +468,6 @@ Task("ReleaseNotes")
453468Task( "AppVeyor" )
454469 . IsDependentOn ( "Run-Code-Coverage" )
455470 . IsDependentOn ( "Upload-Coverage-Result" )
456- . IsDependentOn ( "Generate-Benchmark-Report" )
457471 . IsDependentOn ( "Create-NuGet-Package" )
458472 . IsDependentOn ( "Upload-AppVeyor-Artifacts" )
459473 . IsDependentOn ( "Publish-MyGet" )
0 commit comments