diff --git a/eng/common/post-build/nuget-verification.ps1 b/eng/common/post-build/nuget-verification.ps1 index a365194a93..ac5c69ffca 100644 --- a/eng/common/post-build/nuget-verification.ps1 +++ b/eng/common/post-build/nuget-verification.ps1 @@ -30,7 +30,7 @@ [CmdletBinding(PositionalBinding = $false)] param( [string]$NuGetExePath, - [string]$PackageSource = "https://api.nuget.org/v3/index.json", + [string]$PackageSource = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json", [string]$DownloadPath, [Parameter(ValueFromRemainingArguments = $true)] [string[]]$args diff --git a/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs b/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs index 2fab9fa01c..60522f2d23 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs @@ -59,8 +59,11 @@ public IntegrationTestBase() { _testEnvironment = new IntegrationTestEnvironment(); BuildConfiguration = IntegrationTestEnvironment.BuildConfiguration; + + TempDirectory.NuGetConfigPath = Path.Combine(IntegrationTestEnvironment.RepoRootDirectory, "NuGet.config"); TempDirectory = new TempDirectory(); + var drive = new DriveInfo(Directory.GetDirectoryRoot(TempDirectory.Path)); Console.WriteLine($"Available space for TEMP: {drive.Name} {drive.AvailableFreeSpace / (1024 * 1024)} MB"); diff --git a/test/Microsoft.TestPlatform.TestUtilities/TempDirectory.cs b/test/Microsoft.TestPlatform.TestUtilities/TempDirectory.cs index e8fb8fa0ad..8595e94e9b 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/TempDirectory.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/TempDirectory.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Runtime.CompilerServices; using IO = System.IO; @@ -23,6 +24,8 @@ public TempDirectory() public string Path { get; } + public static string? NuGetConfigPath { get; set; } + public void Dispose() { Dispose(true); @@ -91,12 +94,25 @@ public string CopyFile(string filePath) /// /// Path of the created directory. /// + [MethodImpl(MethodImplOptions.Synchronized)] internal static string CreateUniqueDirectory() { var temp = GetTempPath(); var directoryPath = IO.Path.Combine(temp, "vstest", RandomId.Next()); Directory.CreateDirectory(directoryPath); + if (NuGetConfigPath == null) + { + throw new InvalidOperationException("NuGetConfigPath on TempDirectory class must be set."); + } + + var tempNugetConfigPath = IO.Path.Combine(directoryPath, IO.Path.GetFileName(NuGetConfigPath)); + + if (!File.Exists(tempNugetConfigPath)) + { + File.Copy(NuGetConfigPath, tempNugetConfigPath); + } + return directoryPath; }