Skip to content

Commit f342dc4

Browse files
authored
Merge pull request #7 from twenzel/UpdateProject
Update cake
2 parents 1e0f549 + 801bd34 commit f342dc4

9 files changed

Lines changed: 109 additions & 390 deletions

File tree

.config/dotnet-tools.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"cake.tool": {
6+
"version": "2.0.0",
7+
"commands": [
8+
"dotnet-cake"
9+
]
10+
}
11+
}
12+
}

.github/workflows/build.yml

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,42 @@
11
name: Build & Test
22

3-
on: [push, pull_request]
4-
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- develop
8+
- main
9+
tags:
10+
- "*"
11+
paths-ignore:
12+
- "README.md"
13+
pull_request:
14+
515
jobs:
616
build:
717

8-
runs-on: windows-latest
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
os: [windows-latest, ubuntu-18.04, macos-latest]
922

1023
steps:
11-
- uses: actions/checkout@v1
12-
- name: Setup .NET Core
24+
- name: Checkout the repository
25+
uses: actions/checkout@v2
26+
27+
- name: Fetch all tags and branches
28+
run: git fetch --prune --unshallow
29+
30+
- name: Install .NET SDK
1331
uses: actions/setup-dotnet@v1
1432
with:
15-
dotnet-version: 3.1.100
33+
# gitversion needs 5.0 and we need all SDKs the project is targeting
34+
dotnet-version: |
35+
3.1.x
36+
5.0.x
37+
6.0.x
38+
1639
- name: run cake
17-
uses: ecampidoglio/cake-action@v1.1.1
40+
uses: ecampidoglio/cake-action@v1
1841
with:
19-
target: Pack
20-
cake-version: 0.35.0
42+
target: Test

.github/workflows/release.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ on:
77
jobs:
88
build:
99

10-
runs-on: windows-latest
10+
runs-on: ubuntu-18.04
1111

1212
steps:
13-
- uses: actions/checkout@v1
13+
- uses: actions/checkout@v2
1414

1515
- name: Setup .NET Core
1616
uses: actions/setup-dotnet@v1
1717
with:
18-
dotnet-version: 3.1.100
18+
dotnet-version: |
19+
3.1.x
20+
5.0.x
21+
6.0.x
1922
2023
- name: run cake
21-
uses: ecampidoglio/cake-action@v1.1.1
24+
uses: ecampidoglio/cake-action@v1
2225
with:
23-
target: Publish
24-
cake-version: 0.35.0
26+
target: Publish
2527
env:
2628
nugetApiKey: ${{ secrets.nugetApiKey }}

WebOptimizer.Dotless.sln

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27004.2008
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.32112.339
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebOptimizer.Dotless", "src\WebOptimizer.Dotless.csproj", "{B30F1B43-84C3-476C-996E-78803CCE9C19}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebOptimizer.Dotless.Test", "test\WebOptimizer.Dotless.Test.csproj", "{080EB5C5-EBBC-4F94-8A0F-238E0542FB35}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebOptimizer.Dotless.Test", "test\WebOptimizer.Dotless.Test.csproj", "{080EB5C5-EBBC-4F94-8A0F-238E0542FB35}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution

build.cake

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#tool "nuget:?package=GitVersion.CommandLine&version=4.0.0"
2-
#tool "nuget:?package=nuget.commandline&version=5.3.0"
1+
#tool "dotnet:?package=GitVersion.Tool&version=5.8.1"
2+
#tool "nuget:?package=NuGet.CommandLine&version=5.11.0"
33

44
var target = Argument("target", "Default");
55
var nugetApiKey = Argument("nugetApiKey", EnvironmentVariable("nugetApiKey"));
@@ -9,9 +9,13 @@ var nugetApiKey = Argument("nugetApiKey", EnvironmentVariable("nugetApiKey"));
99
/////////////////////////////////////////////////////////////////////
1010
var solution = "./WebOptimizer.Dotless.sln";
1111
var project = "./src/WebOptimizer.Dotless.csproj";
12-
var outputDir = "./buildArtifacts/";
13-
var outputDirNuget = outputDir+"NuGet/";
14-
var testResultsPath = System.IO.Path.Combine(System.IO.Path.GetFullPath(outputDir), "TestResults.xml");
12+
var outputDirRoot = new DirectoryPath("./buildArtifacts/").MakeAbsolute(Context.Environment);
13+
var outputDirPublished = outputDirRoot.Combine("Published");
14+
var outputDirTemp = outputDirRoot.Combine("Temp");
15+
var packageOutputDir = outputDirPublished.Combine("Package");
16+
17+
var outputDirTests = outputDirTemp.Combine("Tests/");
18+
1519
var nugetPublishFeed = "https://api.nuget.org/v3/index.json";
1620

1721

@@ -23,14 +27,12 @@ Task("Clean")
2327
.Description("Removes the output directory")
2428
.Does(() => {
2529

26-
if (DirectoryExists(outputDir))
27-
{
28-
DeleteDirectory(outputDir, new DeleteDirectorySettings {
30+
EnsureDirectoryDoesNotExist(outputDirRoot, new DeleteDirectorySettings {
2931
Recursive = true,
3032
Force = true
31-
});
32-
}
33-
CreateDirectory(outputDir);
33+
});
34+
CreateDirectory(outputDirRoot);
35+
CreateDirectory(outputDirPublished);
3436
});
3537

3638
GitVersion versionInfo = null;
@@ -50,48 +52,41 @@ Task("Build")
5052
.IsDependentOn("Version")
5153
.Does(() => {
5254

53-
var settings = new DotNetCoreBuildSettings {
54-
Configuration = "Release",
55-
ArgumentCustomization = args => args.Append("/p:SemVer=" + versionInfo.NuGetVersionV2 + " /p:SourceLinkCreate=true")
56-
};
55+
var msBuildSettings = new DotNetMSBuildSettings()
56+
{
57+
Version = versionInfo.AssemblySemVer,
58+
InformationalVersion = versionInfo.InformationalVersion,
59+
PackageVersion = versionInfo.NuGetVersionV2
60+
}.WithProperty("PackageOutputPath", packageOutputDir.FullPath);
5761

58-
DotNetCoreBuild(project, settings);
62+
var settings = new DotNetBuildSettings {
63+
Configuration = "Release",
64+
MSBuildSettings = msBuildSettings
65+
};
66+
67+
DotNetBuild(project, settings);
5968
});
6069

6170
Task("Test")
6271
.IsDependentOn("Build")
6372
.Does(() =>
6473
{
65-
var settings = new DotNetCoreTestSettings {
66-
Logger = "trx;logfilename=" + testResultsPath
74+
var settings = new DotNetTestSettings {
75+
Loggers = new[]{"trx;"},
76+
ResultsDirectory = outputDirTests,
77+
NoBuild = true
6778
};
6879

69-
DotNetCoreTest("./test/WebOptimizer.Dotless.Test.csproj", settings);
70-
});
71-
72-
73-
Task("Pack")
74-
.IsDependentOn("Test")
75-
.IsDependentOn("Version")
76-
.Does(() => {
77-
78-
var packSettings = new DotNetCorePackSettings
79-
{
80-
Configuration = "Release",
81-
OutputDirectory = outputDirNuget,
82-
ArgumentCustomization = args => args.Append("/p:PackageVersion=" + versionInfo.NuGetVersionV2+ " /p:SourceLinkCreate=true")
83-
};
84-
85-
DotNetCorePack(project, packSettings);
80+
DotNetTest("./test/WebOptimizer.Dotless.Test.csproj", settings);
8681
});
8782

8883
Task("Publish")
89-
.IsDependentOn("Pack")
84+
.IsDependentOn("Test")
9085
.Description("Pushes the created NuGet packages to nuget.org")
9186
.Does(() => {
9287

9388
// Get the paths to the packages.
94-
var packages = GetFiles(outputDirNuget + "*.nupkg");
89+
var packages = GetFiles(packageOutputDir.CombineWithFilePath("*.nupkg").FullPath);
9590

9691
// Push the package.
9792
NuGetPush(packages, new NuGetPushSettings {

0 commit comments

Comments
 (0)