From 087852b1b8df5fa8735b01e5e49c7e06e904f7c6 Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Tue, 8 Nov 2016 15:14:47 -0800 Subject: [PATCH 1/2] 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. --- build/Microsoft.DotNet.Cli.Compile.targets | 2 +- .../Microsoft.DotNet.Cli.LzmaArchive.targets | 67 ++++++++++++++----- .../dotnet-cli-build/DownloadFile.cs | 11 ++- 3 files changed, 63 insertions(+), 17 deletions(-) diff --git a/build/Microsoft.DotNet.Cli.Compile.targets b/build/Microsoft.DotNet.Cli.Compile.targets index ed53e1d0e..ca95e66f4 100644 --- a/build/Microsoft.DotNet.Cli.Compile.targets +++ b/build/Microsoft.DotNet.Cli.Compile.targets @@ -19,7 +19,7 @@ SetupStage; CompileStage; BuildProjectsForNuGetPackages; - GenerateNuGetPackagesArchive" /> + GetNuGetPackagesArchive" /> diff --git a/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets b/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets index 04620d875..acb9e16c8 100644 --- a/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets +++ b/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets @@ -1,9 +1,56 @@ + + + + + + + + + + + + $(CoreSetupChannel)/Binaries/$(SharedFrameworkVersion)/$([System.String]::Copy('%(Filename)%(Extension)').Replace('\' ,'/')) + + + + + + + + + + + Inputs="$(IntermediateArchive)" + Outputs="$(IntermediateArchive)"> + + true + + @@ -31,28 +78,18 @@ Configuration="$(Configuration)" /> - - + nuGetPackagesArchive.$(SharedFrameworkVersion).lzma $(IntermediateDirectory)/NuGetPackagesArchiveProject $(IntermediateDirectory)/NuGetPackagesArchiveFolder $(ToolsOutputDirectory)/Archiver.dll - $(IntermediateDirectory)/nuGetPackagesArchive.lzma + $(IntermediateDirectory)/$(NugetPackagesArchiveName) $(Stage2Directory)/sdk/$(SdkVersion)/nuGetPackagesArchive.lzma + $(SharedFrameworkArchiveBlobRootUrl)/$(NugetPackagesArchiveName) - - - - - - \ No newline at end of file diff --git a/build_projects/dotnet-cli-build/DownloadFile.cs b/build_projects/dotnet-cli-build/DownloadFile.cs index 6c8633f07..98ba97257 100644 --- a/build_projects/dotnet-cli-build/DownloadFile.cs +++ b/build_projects/dotnet-cli-build/DownloadFile.cs @@ -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; + } } } From de0ca4823f422b429b2bab06873e9c3f18a2c5c7 Mon Sep 17 00:00:00 2001 From: Livar Cunha Date: Wed, 9 Nov 2016 10:05:05 -0800 Subject: [PATCH 2/2] Fixing how we clean the file when it fails to download. We were doing it inside the using statement, so it still had a lock to the file and failed to delete it. --- build_projects/dotnet-cli-build/DownloadFile.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build_projects/dotnet-cli-build/DownloadFile.cs b/build_projects/dotnet-cli-build/DownloadFile.cs index 98ba97257..f207a75bf 100644 --- a/build_projects/dotnet-cli-build/DownloadFile.cs +++ b/build_projects/dotnet-cli-build/DownloadFile.cs @@ -34,17 +34,17 @@ namespace Microsoft.DotNet.Cli.Build { var getTask = httpClient.GetStreamAsync(Uri); - using (var outStream = File.Create(DestinationPath)) + try { - try + using (var outStream = File.Create(DestinationPath)) { getTask.Result.CopyTo(outStream); } - catch (Exception) - { - File.Delete(DestinationPath); - throw; - } + } + catch (Exception) + { + File.Delete(DestinationPath); + throw; } }