Skip to content

Commit 672f23a

Browse files
committedFeb 8, 2019
using the latest LTS for dotnet
use the cakebuild powershell bootstrapper remove FixForMono as now cake support running with mono
1 parent b64225c commit 672f23a

10 files changed

+145
-119
lines changed
 

‎.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: csharp
22
sudo: required
33
dist: trusty
4-
dotnet: 2.1.500
4+
dotnet: 2.1.503
55
mono:
66
- latest
77
os:

‎azure-pipelines.yml

+17-33
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,21 @@
1+
variables:
2+
DOTNET_SDK_VERSION: '2.1.503'
3+
DOTNET_PACKAGE_TYPE: 'sdk'
4+
RUBY_VERSION: '2.5'
5+
16
jobs:
2-
- job: macOS
3-
pool:
7+
- template: build/tmpl/jobs.yml
8+
parameters:
9+
name: macOS
410
vmImage: 'macOS 10.13'
5-
steps:
6-
- task: DotNetCoreInstaller@0
7-
displayName: 'Use .NET Core sdk 2.1.500'
8-
inputs:
9-
version: 2.1.500
10-
- powershell: ./build.ps1 -script build.cake -target Default
11-
displayName: 'Cake build'
12-
- job: Linux
13-
pool:
11+
installRuby: 'false'
12+
13+
- template: build/tmpl/jobs.yml
14+
parameters:
15+
name: Linux
1416
vmImage: 'Ubuntu 16.04'
15-
steps:
16-
- task: DotNetCoreInstaller@0
17-
displayName: 'Use .NET Core sdk 2.1.500'
18-
inputs:
19-
version: 2.1.500
20-
- task: UseRubyVersion@0
21-
inputs:
22-
addToPath: true # Optional
23-
- powershell: ./build.ps1 -script build.cake -target Default
24-
displayName: 'Cake build'
25-
- job: Windows
26-
pool:
17+
18+
- template: build/tmpl/jobs.yml
19+
parameters:
20+
name: Windows
2721
vmImage: 'VS2017-Win2016'
28-
steps:
29-
- task: DotNetCoreInstaller@0
30-
displayName: 'Use .NET Core sdk 2.1.500'
31-
inputs:
32-
version: 2.1.500
33-
- task: UseRubyVersion@0
34-
inputs:
35-
addToPath: true # Optional
36-
- powershell: ./build.ps1 -script build.cake -target Default
37-
displayName: 'Cake build'

‎build.cake

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Install modules
2+
#module nuget:?package=Cake.DotNetTool.Module&version=0.1.0
13

24
// Install addins.
35
#addin "nuget:?package=Cake.Gitter&version=0.9.0"
@@ -17,6 +19,10 @@
1719
#tool "nuget:?package=GitReleaseNotes&version=0.7.1"
1820
#tool "nuget:?package=ILRepack&version=2.0.16"
1921
#tool "nuget:?package=Codecov&version=1.1.0"
22+
#tool "nuget:?package=nuget.commandline&version=4.9.2"
23+
24+
// Install .NET Core Global tools.
25+
#tool "dotnet:?package=GitReleaseManager.Tool&version=0.8.0"
2026

2127
// Load other scripts.
2228
#load "./build/parameters.cake"
@@ -184,7 +190,6 @@ Task("Test")
184190
nunitSettings.Agents = 1;
185191
}
186192

187-
FixForMono(nunitSettings, "nunit3-console.exe");
188193
NUnit3(testAssemblies, nunitSettings);
189194
});
190195

@@ -323,7 +328,6 @@ Task("Pack-Nuget")
323328
.ToArray()
324329
};
325330

326-
FixForMono(nugetSettings, "nuget.exe");
327331
NuGetPack(package.NuspecPath, nugetSettings);
328332
}
329333
}
@@ -516,7 +520,7 @@ Task("Publish-AzurePipeline")
516520

517521
if (FileExists(parameters.Paths.Files.TestCoverageOutputFilePath)) {
518522
var data = new TFBuildPublishTestResultsData {
519-
TestResultsFiles = new[] { parameters.Paths.Files.TestCoverageOutputFilePath.ToString() },
523+
TestResultsFiles = new[] { parameters.Paths.Files.TestCoverageOutputFilePath },
520524
TestRunner = TFTestRunnerType.NUnit
521525
};
522526
TFBuild.Commands.PublishTestResults(data);
@@ -533,7 +537,7 @@ Task("Publish-Tfs")
533537
.WithCriteria<BuildParameters>((context, parameters) => parameters.EnabledPublishTfs, "Publish-Tfs was disabled.")
534538
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsRunningOnWindows, "Publish-Tfs works only on Windows agents.")
535539
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsRunningOnAppVeyor, "Publish-Tfs works only on AppVeyor.")
536-
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsStableRelease(), "Publish-Tfs works only for releases.")
540+
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsStableRelease(), "Publish-Tfs works only for releases.")
537541
.IsDependentOn("Pack-Tfs")
538542
.Does<BuildParameters>((parameters) =>
539543
{

‎build.config

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
CAKE_VERSION=0.32.1
3+
DOTNET_VERSION=2.1.503

‎build.ps1

+80-56
Original file line numberDiff line numberDiff line change
@@ -45,45 +45,62 @@ Param(
4545
)
4646

4747
Write-Host "Preparing to run build script..."
48+
$DotNetInstallerUri = 'https://dot.net/v1/dotnet-install.ps1';
49+
$DotNetUnixInstallerUri = 'https://dot.net/v1/dotnet-install.sh'
50+
$DotNetChannel = 'LTS'
51+
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
4852

49-
if ($PSEdition -eq "Desktop") { $IsWindows = $true }
50-
51-
$CakeVersion = "0.31.0"
52-
53-
$DotNetChannel = "Current";
54-
$DotNetInstaller = if ($IsWindows) { "dotnet-install.ps1" } else { "dotnet-install.sh" }
55-
$DotNetInstallerUri = "https://dot.net/v1/$DotNetInstaller";
56-
$DotNetVersion = (Get-Content ./src/global.json | ConvertFrom-Json).sdk.version;
57-
58-
$NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
53+
[string] $CakeVersion = ''
54+
[string] $DotNetVersion= ''
55+
foreach($line in Get-Content "$PSScriptRoot\build.config")
56+
{
57+
if ($line -like 'CAKE_VERSION=*') {
58+
$CakeVersion = $line.SubString(13)
59+
}
60+
elseif ($line -like 'DOTNET_VERSION=*') {
61+
$DotNetVersion =$line.SubString(15)
62+
}
63+
}
5964

60-
$PathSplitter = if ($IsWindows) { ';' } else { ':' }
6165

62-
# SSL FIX
63-
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
66+
if ([string]::IsNullOrEmpty($CakeVersion) -or [string]::IsNullOrEmpty($DotNetVersion)) {
67+
'Failed to parse Cake / .NET Core SDK Version'
68+
exit 1
69+
}
6470

6571
# Make sure tools folder exists
66-
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
6772
$ToolPath = Join-Path $PSScriptRoot "tools"
6873
if (!(Test-Path $ToolPath)) {
6974
Write-Verbose "Creating tools directory..."
70-
New-Item -Path $ToolPath -Type directory | out-null
75+
New-Item -Path $ToolPath -Type Directory -Force | out-null
7176
}
7277

78+
# SSL FIX
79+
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
80+
7381
###########################################################################
7482
# INSTALL .NET CORE CLI
7583
###########################################################################
76-
function Remove-PathVariable([string]$VariableToRemove) {
84+
85+
Function Remove-PathVariable([string]$VariableToRemove)
86+
{
87+
$SplitChar = ';'
88+
if ($IsMacOS -or $IsLinux) {
89+
$SplitChar = ':'
90+
}
91+
7792
$path = [Environment]::GetEnvironmentVariable("PATH", "User")
78-
if ($path -ne $null) {
79-
$newItems = $path.Split($PathSplitter, [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
80-
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join($PathSplitter, $newItems), "User")
93+
if ($path -ne $null)
94+
{
95+
$newItems = $path.Split($SplitChar, [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
96+
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join($SplitChar, $newItems), "User")
8197
}
8298

8399
$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
84-
if ($path -ne $null) {
85-
$newItems = $path.Split($PathSplitter, [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
86-
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join($PathSplitter, $newItems), "Process")
100+
if ($path -ne $null)
101+
{
102+
$newItems = $path.Split($SplitChar, [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
103+
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join($SplitChar, $newItems), "Process")
87104
}
88105
}
89106

@@ -95,55 +112,59 @@ if (Get-Command dotnet -ErrorAction SilentlyContinue) {
95112

96113
if($FoundDotNetCliVersion -ne $DotNetVersion) {
97114
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
98-
99115
if (!(Test-Path $InstallPath)) {
100-
New-Item -ItemType Directory $InstallPath | Out-Null;
116+
New-Item -Path $InstallPath -ItemType Directory -Force | Out-Null;
101117
}
102118

103-
[string] $InstalledDotNetVersion = Get-ChildItem -Path ./.dotnet -File `
104-
| Where-Object { $_.Name -eq 'dotnet' -or $_.Name -eq 'dotnet.exe' } `
105-
| ForEach-Object { &$_.FullName --version }
106-
107-
if ($InstalledDotNetVersion -ne $DotNetVersion)
108-
{
109-
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath/$DotNetInstaller");
110-
$Cmd = "$InstallPath/$DotNetInstaller -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath -NoPath"
111-
if (!$IsWindows) { $Cmd = "bash $Cmd" }
112-
Invoke-Expression "& $Cmd"
119+
if ($IsMacOS -or $IsLinux) {
120+
(New-Object System.Net.WebClient).DownloadFile($DotNetUnixInstallerUri, "$InstallPath\dotnet-install.sh");
121+
& bash $InstallPath\dotnet-install.sh --version "$DotNetVersion" --install-dir "$InstallPath" --channel "$DotNetChannel" --no-path
122+
}
123+
else {
124+
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
125+
& $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;
113126
}
114127

115-
# Ensure the installed .NET Core CLI is always used but putting it on the front of the path.
116128
Remove-PathVariable "$InstallPath"
117-
$env:PATH = "$InstallPath$PathSplitter$env:PATH"
118-
$env:DOTNET_ROOT="$InstallPath"
129+
$env:PATH = "$InstallPath;$env:PATH"
119130
}
120131

121-
# Temporarily skip verification of addins.
122-
$env:CAKE_SETTINGS_SKIPVERIFICATION='true'
123132
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
124133
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
125134

126-
###########################################################################
127-
# INSTALL NUGET
128-
###########################################################################
129-
130-
# Make sure nuget.exe exists.
131-
$NugetPath = Join-Path $ToolPath "nuget.exe"
132-
if (!(Test-Path $NugetPath)) {
133-
Write-Host "Downloading NuGet.exe..."
134-
(New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath);
135-
}
136135

137136
###########################################################################
138137
# INSTALL CAKE
139138
###########################################################################
140139

141140
# Make sure Cake has been installed.
142-
Write-Host "Installing Cake..."
143-
$CakeInstallPath = Join-Path $PSScriptRoot ".cake"
144-
if (!(Test-Path $CakeInstallPath)) {
145-
New-Item -ItemType Directory $CakeInstallPath | Out-Null;
146-
Invoke-Expression "& dotnet tool install Cake.Tool --version $CakeVersion --tool-path $CakeInstallPath"
141+
[string] $CakeExePath = ''
142+
[string] $CakeInstalledVersion = Get-Command dotnet-cake -ErrorAction SilentlyContinue | % {&$_.Source --version}
143+
144+
if ($CakeInstalledVersion -eq $CakeVersion) {
145+
# Cake found locally
146+
$CakeExePath = (Get-Command dotnet-cake).Source
147+
}
148+
else {
149+
$CakePath = Join-Path $ToolPath ".store\cake.tool\$CakeVersion"
150+
$CakeExePath = (Get-ChildItem -Path $ToolPath -Filter "dotnet-cake*" -File| ForEach-Object FullName | Select-Object -First 1)
151+
152+
153+
if ((!(Test-Path -Path $CakePath -PathType Container)) -or (!(Test-Path $CakeExePath -PathType Leaf))) {
154+
155+
if ((![string]::IsNullOrEmpty($CakeExePath)) -and (Test-Path $CakeExePath -PathType Leaf))
156+
{
157+
& dotnet tool uninstall --tool-path $ToolPath Cake.Tool
158+
}
159+
160+
& dotnet tool install --tool-path $ToolPath --version $CakeVersion Cake.Tool
161+
if ($LASTEXITCODE -ne 0)
162+
{
163+
'Failed to install cake'
164+
exit 1
165+
}
166+
$CakeExePath = (Get-ChildItem -Path $ToolPath -Filter "dotnet-cake*" -File| ForEach-Object FullName | Select-Object -First 1)
167+
}
147168
}
148169

149170
# ###########################################################################
@@ -162,8 +183,11 @@ $Arguments = @{
162183
# Start Cake
163184
Write-Host "Running build script..."
164185

165-
$Cmd = "$CakeInstallPath/dotnet-cake $Script $Arguments"
166-
Invoke-Expression "& $Cmd"
186+
& "$CakeExePath" $Script --bootstrap
187+
if ($LASTEXITCODE -eq 0)
188+
{
189+
& "$CakeExePath" $Script $Arguments
190+
}
167191

168192
if ($env:APPVEYOR) {
169193
$host.SetShouldExit($LASTEXITCODE)

‎build/tmpl/jobs.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
parameters:
2+
name: '' # defaults for any parameters that aren't specified
3+
vmImage: ''
4+
installRuby: 'true'
5+
jobs:
6+
- job: ${{ parameters.name }}
7+
pool:
8+
vmImage: ${{ parameters.vmImage }}
9+
steps:
10+
- task: DotNetCoreInstaller@0
11+
displayName: 'Use .NET Core sdk $(DOTNET_SDK_VERSION)'
12+
inputs:
13+
version: $(DOTNET_SDK_VERSION)
14+
packageType: $(DOTNET_PACKAGE_TYPE)
15+
- ${{ if eq(parameters.installRuby, 'true') }}:
16+
- task: UseRubyVersion@0
17+
inputs:
18+
versionSpec: $(RUBY_VERSION)
19+
addToPath: true # Optional
20+
- powershell: ./build.ps1 -script build.cake -target Default
21+
displayName: 'Cake build'

‎build/utils.cake

-11
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ FilePath FindToolInPath(string tool)
88
return paths.Select(path => new DirectoryPath(path).CombineWithFilePath(tool)).FirstOrDefault(filePath => FileExists(filePath.FullPath));
99
}
1010

11-
void FixForMono(Cake.Core.Tooling.ToolSettings toolSettings, string toolExe)
12-
{
13-
if (IsRunningOnUnix())
14-
{
15-
var toolPath = Context.Tools.Resolve(toolExe);
16-
toolSettings.ToolPath = FindToolInPath("mono");
17-
toolSettings.ArgumentCustomization = args => toolPath.FullPath + " " + args.Render();
18-
}
19-
}
20-
2111
DirectoryPath HomePath()
2212
{
2313
return IsRunningOnWindows()
@@ -107,7 +97,6 @@ void ILRepackGitVersionExe(bool includeLibGit2Sharp, DirectoryPath target, Direc
10797
settings.Libs = new List<DirectoryPath> { libFolder };
10898
}
10999

110-
FixForMono(settings, "ILRepack.exe");
111100
ILRepack(outFilePath, targetPath, sourceFiles, settings);
112101

113102
CopyFileToDirectory("./LICENSE", ilMergeDir);

‎src/GitVersion.sln.DotSettings

+1
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ II.2.12 &lt;HandlesEvent /&gt;&#xD;
549549
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
550550
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
551551
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
552+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
552553
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
553554
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAlwaysTreatStructAsNotReorderableMigration/@EntryIndexedValue">True</s:Boolean>
554555
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>

‎src/GitVersionTfsTask/package-lock.json

+13-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "2.1.500"
3+
"version": "2.1.503"
44
}
55
}

0 commit comments

Comments
 (0)
Please sign in to comment.