diff --git a/.vsts-ci.yml b/.vsts-ci.yml
index 05e608cd5..7cbab6ffd 100644
--- a/.vsts-ci.yml
+++ b/.vsts-ci.yml
@@ -301,4 +301,5 @@ stages:
/p:DotNetPublishSdkAssetsBlobFeedKey=$(dotnetcli-storage-key)
/p:DotnetPublishChecksumsBlobFeedUrl=https://dotnetclichecksums.blob.core.windows.net/dotnet/index.json
/p:DotNetPublishChecksumsBlobFeedKey=$(dotnetclichecksums-storage-key)
+ /p:SourceBranch=$(BUILD.SOURCEBRANCH)
displayName: Copy to latest
diff --git a/src/CopyToLatest/CopyToLatest.csproj b/src/CopyToLatest/CopyToLatest.csproj
index 21a9eb7bb..a61ea4a61 100644
--- a/src/CopyToLatest/CopyToLatest.csproj
+++ b/src/CopyToLatest/CopyToLatest.csproj
@@ -3,12 +3,12 @@
$(CoreSdkTargetFramework)
true
false
+ $(SourceBranch.Replace('refs/heads/', ''))
-
-
+
\ No newline at end of file
diff --git a/src/CopyToLatest/targets/BranchInfo.props b/src/CopyToLatest/targets/BranchInfo.props
deleted file mode 100644
index 9bd214aa9..000000000
--- a/src/CopyToLatest/targets/BranchInfo.props
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- master
-
-
diff --git a/src/core-sdk-tasks/CopyBlobsToLatest.cs b/src/core-sdk-tasks/CopyBlobsToLatest.cs
index 734898a73..a62000ba7 100644
--- a/src/core-sdk-tasks/CopyBlobsToLatest.cs
+++ b/src/core-sdk-tasks/CopyBlobsToLatest.cs
@@ -64,6 +64,11 @@ namespace Microsoft.DotNet.Cli.Build
public override bool Execute()
{
+ if (!(Channel.Equals("master") || Channel.Equals("main") || Channel.StartsWith("release")))
+ {
+ return true; // Skip copy to latest, we don't want to publish to arbitrary places
+ }
+
string targetFolder = $"{AzurePublisher.Product.Sdk}/{Channel}";
string targetVersionFile = $"{targetFolder}/{CommitHash}";