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

  <Target Name="GatherNupkgsForPublishing">
    <ItemGroup>
      <NupkgsForPublishing Include="$(PackagesDirectory)/Microsoft.DotNet.Cli.Utils.*.nupkg"
                           Exclude="$(PackagesDirectory)/*.symbols.nupkg"
                           Condition=" '$(OS)' == 'Windows_NT' And '$(Architecture)' == 'x64' " >
        <ManifestArtifactData>NonShipping=true</ManifestArtifactData>
      </NupkgsForPublishing>
      <NupkgsForPublishing Include="$(PackagesDirectory)/Microsoft.DotNet.MSBuildSdkResolver.*.nupkg"
                           Exclude="$(PackagesDirectory)/*.symbols.nupkg"
                           Condition=" '$(OS)' == 'Windows_NT' And '$(Architecture)' == 'x64' " >
        <ManifestArtifactData>NonShipping=true</ManifestArtifactData>
      </NupkgsForPublishing>
    </ItemGroup>

    <ItemGroup>
      <SymbolsNupkgsForPublishing Include="$(PackagesDirectory)/Microsoft.DotNet.MSBuildSdkResolver.*.symbols.nupkg"
                                  Condition=" '$(OS)' == 'Windows_NT' And '$(Architecture)' == 'x64' " />
      <SymbolsNupkgsForPublishing Include="$(PackagesDirectory)/runtime.*.Microsoft.DotNet.SDK.*.symbols.nupkg" />
    </ItemGroup>

    <ItemGroup>
      <AllNupkgsForPublishing Include="@(SymbolsNupkgsForPublishing);@(NupkgsForPublishing)" />
    </ItemGroup>
  </Target>

  <Target Name="PublishNupkgToBlobFeed" Condition=" '$(PUBLISH_NUPKG_TO_BLOB_FEED)' == 'true'" DependsOnTargets="GatherNupkgsForPublishing">
    <Error Condition="'$(BlobFeedCloudDropAccessToken)' == ''" Text="Missing property BlobFeedCloudDropAccessToken." />
    <Error Condition="'$(BlobFeedExpectedURL)' == ''" Text="Missing property BlobFeedExpectedURL." />

    <Message Text="Publish NuPkgs to Blob feed started: $(BlobFeedExpectedURL)" />
    <PushToBlobFeed ExpectedFeedUrl="$(BlobFeedExpectedURL)"
                    AccountKey="$(BlobFeedCloudDropAccessToken)"
                    ItemsToPush="@(AllNupkgsForPublishing)"
                    ManifestBranch="$(BranchName)"
                    ManifestBuildId="$(FullNugetVersion)"
                    ManifestCommit="$(CommitHash)"
                    ManifestName="$(BuildName)"
                    ManifestBuildData="ProductVersion=$(FullNugetVersion)"
                    Overwrite="false"
                    PublishFlatContainer="false"
                    SkipCreateManifest="$(IsNotOrchestratedPublish)" />
  </Target>
</Project>
