Merge pull request #1466 from dotnet/piotrpMSFT/dotnet-hello-cleaner
dotnet-hello package cleanup and no-cache
This commit is contained in:
commit
8cc5bd7011
3 changed files with 44 additions and 16 deletions
|
@ -80,7 +80,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
return c.Success();
|
return c.Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Target]
|
[Target(nameof(CleanTestPackages))]
|
||||||
public static BuildTargetResult BuildTestAssetPackages(BuildTargetContext c)
|
public static BuildTargetResult BuildTestAssetPackages(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
var dotnet = DotNetCli.Stage2;
|
var dotnet = DotNetCli.Stage2;
|
||||||
|
@ -100,6 +100,14 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
|
|
||||||
return c.Success();
|
return c.Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Target]
|
||||||
|
public static BuildTargetResult CleanTestPackages(BuildTargetContext c)
|
||||||
|
{
|
||||||
|
Rmdir(Path.Combine(Dirs.NuGetPackages, "dotnet-hello"));
|
||||||
|
|
||||||
|
return c.Success();
|
||||||
|
}
|
||||||
|
|
||||||
[Target]
|
[Target]
|
||||||
public static BuildTargetResult BuildTestAssetProjects(BuildTargetContext c)
|
public static BuildTargetResult BuildTestAssetProjects(BuildTargetContext c)
|
||||||
|
|
|
@ -49,7 +49,7 @@ function CheckRequiredVariables
|
||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
|
|
||||||
function UploadFile($Blob, $Uploadfile)
|
function UploadFile($Blob, $Uploadfile, $PreventCaching = $false)
|
||||||
{
|
{
|
||||||
Write-Host "Uploading $Uploadfile to dotnet feed."
|
Write-Host "Uploading $Uploadfile to dotnet feed."
|
||||||
|
|
||||||
|
@ -57,10 +57,17 @@ function UploadFile($Blob, $Uploadfile)
|
||||||
{
|
{
|
||||||
$env:HOME=Get-Location
|
$env:HOME=Get-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$properties = ""
|
||||||
|
|
||||||
|
if($PreventCaching)
|
||||||
|
{
|
||||||
|
$properties = "--properties cacheControl=no-cache"
|
||||||
|
}
|
||||||
|
|
||||||
# use azure cli to upload to blob storage. We cannot use Invoke-WebRequest to do this becuase azure has a max limit of 64mb that can be uploaded using REST
|
# use azure cli to upload to blob storage. We cannot use Invoke-WebRequest to do this becuase azure has a max limit of 64mb that can be uploaded using REST
|
||||||
#$statusCode = (Invoke-WebRequest -URI "$Upload_URI" -Method PUT -Headers @{"x-ms-blob-type"="BlockBlob"; "x-ms-date"="2015-10-23";"x-ms-version"="2013-08-15"} -InFile $Uploadfile).StatusCode
|
#$statusCode = (Invoke-WebRequest -URI "$Upload_URI" -Method PUT -Headers @{"x-ms-blob-type"="BlockBlob"; "x-ms-date"="2015-10-23";"x-ms-version"="2013-08-15"} -InFile $Uploadfile).StatusCode
|
||||||
azure storage blob upload --quiet --container $env:STORAGE_CONTAINER --blob $Blob --blobtype block --connection-string "$env:CONNECTION_STRING" --file $Uploadfile | Out-Host
|
azure storage blob upload --quiet $properties --container $env:STORAGE_CONTAINER --blob $Blob --blobtype block --connection-string "$env:CONNECTION_STRING" --file $Uploadfile | Out-Host
|
||||||
|
|
||||||
if($?)
|
if($?)
|
||||||
{
|
{
|
||||||
|
@ -88,7 +95,7 @@ function UploadBinaries($zipFile)
|
||||||
Write-Host "Updating the latest dotnet binaries for windows.."
|
Write-Host "Updating the latest dotnet binaries for windows.."
|
||||||
$zipBlobLatest = "$env:CHANNEL/Binaries/Latest/dotnet-win-x64.latest.zip"
|
$zipBlobLatest = "$env:CHANNEL/Binaries/Latest/dotnet-win-x64.latest.zip"
|
||||||
|
|
||||||
if(-Not (UploadFile $zipBlobLatest $zipFile))
|
if(-Not (UploadFile $zipBlobLatest $zipFile $true))
|
||||||
{
|
{
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
@ -102,7 +109,7 @@ function UploadBinaries($zipFile)
|
||||||
# upload the index file
|
# upload the index file
|
||||||
$indexBlob = "$env:CHANNEL/dnvm/latest.win.index"
|
$indexBlob = "$env:CHANNEL/dnvm/latest.win.index"
|
||||||
|
|
||||||
if(-Not (UploadFile $indexBlob $indexFile))
|
if(-Not (UploadFile $indexBlob $indexFile $true))
|
||||||
{
|
{
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
@ -111,7 +118,7 @@ function UploadBinaries($zipFile)
|
||||||
$versionFile = Convert-Path $PSScriptRoot\..\..\artifacts\$env:RID\stage2\.version
|
$versionFile = Convert-Path $PSScriptRoot\..\..\artifacts\$env:RID\stage2\.version
|
||||||
$versionBlob = "$env:CHANNEL/dnvm/latest.win.version"
|
$versionBlob = "$env:CHANNEL/dnvm/latest.win.version"
|
||||||
|
|
||||||
if(-Not (UploadFile $versionBlob $versionFile))
|
if(-Not (UploadFile $versionBlob $versionFile $true))
|
||||||
{
|
{
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
@ -132,7 +139,7 @@ function UploadInstallers($installerFile)
|
||||||
Write-Host "Updating the latest dotnet installer for windows.."
|
Write-Host "Updating the latest dotnet installer for windows.."
|
||||||
$installerBlobLatest = "$env:CHANNEL/Installers/Latest/dotnet-win-x64.latest.exe"
|
$installerBlobLatest = "$env:CHANNEL/Installers/Latest/dotnet-win-x64.latest.exe"
|
||||||
|
|
||||||
if(-Not (UploadFile $installerBlobLatest $installerFile))
|
if(-Not (UploadFile $installerBlobLatest $installerFile $true))
|
||||||
{
|
{
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
@ -145,10 +152,16 @@ function UploadVersionBadge($badgeFile)
|
||||||
$fileName = "windows_$($env:CONFIGURATION)_$([System.IO.Path]::GetFileName($badgeFile))"
|
$fileName = "windows_$($env:CONFIGURATION)_$([System.IO.Path]::GetFileName($badgeFile))"
|
||||||
|
|
||||||
Write-Host "Uploading the version badge to Latest"
|
Write-Host "Uploading the version badge to Latest"
|
||||||
UploadFile "$env:CHANNEL/Binaries/Latest/$fileName" $badgeFile
|
if(-Not (UploadFile "$env:CHANNEL/Binaries/Latest/$fileName" $badgeFile $true))
|
||||||
|
{
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host "Uploading the version badge to $env:DOTNET_CLI_VERSION"
|
Write-Host "Uploading the version badge to $env:DOTNET_CLI_VERSION"
|
||||||
UploadFile "$env:CHANNEL/Binaries/$env:DOTNET_CLI_VERSION/$fileName" $badgeFile
|
if(-Not (UploadFile "$env:CHANNEL/Binaries/$env:DOTNET_CLI_VERSION/$fileName" $badgeFile)
|
||||||
|
{
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,12 +93,19 @@ validate_env_variables(){
|
||||||
upload_file_to_blob_storage_azure_cli(){
|
upload_file_to_blob_storage_azure_cli(){
|
||||||
local blob=$1
|
local blob=$1
|
||||||
local file=$2
|
local file=$2
|
||||||
|
local preventCaching=${3:false}
|
||||||
|
|
||||||
header "Uploading $file to blob storage"
|
header "Uploading $file to blob storage"
|
||||||
|
|
||||||
|
local properties=""
|
||||||
|
|
||||||
|
if $preventCaching ; then
|
||||||
|
$properties="--properties cacheControl=no-cache"
|
||||||
|
fi
|
||||||
|
|
||||||
# use azure cli to upload to blob storage. We cannot use curl to do this becuase azure has a max limit of 64mb that can be uploaded using REST
|
# use azure cli to upload to blob storage. We cannot use curl to do this becuase azure has a max limit of 64mb that can be uploaded using REST
|
||||||
# statusCode=$(curl -s -w "%{http_code}" -L -H "x-ms-blob-type: BlockBlob" -H "x-ms-date: 2015-10-21" -H "x-ms-version: 2013-08-15" $upload_URL -T $file)
|
# statusCode=$(curl -s -w "%{http_code}" -L -H "x-ms-blob-type: BlockBlob" -H "x-ms-date: 2015-10-21" -H "x-ms-version: 2013-08-15" $upload_URL -T $file)
|
||||||
azure storage blob upload --quiet --container $STORAGE_CONTAINER --blob $blob --blobtype block --connection-string "$CONNECTION_STRING" --file $file
|
azure storage blob upload --quiet $properties --container $STORAGE_CONTAINER --blob $blob --blobtype block --connection-string "$CONNECTION_STRING" --file $file
|
||||||
result=$?
|
result=$?
|
||||||
|
|
||||||
if [ "$result" -eq "0" ]; then
|
if [ "$result" -eq "0" ]; then
|
||||||
|
@ -141,7 +148,7 @@ upload_binaries_to_blob_storage(){
|
||||||
echo "Updating the latest dotnet binaries.."
|
echo "Updating the latest dotnet binaries.."
|
||||||
local latestblob="$CHANNEL/Binaries/Latest/dotnet-$OSNAME-x64.latest.tar.gz"
|
local latestblob="$CHANNEL/Binaries/Latest/dotnet-$OSNAME-x64.latest.tar.gz"
|
||||||
|
|
||||||
if ! upload_file_to_blob_storage_azure_cli $latestblob $tarfile; then
|
if ! upload_file_to_blob_storage_azure_cli $latestblob $tarfile true; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -149,14 +156,14 @@ upload_binaries_to_blob_storage(){
|
||||||
local indexContent="Binaries/$DOTNET_CLI_VERSION/$filename"
|
local indexContent="Binaries/$DOTNET_CLI_VERSION/$filename"
|
||||||
local indexfile="latest.$OSNAME.index"
|
local indexfile="latest.$OSNAME.index"
|
||||||
local index_URL="https://$STORAGE_ACCOUNT.blob.core.windows.net/$STORAGE_CONTAINER/$CHANNEL/dnvm/$indexfile$SASTOKEN"
|
local index_URL="https://$STORAGE_ACCOUNT.blob.core.windows.net/$STORAGE_CONTAINER/$CHANNEL/dnvm/$indexfile$SASTOKEN"
|
||||||
update_file_in_blob_storage $index_URL $indexfile $indexContent
|
update_file_in_blob_storage $index_URL $indexfile $indexContent true
|
||||||
|
|
||||||
# update the version file
|
# update the version file
|
||||||
# the "@" prefix tells curl to upload the content of the file
|
# the "@" prefix tells curl to upload the content of the file
|
||||||
local versionContent="@$REPOROOT/artifacts/$RID/stage2/.version"
|
local versionContent="@$REPOROOT/artifacts/$RID/stage2/.version"
|
||||||
local versionfile="latest.$OSNAME.version"
|
local versionfile="latest.$OSNAME.version"
|
||||||
local version_URL="https://$STORAGE_ACCOUNT.blob.core.windows.net/$STORAGE_CONTAINER/$CHANNEL/dnvm/$versionfile$SASTOKEN"
|
local version_URL="https://$STORAGE_ACCOUNT.blob.core.windows.net/$STORAGE_CONTAINER/$CHANNEL/dnvm/$versionfile$SASTOKEN"
|
||||||
update_file_in_blob_storage $version_URL $versionfile $versionContent
|
update_file_in_blob_storage $version_URL $versionfile $versionContent true
|
||||||
|
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
@ -175,7 +182,7 @@ upload_installers_to_blob_storage(){
|
||||||
local extension="${filename##*.}"
|
local extension="${filename##*.}"
|
||||||
local latestblob="$CHANNEL/Installers/Latest/dotnet-$OSNAME-x64.latest.$extension"
|
local latestblob="$CHANNEL/Installers/Latest/dotnet-$OSNAME-x64.latest.$extension"
|
||||||
|
|
||||||
if ! upload_file_to_blob_storage_azure_cli $latestblob $installfile; then
|
if ! upload_file_to_blob_storage_azure_cli $latestblob $installfile true; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -194,7 +201,7 @@ upload_version_badge(){
|
||||||
local badgefile=$1
|
local badgefile=$1
|
||||||
local filename="${OSNAME}_${CONFIGURATION}_$(basename $badgefile)"
|
local filename="${OSNAME}_${CONFIGURATION}_$(basename $badgefile)"
|
||||||
echo "Uploading the version badge to Latest"
|
echo "Uploading the version badge to Latest"
|
||||||
upload_file_to_blob_storage_azure_cli "$CHANNEL/Binaries/Latest/$filename" $badgefile
|
upload_file_to_blob_storage_azure_cli "$CHANNEL/Binaries/Latest/$filename" $badgefile true
|
||||||
|
|
||||||
echo "Uploading the version badge to $DOTNET_CLI_VERSION"
|
echo "Uploading the version badge to $DOTNET_CLI_VERSION"
|
||||||
upload_file_to_blob_storage_azure_cli "$CHANNEL/Binaries/$DOTNET_CLI_VERSION/$filename" $badgefile
|
upload_file_to_blob_storage_azure_cli "$CHANNEL/Binaries/$DOTNET_CLI_VERSION/$filename" $badgefile
|
||||||
|
|
Loading…
Reference in a new issue