Skip to content

Commit 5f71be9

Browse files
committed
Merge commit 'a6584ff780d32308bf7a902ad3e63cc12eb2d76f' as 'build/shared'
2 parents d0eb205 + a6584ff commit 5f71be9

19 files changed

+644
-0
lines changed

build/shared/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 AppCore .NET
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: $(Date:yyyyMMdd)$(Rev:.r)
2+
3+
variables:
4+
configuration: Debug
5+
6+
trigger:
7+
branches:
8+
include:
9+
- dev
10+
- master
11+
- main
12+
- releases/*
13+
- hotfixes/*
14+
- support/v*
15+
16+
jobs:
17+
- template: build/shared/azure-pipelines/jobs.yml
18+
parameters:
19+
configuration: $(configuration)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: $(Date:yyyyMMdd)$(Rev:.r)
2+
3+
variables:
4+
configuration: Release
5+
6+
pr: none
7+
8+
trigger:
9+
tags:
10+
include:
11+
- v*
12+
13+
jobs:
14+
- template: build/shared/azure-pipelines/jobs.yml
15+
parameters:
16+
configuration: $(configuration)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
parameters:
2+
configuration: 'Debug'
3+
testFilter: ''
4+
5+
steps:
6+
- pwsh: ./build.ps1 --configuration "${{ parameters.configuration }}"
7+
displayName: Build
8+
- pwsh: ./build.ps1 --target "Test" --skip-target "Build" --configuration "${{ parameters.configuration }}" --test-filter "${{ parameters.testFilter }}" --artifactsDir "$(Build.ArtifactStagingDirectory)"
9+
displayName: Run Tests
10+
- task: PublishTestResults@2
11+
displayName: Publish Test Results
12+
condition: always()
13+
inputs:
14+
testRunner: VSTest
15+
testRunTitle: '$(Agent.OS)-$(Agent.OSArchitecture)'
16+
testResultsFiles: '$(Build.ArtifactStagingDirectory)/test-results/*.trx'
17+
failTaskOnFailedTests: true
18+
buildConfiguration: ${{ parameters.configuration }}
19+
- task: PublishCodeCoverageResults@1
20+
displayName: Publish Coverage Results
21+
condition: always()
22+
inputs:
23+
codeCoverageTool: 'cobertura'
24+
summaryFileLocation: '$(Build.ArtifactStagingDirectory)/test-results/report/Cobertura.xml'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
steps:
2+
3+
- task: UseDotNet@2
4+
displayName: 'Install .NET Core SDK 3.1'
5+
inputs:
6+
version: '3.1.x'
7+
- task: UseDotNet@2
8+
displayName: 'Install .NET SDK 5'
9+
inputs:
10+
version: '5.x'
11+
- task: UseDotNet@2
12+
displayName: 'Install .NET SDK 6'
13+
inputs:
14+
version: '6.x'
15+
- task: NuGetToolInstaller@1
16+
displayName: 'Install NuGet 5.4'
17+
inputs:
18+
versionSpec: '5.4.x'
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
parameters:
2+
configuration: 'Debug'
3+
testFilter: ''
4+
5+
jobs:
6+
- job: Linux
7+
pool:
8+
vmImage: 'ubuntu-latest'
9+
steps:
10+
- template: ./install-steps.yml
11+
- template: ./build-steps.yml
12+
parameters:
13+
configuration: '${{ parameters.configuration }}'
14+
testFilter: '${{ parameters.testFilter }}'
15+
- template: ./publish-steps.yml
16+
parameters:
17+
configuration: '${{ parameters.configuration }}'
18+
19+
- job: MacOS
20+
pool:
21+
vmImage: 'macOS-latest'
22+
steps:
23+
- template: ./install-steps.yml
24+
- template: ./build-steps.yml
25+
parameters:
26+
configuration: '${{ parameters.configuration }}'
27+
testFilter: '${{ parameters.testFilter }}'
28+
29+
- job: Windows
30+
pool:
31+
vmImage: 'windows-latest'
32+
steps:
33+
- template: ./install-steps.yml
34+
- template: ./build-steps.yml
35+
parameters:
36+
configuration: '${{ parameters.configuration }}'
37+
testFilter: '${{ parameters.testFilter }}'
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
parameters:
2+
configuration: 'Debug'
3+
4+
steps:
5+
- pwsh: ./build.ps1 --target "Publish" --configuration "${{ parameters.configuration }}" --artifactsDir "$(Build.ArtifactStagingDirectory)"
6+
displayName: Publish
7+
- task: NuGetCommand@2
8+
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
9+
displayName: Push Packages (Testing)
10+
inputs:
11+
command: push
12+
nuGetFeedType: external
13+
publishFeedCredentials: MyGet Testing
14+
packagesToPush: $(Build.ArtifactStagingDirectory)/packages/**.nupkg;$(Build.ArtifactStagingDirectory)/packages/**.snupkg
15+
verbosityPush: 'Normal'
16+
- task: NuGetCommand@2
17+
condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/tags')))
18+
displayName: Push Packages (CI)
19+
inputs:
20+
command: push
21+
nuGetFeedType: external
22+
publishFeedCredentials: MyGet
23+
packagesToPush: $(Build.ArtifactStagingDirectory)/packages/**.nupkg;$(Build.ArtifactStagingDirectory)/packages/**.snupkg
24+
verbosityPush: 'Normal'
25+
- task: NuGetCommand@2
26+
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags'))
27+
displayName: Push Packages (Release)
28+
inputs:
29+
command: push
30+
nuGetFeedType: external
31+
publishFeedCredentials: NuGet
32+
packagesToPush: $(Build.ArtifactStagingDirectory)/packages/**.nupkg
33+
verbosityPush: 'Normal'

build/shared/build.cake

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#addin "nuget:?package=Cake.Figlet&version=2.0.1"
2+
3+
#load "build/shared/cake/common.cake"
4+
#load "build/shared/cake/dotnetcore.cake"
5+
6+
Setup<BuildParameters>(context =>
7+
{
8+
var parameters = BuildParameters.Create(Context);
9+
parameters.Initialize();
10+
11+
Information(Figlet("AppCore.XYZ"));
12+
Information($"Version: {parameters.Version.InformationalVersion}");
13+
14+
return parameters;
15+
});
16+
17+
Task("Restore")
18+
.IsDependentOn("DotNetCore.Restore");
19+
20+
Task("Build")
21+
.IsDependentOn("DotNetCore.Build");
22+
23+
Task("Test")
24+
.IsDependentOn("DotNetCore.Test");
25+
26+
Task("Clean")
27+
.IsDependentOn("Common.Clean")
28+
.IsDependentOn("DotNetCore.Clean");
29+
30+
Task("Rebuild")
31+
.IsDependentOn("Clean")
32+
.IsDependentOn("Build");
33+
34+
Task("Publish")
35+
.IsDependentOn("DotNetCore.Pack");
36+
37+
RunTarget(Context.Argument("target", "Build"));

build/shared/build.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[CmdletBinding()]
2+
param (
3+
[Parameter(ValueFromRemainingArguments=$True)]
4+
[string[]] $Arguments
5+
)
6+
7+
$ErrorActionPreference = "Stop"
8+
9+
$ToolsPath = Join-Path $PSScriptRoot "build" -Resolve | Join-Path -ChildPath "tools"
10+
$Cake = Join-Path $ToolsPath "dotnet-cake"
11+
$CakeVersion = "1.1.0"
12+
$CakeArgs = @("--paths_tools=$ToolsPath")
13+
14+
function Exec {
15+
param ([ScriptBlock] $ScriptBlock)
16+
& $ScriptBlock
17+
If ($LASTEXITCODE -ne 0) {
18+
Write-Error "Execution failed with exit code $LASTEXITCODE"
19+
}
20+
}
21+
22+
# bootstrap cake
23+
If (!(Test-Path "$ToolsPath/.store/cake.tool")) {
24+
Exec { & dotnet tool install --tool-path $ToolsPath Cake.Tool --version $CakeVersion }
25+
Exec { & $Cake @CakeArgs --bootstrap }
26+
}
27+
28+
# build
29+
Exec { & $Cake @CakeArgs @Arguments }

build/shared/cake/common.cake

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#addin "nuget:?package=Cake.FileHelpers&version=4.0.1"
2+
3+
#load "parameters.cake"
4+
#load "constants.cake"
5+
6+
public static CakeTaskBuilder CanBeSkipped(this CakeTaskBuilder builder, params string[] tasks)
7+
{
8+
return builder.WithCriteria<BuildParameters>((c,p) => !p.SkipTargets.Overlaps(tasks));
9+
}
10+
11+
public void CleanFile(string filePath)
12+
{
13+
if (Context.FileExists(filePath))
14+
Context.DeleteFile(filePath);
15+
}
16+
17+
public bool UpdateVersionProps(string projectFile, BuildVersion version)
18+
{
19+
var file = Context.File(projectFile);
20+
bool updated = false;
21+
if (!Context.FileExists(file))
22+
{
23+
Context.FileWriteText(file, "<Project><PropertyGroup><Version /><AssemblyVersion /><FileVersion /><InformationalVersion /></PropertyGroup></Project>");
24+
}
25+
26+
if (Context.XmlPeek(file, "/Project/PropertyGroup/Version") != version.Version)
27+
{
28+
Context.XmlPoke(file, "/Project/PropertyGroup/Version", version.Version);
29+
updated = true;
30+
}
31+
32+
if (Context.XmlPeek(file, "/Project/PropertyGroup/AssemblyVersion") != version.AssemblyVersion)
33+
{
34+
Context.XmlPoke(file, "/Project/PropertyGroup/AssemblyVersion", version.AssemblyVersion);
35+
updated = true;
36+
}
37+
38+
if (Context.XmlPeek(file, "/Project/PropertyGroup/FileVersion") != version.FileVersion)
39+
{
40+
Context.XmlPoke(file, "/Project/PropertyGroup/FileVersion", version.FileVersion);
41+
updated = true;
42+
}
43+
44+
if (Context.XmlPeek(file, "/Project/PropertyGroup/InformationalVersion") != version.InformationalVersion)
45+
{
46+
Context.XmlPoke(file, "/Project/PropertyGroup/InformationalVersion", version.InformationalVersion);
47+
updated = true;
48+
}
49+
50+
return updated;
51+
}
52+
53+
Task("Common.Clean")
54+
.Does<BuildParameters>(p =>
55+
{
56+
CleanDirectory(p.ArtifactsDir);
57+
});

0 commit comments

Comments
 (0)