11// Install tools.
2- #tool dotnet : ? package= GitVersion . Tool & version = 5.6 .6
3- #tool nuget: ? package = GitReleaseManager & version = 0.12 .1
2+ #tool dotnet : ? package= GitVersion . Tool & version = 5.8 .2
3+ #tool nuget: ? package = GitReleaseManager & version = 0.13 .0
44#tool nuget: ? package = OpenCover & version = 4.7 .1221
5- #tool nuget: ? package = ReportGenerator & version = 4.8 .12
5+ #tool nuget: ? package = ReportGenerator & version = 5.0 .4
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.1 .0
11+ #addin nuget: ? package = Cake . Git & version = 2.0 .0
1212
1313
1414///////////////////////////////////////////////////////////////////////////////
@@ -61,11 +61,10 @@ var isLocalBuild = BuildSystem.IsLocalBuild;
6161var isMainBranch = StringComparer . OrdinalIgnoreCase . Equals( "main" , BuildSystem . AppVeyor . Environment . Repository . Branch ) ;
6262var isMainRepo = StringComparer. OrdinalIgnoreCase. Equals( $"{gitHubRepoOwner}/{gitHubRepo}" , BuildSystem . AppVeyor . Environment . Repository . Name ) ;
6363var isPullRequest = BuildSystem. AppVeyor. Environment. PullRequest. IsPullRequest;
64- var isTagged = (
65- BuildSystem . AppVeyor . Environment . Repository . Tag . IsTag &&
66- ! string . IsNullOrWhiteSpace ( BuildSystem . AppVeyor . Environment . Repository . Tag . Name )
67- ) ;
68- var isBenchmarkPresent = FileExists( benchmarkProject ) ;
64+ var isTagged = BuildSystem . AppVeyor . Environment . Repository . Tag . IsTag && ! string . IsNullOrWhiteSpace ( BuildSystem . AppVeyor . Environment . Repository . Tag . Name ) ;
65+ var isIntegrationTestsProjectPresent = FileExists( integrationTestsProject ) ;
66+ var isUnitTestsProjectPresent = FileExists ( unitTestsProject ) ;
67+ var isBenchmarkProjectPresent = FileExists ( benchmarkProject ) ;
6968
7069// Generally speaking, we want to honor all the TFM configured in the source project and the unit test project.
7170// However, there are a few scenarios where a single framework is sufficient. Here are a few examples that come to mind:
@@ -134,19 +133,29 @@ Setup(context =>
134133 // Integration tests are intended to be used for debugging purposes and not intended to be executed in CI environment.
135134 // Also, the runner for these tests contains windows-specific code (such as resizing window, moving window to center of screen, etc.)
136135 // which can cause problems when attempting to run unit tests on an Ubuntu image on AppVeyor.
137- if ( ! isLocalBuild )
136+ if ( ! isLocalBuild && isIntegrationTestsProjectPresent )
138137 {
139138 Information ( "" ) ;
140139 Information ( "Removing integration tests" ) ;
141- DotNetCoreTool ( solutionFile , "sln" , $ "remove { integrationTestsProject . TrimStart ( sourceFolder , StringComparison . OrdinalIgnoreCase ) } ") ;
140+ DotNetTool ( solutionFile , "sln" , $ "remove { integrationTestsProject . TrimStart ( sourceFolder , StringComparison . OrdinalIgnoreCase ) } ") ;
141+ }
142+
143+ // Similarly, benchmarking can causes problems similar to this one:
144+ // error NETSDK1005: Assets file '/home/appveyor/projects/stronggrid/Source/StrongGrid.Benchmark/obj/project.assets.json' doesn't have a target for 'net5.0'.
145+ // Ensure that restore has run and that you have included 'net5.0' in the TargetFrameworks for your project.
146+ if ( ! isLocalBuild && isBenchmarkProjectPresent )
147+ {
148+ Information ( "" ) ;
149+ Information ( "Removing benchmark project" ) ;
150+ DotNetTool ( solutionFile , "sln" , $ "remove { benchmarkProject . TrimStart ( sourceFolder , StringComparison . OrdinalIgnoreCase ) } ") ;
142151 }
143152} ) ;
144153
145154Teardown( context =>
146155{
147156 if ( ! isLocalBuild )
148157 {
149- Information ( "Restoring integration tests " ) ;
158+ Information ( "Restoring projects that may have been removed during build script setup " ) ;
150159 GitCheckout ( "." , new FilePath [ ] { solutionFile } ) ;
151160 Information ( "" ) ;
152161 }
@@ -193,7 +202,7 @@ Task("Restore-NuGet-Packages")
193202 . IsDependentOn ( "Clean" )
194203 . Does ( ( ) =>
195204{
196- DotNetCoreRestore ( "./Source/" , new DotNetCoreRestoreSettings
205+ DotNetRestore ( "./Source/" , new DotNetRestoreSettings
197206 {
198207 Sources = new [ ] {
199208 "https://api.nuget.org/v3/index.json" ,
@@ -205,16 +214,18 @@ Task("Build")
205214 . IsDependentOn ( "Restore-NuGet-Packages" )
206215 . Does ( ( ) =>
207216{
208- DotNetCoreBuild ( solutionFile , new DotNetCoreBuildSettings
217+ DotNetBuild ( solutionFile , new DotNetBuildSettings
209218 {
210219 Configuration = configuration ,
211220 Framework = desiredFramework ,
212221 NoRestore = true ,
213- ArgumentCustomization = args =>
222+ MSBuildSettings = new DotNetMSBuildSettings
214223 {
215- return args
216- . Append ( "/p:SemVer={0}" , versionInfo . LegacySemVerPadded )
217- . Append ( "/p:ContinuousIntegrationBuild={0}" , BuildSystem . IsLocalBuild ? "false" : "true" ) ;
224+ Version = versionInfo . LegacySemVerPadded ,
225+ AssemblyVersion = versionInfo . MajorMinorPatch ,
226+ FileVersion = versionInfo . MajorMinorPatch ,
227+ InformationalVersion = versionInfo . InformationalVersion ,
228+ ContinuousIntegrationBuild = ! BuildSystem . IsLocalBuild
218229 }
219230 } ) ;
220231} ) ;
@@ -223,7 +234,7 @@ Task("Run-Unit-Tests")
223234 . IsDependentOn ( "Build" )
224235 . Does ( ( ) =>
225236{
226- DotNetCoreTest ( unitTestsProject , new DotNetCoreTestSettings
237+ DotNetTest ( unitTestsProject , new DotNetTestSettings
227238 {
228239 NoBuild = true ,
229240 NoRestore = true ,
@@ -236,7 +247,7 @@ Task("Run-Code-Coverage")
236247 . IsDependentOn ( "Build" )
237248 . Does ( ( ) =>
238249{
239- Action < ICakeContext > testAction = ctx => ctx . DotNetCoreTest ( unitTestsProject , new DotNetCoreTestSettings
250+ Action < ICakeContext > testAction = ctx => ctx . DotNetTest ( unitTestsProject , new DotNetTestSettings
240251 {
241252 NoBuild = true ,
242253 NoRestore = true ,
@@ -291,7 +302,7 @@ Task("Create-NuGet-Package")
291302{
292303 var releaseNotesUrl = @$ "https://github.com/{ gitHubRepoOwner } /{ gitHubRepo } /releases/tag/{ milestone } ";
293304
294- var settings = new DotNetCorePackSettings
305+ var settings = new DotNetPackSettings
295306 {
296307 Configuration = configuration ,
297308 IncludeSource = false ,
@@ -301,18 +312,14 @@ Task("Create-NuGet-Package")
301312 NoDependencies = true ,
302313 OutputDirectory = outputDir ,
303314 SymbolPackageFormat = "snupkg" ,
304- ArgumentCustomization = ( args ) =>
315+ MSBuildSettings = new DotNetMSBuildSettings
305316 {
306- return args
307- . Append ( "/p:PackageReleaseNotes=\" {0}\" " , releaseNotesUrl )
308- . Append ( "/p:Version={0}" , versionInfo . LegacySemVerPadded )
309- . Append ( "/p:AssemblyVersion={0}" , versionInfo . MajorMinorPatch )
310- . Append ( "/p:FileVersion={0}" , versionInfo . MajorMinorPatch )
311- . Append ( "/p:AssemblyInformationalVersion={0}" , versionInfo . InformationalVersion ) ;
317+ PackageReleaseNotes = releaseNotesUrl ,
318+ PackageVersion = versionInfo . LegacySemVerPadded
312319 }
313320 } ;
314321
315- DotNetCorePack ( sourceProject , settings ) ;
322+ DotNetPack ( sourceProject , settings ) ;
316323} ) ;
317324
318325Task( "Upload-AppVeyor-Artifacts" )
@@ -408,14 +415,14 @@ Task("Publish-GitHub-Release")
408415
409416Task( "Generate-Benchmark-Report" )
410417 . IsDependentOn ( "Build" )
411- . WithCriteria ( isBenchmarkPresent )
418+ . WithCriteria ( isBenchmarkProjectPresent )
412419 . Does ( ( ) =>
413420{
414421 var publishDirectory = $ "{ benchmarkDir } Publish/";
415422 var publishedAppLocation = MakeAbsolute ( File ( $ "{ publishDirectory } { libraryName } .Benchmark.exe") ) . FullPath ;
416423 var artifactsLocation = MakeAbsolute ( File ( benchmarkDir ) ) . FullPath ;
417424
418- DotNetCorePublish ( benchmarkProject , new DotNetCorePublishSettings
425+ DotNetPublish ( benchmarkProject , new DotNetPublishSettings
419426 {
420427 Configuration = configuration ,
421428 NoRestore = true ,
@@ -452,7 +459,7 @@ Task("Coverage")
452459
453460Task( "Benchmark" )
454461 . IsDependentOn ( "Generate-Benchmark-Report" )
455- . WithCriteria ( isBenchmarkPresent )
462+ . WithCriteria ( isBenchmarkProjectPresent )
456463 . Does ( ( ) =>
457464{
458465 var htmlReports = GetFiles ( $ "{ benchmarkDir } results/*-report.html", new GlobberSettings { IsCaseSensitive = false } ) ;
0 commit comments