<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <PropertyGroup>
      <FinalArchive>$(SdkOutputDirectory)/nuGetPackagesArchive.lzma</FinalArchive>
      <PackagesArchive>$(PackagesDirectory)/nuGetPackagesArchive.lzma</PackagesArchive>
      <NugetPackagesArchiveName>nuGetPackagesArchive-$(AspNetCoreVersion).lzma</NugetPackagesArchiveName>
      <IntermediateArchive>$(IntermediateDirectory)/$(NugetPackagesArchiveName)</IntermediateArchive>
      <NugetPackagesArchiveBlobUrl>$(AspNetCoreSharedFxRootUrl)$(AspNetCoreVersion)/$(NugetPackagesArchiveName)</NugetPackagesArchiveBlobUrl>
    </PropertyGroup>

    <Target Name="GetNuGetPackagesArchive"
            Inputs="$(IntermediateArchive)"
            Outputs="$(FinalArchive)"
            Condition=" '$(IncludeNuGetPackageArchive)' == 'true' ">
      <DownloadFile Uri="$(NugetPackagesArchiveBlobUrl)$(CoreSetupBlobAccessTokenParam)"
                    DestinationPath="$(IntermediateArchive)"
                    ContinueOnError="WarnAndContinue" />

      <Copy SourceFiles="$(IntermediateArchive)" DestinationFiles="$(FinalArchive)" />
      <Copy SourceFiles="$(IntermediateArchive)" DestinationFiles="$(PackagesArchive)" />
    </Target>
</Project>
