Skip to content

Commit 9155b19

Browse files
committed
Update build script and other resource files. Upgrade to .NET SDK 6.0. Upgrade to Cake 2.0.0
1 parent a9b75ca commit 9155b19

8 files changed

Lines changed: 139 additions & 49 deletions

File tree

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"cake.tool": {
6-
"version": "1.2.0",
6+
"version": "2.0.0",
77
"commands": [
88
"dotnet-cake"
99
]

.gitignore

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## Ignore Visual Studio temporary files, build results, and
66
## files generated by popular Visual Studio add-ons.
77
##
8-
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
8+
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
99

1010
# User-specific files
1111
*.rsuser
@@ -210,9 +210,6 @@ PublishScripts/
210210
*.nuget.props
211211
*.nuget.targets
212212

213-
# Nuget personal access tokens and Credentials
214-
nuget.config
215-
216213
# Microsoft Azure Build Output
217214
csx/
218215
*.build.csdef
@@ -301,6 +298,15 @@ node_modules/
301298
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
302299
*.vbw
303300

301+
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
302+
*.vbp
303+
304+
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
305+
*.dsw
306+
*.dsp
307+
308+
# Visual Studio 6 technical files
309+
304310
# Visual Studio LightSwitch build output
305311
**/*.HTMLClient/GeneratedArtifacts
306312
**/*.DesktopClient/GeneratedArtifacts
@@ -357,6 +363,9 @@ ASALocalRun/
357363
# Local History for Visual Studio
358364
.localhistory/
359365

366+
# Visual Studio History (VSHistory) files
367+
.vshistory/
368+
360369
# BeatPulse healthcheck temp database
361370
healthchecksdb
362371

@@ -388,7 +397,6 @@ FodyWeavers.xsd
388397
*.msp
389398

390399
# JetBrains Rider
391-
.idea/
392400
*.sln.iml
393401

394402
### VisualStudio Patch ###

GitReleaseManager.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ issue-labels-include:
2626
- Bug
2727
- New Feature
2828
- Improvement
29+
- Enhancement
2930
- Documentation
3031
- Security
3132
issue-labels-exclude:

GitVersion.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ branches:
1313
develop:
1414
regex: dev(elop)?(ment)?$
1515
mode: ContinuousDeployment
16-
tag: alpha
16+
tag: beta
1717
hotfix:
1818
regex: hotfix(es)?[/-]
1919
mode: ContinuousDeployment
20-
tag: beta
20+
tag: hotfix
2121
release:
2222
regex: release(s)?[/-]
2323
mode: ContinuousDeployment

appveyor.psm1

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Inspired by: https://github.com/PowerShell/PSScriptAnalyzer/blob/master/tools/appveyor.psm1
2+
3+
$ErrorActionPreference = 'Stop'
4+
5+
# Implements the AppVeyor 'install' step and installs the desired .NET SDK if not already installed.
6+
function Invoke-AppVeyorInstall {
7+
8+
Write-Verbose -Verbose "Determining the desired version of .NET SDK"
9+
$globalDotJson = Get-Content (Join-Path $PSScriptRoot 'global.json') -Raw | ConvertFrom-Json
10+
$desiredDotNetCoreSDKVersion = $globalDotJson.sdk.version
11+
Write-Verbose -Verbose "We have determined that the desired version of the .NET SDK is $desiredDotNetCoreSDKVersion"
12+
13+
Write-Verbose -Verbose "Checking availability of .NET SDK $desiredDotNetCoreSDKVersion"
14+
$desiredDotNetCoreSDKVersionPresent = (dotnet --list-sdks) -match $desiredDotNetCoreSDKVersion
15+
16+
if (-not $desiredDotNetCoreSDKVersionPresent) {
17+
Write-Verbose -Verbose "We have determined that the desired version of the .NET SDK is not present on this machine"
18+
Write-Verbose -Verbose "Installing .NET SDK $desiredDotNetCoreSDKVersion"
19+
$originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol
20+
try {
21+
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
22+
if ($IsLinux -or $isMacOS) {
23+
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.sh' -OutFile dotnet-install.sh
24+
25+
# Normally we would execute dotnet-install.sh like so:
26+
# bash dotnet-install.sh --version $desiredDotNetCoreSDKVersion
27+
#
28+
# and we would also update the PATH environment variable like so:
29+
# $OLDPATH = [System.Environment]::GetEnvironmentVariable("PATH")
30+
# $NEWPATH = "/home/appveyor/.dotnet$([System.IO.Path]::PathSeparator)$OLDPATH"
31+
# [Environment]::SetEnvironmentVariable("PATH", "$NEWPATH")
32+
#
33+
# This is supposed to result in the desired .NET SDK to be installed side-by-side
34+
# with the other version(s) of the SDK already installed. However, my experience
35+
# on Ubuntu images in Appveyor has been that the recently installed SDK is the only
36+
# one detected and the previous versions are no longer detected as being installed.
37+
#
38+
# This whole thing is problematic because GitVersion.Tool 5.7 is not compatible with
39+
# .NET 6 (in fact, it doesn't even install) and you must have .NET 5 installed side-by-side
40+
# with .NET 6 in order to install and use GitVersion.Tool
41+
#
42+
# I spent a whole day trying to find a solution but ultimately the only reliable solution
43+
# I was able to come up with is to install in the default location (which is /usr/share/dotnet)
44+
# using 'sudo' because you need admin privileges to access the default install location.
45+
46+
sudo bash dotnet-install.sh --version $desiredDotNetCoreSDKVersion --install-dir /usr/share/dotnet
47+
}
48+
else {
49+
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1
50+
.\dotnet-install.ps1 -Version $desiredDotNetCoreSDKVersion
51+
}
52+
}
53+
finally {
54+
[Net.ServicePointManager]::SecurityProtocol = $originalSecurityProtocol
55+
Remove-Item .\dotnet-install.*
56+
}
57+
Write-Verbose -Verbose "Installed .NET SDK $desiredDotNetCoreSDKVersion"
58+
}
59+
else {
60+
Write-Verbose -Verbose "We have determined that the desired version of the .NET SDK is already installed on this machine"
61+
}
62+
}

appveyor.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
1-
# Before Build
1+
# environment variables
2+
environment:
3+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # For faster CI builds
4+
DOTNET_ROLL_FORWARD: Major # See https://github.com/GitTools/GitVersion/issues/2906 until 5.8.0 is released
5+
6+
# scripts that are called at very beginning, before repo cloning
27
init:
38
- git config --global core.autocrlf true
49

5-
# Build script
6-
build_script:
10+
# scripts that run after cloning repository
11+
install:
12+
- ps: Import-Module .\appveyor.psm1; Invoke-AppveyorInstall
13+
14+
# scripts to run before build
15+
before_build:
716
- dotnet --info
17+
18+
# to run your custom scripts instead of automatic MSBuild
19+
build_script:
820
- ps: .\build.ps1 --target=AppVeyor
921

22+
# scripts to run after build
23+
after_build:
24+
1025
# Tests
1126
test: off
1227

@@ -26,11 +41,8 @@ cache:
2641
# Environment configuration
2742
image:
2843
- Ubuntu1804
29-
- Visual Studio 2019
44+
- Visual Studio 2022
3045

31-
#---------------------------------#
32-
# Skip builds for doc changes #
33-
#---------------------------------#
46+
# Skip builds for doc changes
3447
skip_commits:
35-
# Regex for matching commit message
3648
message: /\(doc\).*/

build.cake

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
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;
6161
var isMainBranch = StringComparer.OrdinalIgnoreCase.Equals("main", BuildSystem.AppVeyor.Environment.Repository.Branch);
6262
var isMainRepo = StringComparer.OrdinalIgnoreCase.Equals($"{gitHubRepoOwner}/{gitHubRepo}", BuildSystem.AppVeyor.Environment.Repository.Name);
6363
var 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

145154
Teardown(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

318325
Task("Upload-AppVeyor-Artifacts")
@@ -408,14 +415,14 @@ Task("Publish-GitHub-Release")
408415

409416
Task("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

453460
Task("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 });

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "5.0.400",
3+
"version": "6.0.200",
44
"rollForward": "latestFeature"
55
}
66
}

0 commit comments

Comments
 (0)