diff --git a/build/Test.targets b/build/Test.targets
index 9f4ce8778..f9642c6a3 100644
--- a/build/Test.targets
+++ b/build/Test.targets
@@ -10,6 +10,7 @@
$(TestOutputDir)/packages/
$(TestOutputDir)/artifacts/
$(TestOutputDir)/results/
+ $(TestArtifactsDir)/ExternalRestoreSourcesForTestsContainer.txt
+
+
+ $externalRestoreSources$
";
- content = content.Replace("$fullpath$", nugetCache);
+ content = content
+ .Replace("$fullpath$", nugetCache)
+ .Replace("$externalRestoreSources$", externalRestoreSources);
using (var newNuGetConfigStream =
new FileStream(newNuGetConfig.FullName, FileMode.Create, FileAccess.Write))
diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs
index 7de277852..de2af4896 100644
--- a/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs
+++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs
@@ -22,6 +22,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
private string _stage2WithBackwardsCompatibleRuntimesDirectory;
private string _testPackages;
private string _testWorkingFolder;
+ private string _testArtifactsFolder;
public static string RepoRoot
{
@@ -92,6 +93,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
public string Stage2WithBackwardsCompatibleRuntimesDirectory => _stage2WithBackwardsCompatibleRuntimesDirectory;
public string TestPackages => _testPackages;
public string TestWorkingFolder => _testWorkingFolder;
+ public string TestArtifactsFolder => _testArtifactsFolder;
public RepoDirectoriesProvider(
string artifacts = null,
@@ -123,6 +125,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
_testPackages = Path.Combine(_artifacts, "test", "packages");
}
+ _testArtifactsFolder = Path.Combine(_artifacts, "test", "artifacts");
+
_testWorkingFolder = Path.Combine(RepoRoot,
"bin",
(previousStage + 1).ToString(),
diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssetInstanceExtensions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssetInstanceExtensions.cs
new file mode 100644
index 000000000..a1cf95916
--- /dev/null
+++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/TestAssetInstanceExtensions.cs
@@ -0,0 +1,33 @@
+// 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.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+using Microsoft.DotNet.Cli.Utils;
+using Microsoft.DotNet.TestFramework;
+using Microsoft.DotNet.Tools.Common;
+
+namespace Microsoft.DotNet.Tools.Test.Utilities
+{
+ public static class TestAssetInstanceExtensions
+ {
+ public static TestAssetInstance WithNuGetConfigAndExternalRestoreSources(
+ this TestAssetInstance testAssetInstance, string nugetCache)
+ {
+ var externalRestoreSourcesForTests = Path.Combine(
+ new RepoDirectoriesProvider().TestArtifactsFolder, "ExternalRestoreSourcesForTestsContainer.txt");
+ var externalRestoreSources = File.Exists(externalRestoreSourcesForTests) ?
+ File.ReadAllText(externalRestoreSourcesForTests) :
+ string.Empty;
+
+ return testAssetInstance.WithNuGetConfig(nugetCache, externalRestoreSources);
+ }
+ }
+}
\ No newline at end of file