Skip to content

Commit 7c8033d

Browse files
committed
Refresh build script
1 parent 19fa86c commit 7c8033d

4 files changed

Lines changed: 51 additions & 18 deletions

File tree

.editorconfig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ insert_final_newline = false
1111
trim_trailing_whitespace = true
1212

1313
# .NET Code files
14-
[*.{cs,csx,cake,vb}]
14+
[*.{cs,csx,cake,vb,vbx,h,cpp,idl}]
1515
indent_style = tab
1616
tab_width = 4
1717
insert_final_newline = true
@@ -21,12 +21,12 @@ insert_final_newline = true
2121
indent_style = tab
2222
tab_width = 4
2323

24-
# Visual Studio XML Project Files
25-
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
24+
# MSBuild project files
25+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,msbuildproj}]
2626
indent_size = 2
2727

28-
# Various XML Configuration Files
29-
[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}]
28+
# Xml config files
29+
[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct,runsettings}]
3030
indent_size = 2
3131

3232
# JSON Files

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,6 @@
9494
*.DOT diff=astextplain
9595
*.rtf diff=astextplain
9696
*.RTF diff=astextplain
97+
98+
# The macOS codesign tool is extremely picky, and requires LF line endings.
99+
*.plist eol=lf

build.cake

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#tool dotnet:?package=GitVersion.Tool&version=5.12.0
33
#tool dotnet:?package=coveralls.net&version=4.0.1
44
#tool nuget:?package=GitReleaseManager&version=0.13.0
5-
#tool nuget:?package=ReportGenerator&version=5.1.16
5+
#tool nuget:?package=ReportGenerator&version=5.1.21
66
#tool nuget:?package=xunit.runner.console&version=2.4.2
77
#tool nuget:?package=Codecov&version=1.13.0
88

@@ -66,6 +66,7 @@ var sourceFolder = "./Source/";
6666
var outputDir = "./artifacts/";
6767
var codeCoverageDir = $"{outputDir}CodeCoverage/";
6868
var benchmarkDir = $"{outputDir}Benchmark/";
69+
var coverageFile = $"{codeCoverageDir}coverage.{DefaultFramework}.xml";
6970

7071
var solutionFile = $"{sourceFolder}{libraryName}.sln";
7172
var sourceProject = $"{sourceFolder}{libraryName}/{libraryName}.csproj";
@@ -85,13 +86,15 @@ var isIntegrationTestsProjectPresent = FileExists(integrationTestsProject);
8586
var isUnitTestsProjectPresent = FileExists(unitTestsProject);
8687
var isBenchmarkProjectPresent = FileExists(benchmarkProject);
8788

89+
var publishingError = false;
90+
8891
// Generally speaking, we want to honor all the TFM configured in the source project and the unit test project.
8992
// However, there are a few scenarios where a single framework is sufficient. Here are a few examples that come to mind:
9093
// - when building source project on Ubuntu
9194
// - when running unit tests on Ubuntu
9295
// - when calculating code coverage
9396
// FYI, this will cause an error if the source project and/or the unit test project are not configured to target this desired framework:
94-
const string DefaultFramework = "net6.0";
97+
const string DefaultFramework = "net7.0";
9598
var desiredFramework = (
9699
!IsRunningOnWindows() ||
97100
target.Equals("Coverage", StringComparison.OrdinalIgnoreCase) ||
@@ -257,6 +260,7 @@ Task("Build")
257260
});
258261

259262
Task("Run-Unit-Tests")
263+
.WithCriteria(() => isUnitTestsProjectPresent)
260264
.IsDependentOn("Build")
261265
.Does(() =>
262266
{
@@ -270,6 +274,7 @@ Task("Run-Unit-Tests")
270274
});
271275

272276
Task("Run-Code-Coverage")
277+
.WithCriteria(() => isUnitTestsProjectPresent)
273278
.IsDependentOn("Build")
274279
.Does(() =>
275280
{
@@ -297,29 +302,46 @@ Task("Run-Code-Coverage")
297302

298303
Task("Upload-Coverage-Result-Coveralls")
299304
.IsDependentOn("Run-Code-Coverage")
300-
.OnError(exception => Information($"ONERROR: Failed to upload coverage result to Coveralls: {exception.Message}"))
305+
.WithCriteria(() => FileExists(coverageFile))
306+
.WithCriteria(() => !isLocalBuild)
307+
.WithCriteria(() => !isPullRequest)
308+
.WithCriteria(() => isMainRepo)
301309
.Does(() =>
302310
{
303-
//CoverallsNet(new FilePath($"{codeCoverageDir}coverage.{DefaultFramework}.xml"), CoverallsNetReportType.OpenCover, new CoverallsNetSettings()
304-
//{
305-
// RepoToken = coverallsToken
306-
//});
311+
CoverallsNet(new FilePath(coverageFile), CoverallsNetReportType.OpenCover, new CoverallsNetSettings()
312+
{
313+
RepoToken = coverallsToken,
314+
UseRelativePaths = true
315+
});
316+
}).OnError (exception =>
317+
{
318+
Error(exception.Message);
319+
Information($"Failed to upload coverage result to Coveralls, but continuing with next Task...");
320+
publishingError = true;
307321
});
308322

309323
Task("Upload-Coverage-Result-Codecov")
310324
.IsDependentOn("Run-Code-Coverage")
311-
.OnError(exception => Information($"ONERROR: Failed to upload coverage result to Codecov: {exception.Message}"))
325+
.WithCriteria(() => FileExists(coverageFile))
326+
.WithCriteria(() => !isLocalBuild)
327+
.WithCriteria(() => !isPullRequest)
328+
.WithCriteria(() => isMainRepo)
312329
.Does(() =>
313330
{
314-
//Codecov($"{codeCoverageDir}coverage.{DefaultFramework}.xml", codecovToken);
331+
Codecov(coverageFile, codecovToken);
332+
}).OnError (exception =>
333+
{
334+
Error(exception.Message);
335+
Information($"Failed to upload coverage result to Codecov, but continuing with next Task...");
336+
publishingError = true;
315337
});
316338

317339
Task("Generate-Code-Coverage-Report")
318340
.IsDependentOn("Run-Code-Coverage")
319341
.Does(() =>
320342
{
321343
ReportGenerator(
322-
new FilePath($"{codeCoverageDir}coverage.{DefaultFramework}.xml"),
344+
new FilePath(coverageFile),
323345
codeCoverageDir,
324346
new ReportGeneratorSettings() {
325347
ClassFilters = new[] { "*.UnitTests*" }
@@ -513,7 +535,14 @@ Task("AppVeyor")
513535
.IsDependentOn("Upload-AppVeyor-Artifacts")
514536
.IsDependentOn("Publish-MyGet")
515537
.IsDependentOn("Publish-NuGet")
516-
.IsDependentOn("Publish-GitHub-Release");
538+
.IsDependentOn("Publish-GitHub-Release")
539+
.Finally(() =>
540+
{
541+
if (publishingError)
542+
{
543+
throw new Exception("An error occurred during the publishing of [Http-Multipart-Data-Parser]. All publishing tasks have been attempted.");
544+
}
545+
});
517546

518547
Task("Default")
519548
.IsDependentOn("Run-Unit-Tests")

global.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"sdk": {
3-
"version": "7.0.102",
4-
"rollForward": "latestFeature"
3+
"version": "7.0.302",
4+
"rollForward": "patch",
5+
"allowPrerelease": false
56
}
67
}

0 commit comments

Comments
 (0)