Skip to content

Commit 9fea6b6

Browse files
committed
Explicitly define .NET SDK version
1 parent 98906f5 commit 9fea6b6

6 files changed

Lines changed: 77 additions & 64 deletions

File tree

Dibix.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{62C58971
2424
build\dependencies.props = build\dependencies.props
2525
Directory.Build.props = Directory.Build.props
2626
Directory.Build.targets = Directory.Build.targets
27+
global.json = global.json
2728
NuGet.config = NuGet.config
2829
Packages.props = Packages.props
2930
build\release.yml = build\release.yml
@@ -54,6 +55,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "azure-pipeline-templates",
5455
build\azure-pipelines-template\build-dotnet.yml = build\azure-pipelines-template\build-dotnet.yml
5556
build\azure-pipelines-template\build.yml = build\azure-pipelines-template\build.yml
5657
build\azure-pipelines-template\initialize.yml = build\azure-pipelines-template\initialize.yml
58+
build\azure-pipelines-template\install-dotnet-sdk.yml = build\azure-pipelines-template\install-dotnet-sdk.yml
5759
build\azure-pipelines-template\pack-dotnet.yml = build\azure-pipelines-template\pack-dotnet.yml
5860
build\azure-pipelines-template\pack.yml = build\azure-pipelines-template\pack.yml
5961
build\azure-pipelines-template\publish-coverage.yml = build\azure-pipelines-template\publish-coverage.yml
Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
$ErrorActionPreference = Stop
2-
$userSecretsId = "dibix"
3-
4-
#region Functions
5-
function Read-ValueFromUserInput([string] $msg, [string] $currentValue)
6-
{
7-
if ($silent)
8-
{
9-
$currentValue
10-
}
11-
else
12-
{
13-
$prompt = Read-Host "$msg [$($currentValue)]"
14-
($currentValue,$prompt)[[bool]$prompt]
15-
}
16-
}
17-
18-
function Exec($cmd)
19-
{
20-
Invoke-Expression "& $cmd"
21-
22-
if ($LASTEXITCODE -ne 0)
23-
{
24-
throw "Command '$cmd' returned exit code $LASTEXITCODE."
25-
}
26-
}
27-
28-
function Get-Secret($key, $id)
29-
{
30-
$secretsDirectory = & {
31-
if ($IsWindows -ne $False) { Join-Path $env:APPDATA -ChildPath "Microsoft" | Join-Path -ChildPath "UserSecrets" }
32-
else { Join-Path $env:HOME -ChildPath ".microsoft" | Join-Path -ChildPath "usersecrets" }
33-
}
34-
$secretsPath = Join-Path $secretsDirectory -ChildPath "$id" | Join-Path -ChildPath "secrets.json"
35-
if (Test-Path $secretsPath)
36-
{
37-
$secrets = Get-Content $secretsPath | Out-String | ConvertFrom-Json
38-
$secrets.$key
39-
}
40-
}
41-
42-
function Set-Secret($key, $value, $id)
43-
{
44-
Exec "dotnet user-secrets set $key ""$value"" --id $id"
45-
}
46-
#endregion
47-
48-
$connectionStringKey = "Database:ConnectionString"
49-
50-
$connectionString = Get-Secret $connectionStringKey $userSecretsId
51-
$connectionString = Read-ValueFromUserInput "Enter connection string:" $connectionString
52-
1+
$ErrorActionPreference = Stop
2+
$userSecretsId = "dibix"
3+
4+
#region Functions
5+
function Read-ValueFromUserInput([string] $msg, [string] $currentValue)
6+
{
7+
if ($silent)
8+
{
9+
$currentValue
10+
}
11+
else
12+
{
13+
$prompt = Read-Host "$msg [$($currentValue)]"
14+
($currentValue,$prompt)[[bool]$prompt]
15+
}
16+
}
17+
18+
function Exec($cmd)
19+
{
20+
Invoke-Expression "& $cmd"
21+
22+
if ($LASTEXITCODE -ne 0)
23+
{
24+
throw "Command '$cmd' returned exit code $LASTEXITCODE."
25+
}
26+
}
27+
28+
function Get-Secret($key, $id)
29+
{
30+
$secretsDirectory = & {
31+
if ($IsWindows -ne $False) { Join-Path $env:APPDATA -ChildPath "Microsoft" | Join-Path -ChildPath "UserSecrets" }
32+
else { Join-Path $env:HOME -ChildPath ".microsoft" | Join-Path -ChildPath "usersecrets" }
33+
}
34+
$secretsPath = Join-Path $secretsDirectory -ChildPath "$id" | Join-Path -ChildPath "secrets.json"
35+
if (Test-Path $secretsPath)
36+
{
37+
$secrets = Get-Content $secretsPath | Out-String | ConvertFrom-Json
38+
$secrets.$key
39+
}
40+
}
41+
42+
function Set-Secret($key, $value, $id)
43+
{
44+
Exec "dotnet user-secrets set $key ""$value"" --id $id"
45+
}
46+
#endregion
47+
48+
$connectionStringKey = "Database:ConnectionString"
49+
50+
$connectionString = Get-Secret $connectionStringKey $userSecretsId
51+
$connectionString = Read-ValueFromUserInput "Enter connection string:" $connectionString
52+
5353
Set-Secret $connectionStringKey $connectionString $userSecretsId
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
steps:
2+
- template: install-dotnet-sdk.yml
3+
24
#- powershell: (gci env:* | sort-object name) # Print env variables
3-
- task: DotNetCoreCLI@2
4-
displayName: 🤓 Install NBGV
5-
inputs:
6-
command: custom
7-
custom: tool
8-
arguments: install --tool-path $(Agent.TempDirectory) nbgv
5+
- task: DotNetCoreCLI@2
6+
displayName: 🤓 Install NBGV
7+
inputs:
8+
command: custom
9+
custom: tool
10+
arguments: install --tool-path $(Agent.TempDirectory) nbgv
911

10-
- script: $(Agent.TempDirectory)/nbgv cloud
11-
displayName: 🖌️ Update pipeline instance name
12+
- script: $(Agent.TempDirectory)/nbgv cloud
13+
displayName: 🖌️ Update pipeline instance name
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
steps:
2+
- task: UseDotNet@2
3+
displayName: 🧰 Ensure .NET SDK
4+
inputs:
5+
useGlobalJson: true

build/azure-pipelines-template/run.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
- Cobertura
1818

1919
steps:
20-
- task: UseDotNet@2
21-
displayName: 🧰 Ensure .NET SDK 6
22-
inputs:
23-
version: 6.x
20+
- template: install-dotnet-sdk.yml
2421

2522
- template: restore.yml
2623

global.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"sdk": {
3+
"version": "6.0.100",
4+
"rollForward": "latestMinor",
5+
"allowPrerelease": false
6+
}
7+
}

0 commit comments

Comments
 (0)