Skip to content
This repository was archived by the owner on Oct 18, 2018. It is now read-only.

Commit 8fd6124

Browse files
author
Nate McMaster
committed
Merge branch 'release/2.0'
2 parents b1f55ff + 93f2e99 commit 8fd6124

File tree

4 files changed

+156
-2
lines changed

4 files changed

+156
-2
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ node_modules
2222
.deps
2323
global.json
2424
msbuild.ProjectImports.zip
25+
.dotnet/
26+
.tools/

build/RuntimeStoreInstaller.targets

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
<TimestampFreeLinuxRSArchive>$(TimestampFreeRSArchivePrefix)linux-x64.patch.tar.gz</TimestampFreeLinuxRSArchive>
3232
</PropertyGroup>
3333

34-
<Target Name="BuildInstallers" DependsOnTargets="GenerateTargzs;GenerateRpms;GenerateDebs;GenerateRelabledInstallers" />
34+
<Target Name="BuildInstallers" DependsOnTargets="GenerateRuntimeVersionFile;GenerateTargzs;GenerateRpms;GenerateDebs;GenerateRelabledInstallers" />
35+
36+
<Target Name="GenerateRuntimeVersionFile">
37+
<WriteLinesToFile File="$(_InstallersOutputDir)runtime.version" Lines="$(MicrosoftNETCoreApp20PackageVersion)" Overwrite="true" />
38+
</Target>
3539

3640
<Target Name="_EnsureInstallerPrerequisites">
3741
<MakeDir Directories="$(_InstallersOutputDir)" />

scripts/UploadBlobs.ps1

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<#
2+
.SYNOPSIS
3+
Deploys a build to an Azure blob store
4+
5+
.PARAMETER AccountName
6+
The account name for the Azure account
7+
8+
.PARAMETER AccountKey
9+
The account key for the Azure account
10+
11+
.PARAMETER BuildNumber
12+
The build number of the current build
13+
14+
.PARAMETER BaseFeedUrl
15+
The base URI of the package feed (may be different than blobBaseUrl for private-only blobs)
16+
17+
.PARAMETER ContainerName
18+
The container name. Defaults to 'dotnet'
19+
20+
.PARAMETER ArtifactsPath
21+
The path to the build outputs
22+
#>
23+
[CmdletBinding(SupportsShouldProcess = $true)]
24+
param(
25+
[Parameter(Mandatory = $true)]
26+
$AccountName,
27+
[Parameter(Mandatory = $true)]
28+
$AccountKey,
29+
[Parameter(Mandatory = $true)]
30+
$BuildNumber,
31+
[Parameter(Mandatory = $true)]
32+
$ArtifactsPath,
33+
$BaseBlobFeedUrl,
34+
$ContainerName = 'dotnet'
35+
)
36+
37+
$ErrorActionPreference = 'Stop'
38+
Set-StrictMode -Version 1
39+
40+
Import-Module -Scope Local "$PSScriptRoot/common.psm1"
41+
42+
if (!(Get-Command 'az' -ErrorAction Ignore)) {
43+
Write-Error 'Missing required command: az. Please install the Azure CLI and ensure it is available on PATH.'
44+
}
45+
46+
$repoRoot = Resolve-Path "$PSScriptRoot/.."
47+
48+
$sleetVersion = '2.3.25'
49+
$sleet = "$repoRoot/.tools/sleet.$sleetVersion/tools/sleet.exe"
50+
51+
if (-not (Test-Path $sleet)) {
52+
mkdir "$repoRoot/.tools/sleet.$sleetVersion" -ErrorAction Ignore | Out-Null
53+
$installScriptPath = "$repoRoot/.dotnet/dotnet-install.ps1"
54+
Invoke-WebRequest -UseBasicParsing -OutFile "$repoRoot/.tools/sleet.$sleetVersion.zip" https://www.nuget.org/api/v2/package/Sleet/$sleetVersion
55+
Expand-Archive "$repoRoot/.tools/sleet.$sleetVersion.zip" -DestinationPath "$repoRoot/.tools/sleet.$sleetVersion"
56+
}
57+
58+
[xml] $versionProps = Get-Content "$repoRoot/version.props"
59+
$props = $versionProps.Project.PropertyGroup
60+
$VersionPrefix = "$($props.AspNetCoreMajorVersion).$($props.AspNetCoreMinorVersion).$($props.AspNetCorePatchVersion)"
61+
62+
$blobFolder = "$ContainerName/aspnetcore/store/$VersionPrefix-$BuildNumber"
63+
$packagesFolder = "$blobFolder/packages/"
64+
65+
$blobBaseUrl = "https://$AccountName.blob.core.windows.net/$blobFolder"
66+
$packageBlobUrl = "https://$AccountName.blob.core.windows.net/$packagesFolder"
67+
68+
if (-not $BaseBlobFeedUrl) {
69+
$BaseBlobFeedUrl = "https://$AccountName.blob.core.windows.net/$packagesFolder"
70+
}
71+
else {
72+
$BaseBlobFeedUrl = "$BaseBlobFeedUrl/$packagesFolder"
73+
}
74+
75+
$packageGlobPath = "$ArtifactsPath/packages/**/*.nupkg"
76+
$globs = (
77+
@{
78+
basePath = "$ArtifactsPath/lzma"
79+
pattern = "*"
80+
destination = $blobFolder
81+
},
82+
@{
83+
basePath = "$ArtifactsPath/installers"
84+
pattern = "*"
85+
destination = $blobFolder
86+
})
87+
88+
$sleetConfigObj = @{
89+
sources = @(
90+
@{
91+
name = "feed"
92+
type = "azure"
93+
path = $packageBlobUrl
94+
baseURI = $BaseBlobFeedUrl
95+
container = $ContainerName
96+
connectionString = "DefaultEndpointsProtocol=https;AccountName=$AccountName;AccountKey=$AccountKey"
97+
})
98+
}
99+
100+
$sleetConfig = "$repoRoot/.tools/sleet.json"
101+
$sleetConfigObj | ConvertTo-Json | Set-Content -Path $sleetConfig -Encoding Ascii
102+
if ($PSCmdlet.ShouldProcess("Initialize remote feed in $packageBlobUrl")) {
103+
Invoke-Block { & $sleet init --config $sleetConfig --verbose }
104+
}
105+
106+
Get-ChildItem -Recurse $packageGlobPath `
107+
| split-path -parent `
108+
| select -Unique `
109+
| % {
110+
if ($PSCmdlet.ShouldProcess("Push packages in $_ to $packageBlobUrl")) {
111+
Invoke-Block { & $sleet push --verbose --config $sleetConfig --source feed --force $_ }
112+
}
113+
}
114+
115+
[string[]] $otherArgs = @()
116+
117+
if ($VerbosePreference) {
118+
$otherArgs += '--verbose'
119+
}
120+
121+
if ($WhatIfPreference) {
122+
$otherArgs += '--dryrun'
123+
}
124+
125+
$globs | ForEach-Object {
126+
$pattern = $_.pattern
127+
$basePath = $_.basePath
128+
$destination = $_.destination
129+
if (!(Get-ChildItem -Recurse "$basePath/$pattern" -ErrorAction Ignore)) {
130+
Write-Warning "Expected files in $basePath/$pattern but found none"
131+
}
132+
133+
Invoke-Block { & az storage blob upload-batch `
134+
--account-name $AccountName `
135+
--account-key $AccountKey `
136+
--verbose `
137+
--pattern $pattern `
138+
--destination $destination.TrimEnd('/') `
139+
--source $basePath `
140+
--no-progress `
141+
@otherArgs
142+
}
143+
}
144+
145+
Write-Host -f green "Done!"

scripts/common.psm1

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ function Invoke-Block([scriptblock]$cmd) {
1515
# - $?: did the powershell script block throw an error
1616
# - $lastexitcode: did a windows command executed by the script block end in error
1717
if ((-not $?) -or ($lastexitcode -ne 0)) {
18-
Write-Warning $error[0]
18+
if ($error -ne $null)
19+
{
20+
Write-Warning $error[0]
21+
}
1922
throw "Command failed to execute: $cmd"
2023
}
2124
}

0 commit comments

Comments
 (0)