Changing the lzma generation to first trying to download it from blob. If that fails, generate it. And if we generate it and we are uploading things to azure, upload it as well.

This commit is contained in:
Livar Cunha 2016-11-08 15:14:47 -08:00
parent ccc4968bc3
commit 087852b1b8
3 changed files with 63 additions and 17 deletions

View file

@ -19,7 +19,7 @@
SetupStage;
CompileStage;
BuildProjectsForNuGetPackages;
GenerateNuGetPackagesArchive" />
GetNuGetPackagesArchive" />
<Target Name="SetupStage"
DependsOnTargets="Prepare">

View file

@ -1,9 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="GetNuGetPackagesArchive"
DependsOnTargets="SetupNuGetPackagesArchiveInputsOutputs;
DownloadNuGetPackagesArchive;
GenerateNuGetPackagesArchive;
UploadNuGetPackagesArchiveToAzure"
Inputs="$(IntermediateArchive)"
Outputs="$(FinalArchive)">
<Copy SourceFiles="$(IntermediateArchive)" DestinationFiles="$(FinalArchive)" />
</Target>
<Target Name="UploadNuGetPackagesArchiveToAzure"
DependsOnTargets="SetupNuGetPackagesArchiveInputsOutputs;
SetupAzureBlobInformation;
GenerateNuGetPackagesArchive"
Condition=" 'UploadNuGetPackagesArchiveToAzure' == 'true' And '$(PUBLISH_TO_AZURE_BLOB)' != '' ">
<ItemGroup>
<NuGetPackagesArchiveToUpload Include="$(IntermediateArchive)" />
</ItemGroup>
<ItemGroup>
<NuGetPackagesArchiveToUpload>
<RelativeBlobPath>$(CoreSetupChannel)/Binaries/$(SharedFrameworkVersion)/$([System.String]::Copy('%(Filename)%(Extension)').Replace('\' ,'/'))</RelativeBlobPath>
</NuGetPackagesArchiveToUpload>
</ItemGroup>
<UploadToAzure
AccountKey="$(ArtifactCloudDropAccessToken)"
AccountName="$(ArtifactCloudDropAccountName)"
ContainerName="$(ArtifactContainerName)"
Items="@(NuGetPackagesArchiveToUpload)"
Overwrite="false"
ContinueOnError="WarnAndContinue" />
</Target>
<Target Name="DownloadNuGetPackagesArchive"
DependsOnTargets="SetupNuGetPackagesArchiveInputsOutputs"
Inputs="$(IntermediateArchive)"
Outputs="$(IntermediateArchive)">
<DownloadFile Uri="$(NugetPackagesArchiveBlobUrl)"
DestinationPath="$(IntermediateArchive)"
ContinueOnError="WarnAndContinue" />
</Target>
<Target Name="GenerateNuGetPackagesArchive"
DependsOnTargets="SetupNuGetPackagesArchiveInputsOutputs"
Inputs="@(GenerateNuGetPackagesArchiveInputs)"
Outputs="$(FinalArchive)">
Inputs="$(IntermediateArchive)"
Outputs="$(IntermediateArchive)">
<PropertyGroup>
<UploadNuGetPackagesArchiveToAzure>true</UploadNuGetPackagesArchiveToAzure>
</PropertyGroup>
<ItemGroup>
<FilesToClean Include="$(NuGetPackagesArchiveProject)/**/*" />
<FilesToClean Include="$(NuGetPackagesArchiveFolder)/**/*" />
@ -31,28 +78,18 @@
Configuration="$(Configuration)" />
<Exec Command="$(DotnetStage0) $(ArchiverDll) -a $(IntermediateArchive) $(NuGetPackagesArchiveFolder)" />
<Copy SourceFiles="$(IntermediateArchive)" DestinationFiles="$(FinalArchive)" />
</Target>
<Target Name="SetupNuGetPackagesArchiveInputsOutputs"
DependsOnTargets="Prepare;SetupStage">
<PropertyGroup>
<NugetPackagesArchiveName>nuGetPackagesArchive.$(SharedFrameworkVersion).lzma</NugetPackagesArchiveName>
<NuGetPackagesArchiveProject>$(IntermediateDirectory)/NuGetPackagesArchiveProject</NuGetPackagesArchiveProject>
<NuGetPackagesArchiveFolder>$(IntermediateDirectory)/NuGetPackagesArchiveFolder</NuGetPackagesArchiveFolder>
<ArchiverDll>$(ToolsOutputDirectory)/Archiver.dll</ArchiverDll>
<IntermediateArchive>$(IntermediateDirectory)/nuGetPackagesArchive.lzma</IntermediateArchive>
<IntermediateArchive>$(IntermediateDirectory)/$(NugetPackagesArchiveName)</IntermediateArchive>
<FinalArchive>$(Stage2Directory)/sdk/$(SdkVersion)/nuGetPackagesArchive.lzma</FinalArchive>
<NugetPackagesArchiveBlobUrl>$(SharedFrameworkArchiveBlobRootUrl)/$(NugetPackagesArchiveName)</NugetPackagesArchiveBlobUrl>
</PropertyGroup>
<ItemGroup>
<GenerateNuGetPackagesArchiveInputs Include="$(_DotNetNewFolder)/CSharp_Console/**/*" />
<GenerateNuGetPackagesArchiveInputs Include="$(SrcDirectory)/dotnet-archive/**/*"
Exclude="$(SrcDirectory)/dotnet-archive/**/bin/**/*;
$(SrcDirectory)/dotnet-archive/**/obj/**/*" />
<GenerateNuGetPackagesArchiveInputs Include="$(SrcDirectory)/Microsoft.DotNet.Archive/**/*"
Exclude="$(SrcDirectory)/Microsoft.DotNet.Archive/**/bin/**/*;
$(SrcDirectory)/Microsoft.DotNet.Archive/**/obj/**/*" />
</ItemGroup>
</Target>
</Project>

View file

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;
using System.Net.Http;
using Microsoft.Build.Framework;
@ -35,7 +36,15 @@ namespace Microsoft.DotNet.Cli.Build
using (var outStream = File.Create(DestinationPath))
{
getTask.Result.CopyTo(outStream);
try
{
getTask.Result.CopyTo(outStream);
}
catch (Exception)
{
File.Delete(DestinationPath);
throw;
}
}
}