diff --git a/Directory.Build.props b/Directory.Build.props
index 8ac4bbc23f08..87e6532372bd 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -17,6 +17,8 @@
true
+
+ $(DefineConstants);CI_BUILD
diff --git a/src/Tests/Microsoft.DotNet.Cli.Sln.Internal.Tests/Microsoft.DotNet.Cli.Sln.Internal.Tests.cs b/src/Tests/Microsoft.DotNet.Cli.Sln.Internal.Tests/Microsoft.DotNet.Cli.Sln.Internal.Tests.cs
index 06e4423a309a..e881a5b06f74 100644
--- a/src/Tests/Microsoft.DotNet.Cli.Sln.Internal.Tests/Microsoft.DotNet.Cli.Sln.Internal.Tests.cs
+++ b/src/Tests/Microsoft.DotNet.Cli.Sln.Internal.Tests/Microsoft.DotNet.Cli.Sln.Internal.Tests.cs
@@ -104,9 +104,9 @@ public GivenAnSlnFile(ITestOutputHelper log) : base(log)
{
}
- private string CreateFile([CallerMemberName] string callerName = null)
+ private string CreateFile([CallerMemberName] string callerName = null, string identifier = null)
{
- var folder = _testAssetsManager.CreateTestDirectory(testName: callerName);
+ var folder = _testAssetsManager.CreateTestDirectory(testName: callerName + identifier);
var filename = Path.Combine(folder.Path, Guid.NewGuid().ToString() + ".tmp");
using (new FileStream(filename, FileMode.CreateNew)) { }
return filename;
@@ -324,7 +324,7 @@ public void WhenGivenAValidSlnFileItModifiesSavesAndVerifiesContents()
[InlineData("First Line\nSecondLine\nMicrosoft Visual Studio Solution File, Format Version \nFourth Line", 3)]
public void WhenGivenASolutionWithMissingHeaderVersionItThrows(string fileContents, int lineNum)
{
- var tmpFile = CreateFile();
+ var tmpFile = CreateFile(identifier: fileContents.GetHashCode().ToString());
File.WriteAllText(tmpFile, fileContents);
Action action = () =>
@@ -342,7 +342,7 @@ public void WhenGivenASolutionWithMissingHeaderVersionItThrows(string fileConten
[InlineData("Microsoft Visual\nStudio Solution File,\nFormat Version ")]
public void WhenGivenASolutionWithMissingHeaderItThrows(string fileContents)
{
- var tmpFile = CreateFile();
+ var tmpFile = CreateFile(identifier: fileContents.GetHashCode().ToString());
File.WriteAllText(tmpFile, fileContents);
Action action = () =>
diff --git a/src/Tests/Microsoft.DotNet.Cli.Telemetry.PersistenceChannel.Tests/SenderTests.cs b/src/Tests/Microsoft.DotNet.Cli.Telemetry.PersistenceChannel.Tests/SenderTests.cs
index e174feaec8a7..4dd7caec8818 100644
--- a/src/Tests/Microsoft.DotNet.Cli.Telemetry.PersistenceChannel.Tests/SenderTests.cs
+++ b/src/Tests/Microsoft.DotNet.Cli.Telemetry.PersistenceChannel.Tests/SenderTests.cs
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Net;
+using System.Runtime.CompilerServices;
using System.Threading;
using FluentAssertions;
using Microsoft.DotNet.Tools.Test.Utilities;
@@ -19,16 +20,11 @@ public class SenderTests : SdkTest
private Mock StorageBaseMock { get; }
- private SenderUnderTest Sender { get; }
-
public SenderTests(ITestOutputHelper log) : base(log)
{
StorageBaseMock = new Mock();
TransmissionMock = new Mock(string.Empty, new Uri("http://some/url"), new byte[] { },
string.Empty, string.Empty);
- StorageService storageService = CreateStorageService();
- PersistenceTransmitter transmitter = new PersistenceTransmitter(storageService, 0);
- Sender = new SenderUnderTest(StorageBaseMock.Object, transmitter);
_deleteCount = 0;
StorageBaseMock.Setup(storage => storage.Delete(It.IsAny()))
.Callback(() => _deleteCount++);
@@ -37,6 +33,7 @@ public SenderTests(ITestOutputHelper log) : base(log)
[Fact]
public void WhenServerReturn503TransmissionWillBeRetried()
{
+ var Sender = GetSenderUnderTest();
int peekCounts = 0;
// Setup transmission.SendAsync() to throw WebException that has 503 status Code
@@ -63,6 +60,7 @@ public void WhenServerReturn503TransmissionWillBeRetried()
[Fact]
public void WhenServerReturn400IntervalWillBe10Seconds()
{
+ var Sender = GetSenderUnderTest();
int peekCounts = 0;
// Setup transmission.SendAsync() to throw WebException that has 400 status Code
@@ -104,6 +102,7 @@ public void DisposeDoesNotThrow()
[Fact]
public void WhenServerReturnDnsErrorRequestWillBeRetried()
{
+ var Sender = GetSenderUnderTest();
int peekCounts = 0;
// Setup transmission.SendAsync() to throw WebException with ProxyNameResolutionFailure failure
@@ -170,12 +169,19 @@ protected override bool Send(StorageTransmission transmission, ref TimeSpan next
}
}
- private StorageService CreateStorageService()
+ private StorageService CreateStorageService([CallerMemberName] string testName = null)
{
- string tempPath = Path.Combine(_testAssetsManager.CreateTestDirectory("TestStorageService").Path, Path.GetTempFileName());
+ string tempPath = Path.Combine(_testAssetsManager.CreateTestDirectory("TestStorageService", identifier: testName).Path, Path.GetTempFileName());
StorageService storageService = new StorageService();
storageService.Init(tempPath);
return storageService;
}
+
+ private SenderUnderTest GetSenderUnderTest([CallerMemberName] string testName = null)
+ {
+ StorageService storageService = CreateStorageService(testName);
+ PersistenceTransmitter transmitter = new PersistenceTransmitter(storageService, 0);
+ return new SenderUnderTest(StorageBaseMock.Object, transmitter);
+ }
}
}
diff --git a/src/Tests/Microsoft.DotNet.ShellShim.Tests/ShellShimRepositoryTests.cs b/src/Tests/Microsoft.DotNet.ShellShim.Tests/ShellShimRepositoryTests.cs
index 6eaabd5f755f..4285a0a7d5cf 100644
--- a/src/Tests/Microsoft.DotNet.ShellShim.Tests/ShellShimRepositoryTests.cs
+++ b/src/Tests/Microsoft.DotNet.ShellShim.Tests/ShellShimRepositoryTests.cs
@@ -27,17 +27,14 @@ namespace Microsoft.DotNet.ShellShim.Tests
{
public class ShellShimRepositoryTests : SdkTest
{
- private Lazy _reusedHelloWorldExecutableDll;
-
public ShellShimRepositoryTests(ITestOutputHelper output) : base(output)
{
- _reusedHelloWorldExecutableDll = new Lazy(() => MakeHelloWorldExecutableDll("reused"));
}
[Fact]
public void GivenAnExecutablePathItCanGenerateShimFile()
{
- var outputDll = _reusedHelloWorldExecutableDll.Value;
+ var outputDll = MakeHelloWorldExecutableDll();
var pathToShim = GetNewCleanFolderUnderTempRoot();
ShellShimRepository shellShimRepository = ConfigBasicTestDependencyShellShimRepository(pathToShim);
var shellCommandName = nameof(ShellShimRepositoryTests) + Path.GetRandomFileName();
@@ -53,7 +50,7 @@ public void GivenAnExecutablePathItCanGenerateShimFile()
[Fact]
public void GivenAnExecutableAndRelativePathToShimPathItCanGenerateShimFile()
{
- var outputDll = MakeHelloWorldExecutableDll("GivenAnExecutableAndRelativePath");
+ var outputDll = MakeHelloWorldExecutableDll();
// To reproduce the bug, dll need to be nested under the shim
var parentPathAsShimPath = outputDll.GetDirectoryPath().GetParentPath().GetParentPath().Value;
var relativePathToShim = Path.GetRelativePath(
@@ -80,7 +77,7 @@ private static ShellShimRepository ConfigBasicTestDependencyShellShimRepository(
[Fact]
public void GivenAnExecutablePathItCanGenerateShimFileInTransaction()
{
- var outputDll = _reusedHelloWorldExecutableDll.Value;
+ var outputDll = MakeHelloWorldExecutableDll();
var pathToShim = GetNewCleanFolderUnderTempRoot();
var shellShimRepository = ConfigBasicTestDependencyShellShimRepository(pathToShim);
var shellCommandName = nameof(ShellShimRepositoryTests) + Path.GetRandomFileName();
@@ -101,7 +98,7 @@ public void GivenAnExecutablePathItCanGenerateShimFileInTransaction()
[Fact]
public void GivenAnExecutablePathDirectoryThatDoesNotExistItCanGenerateShimFile()
{
- var outputDll = _reusedHelloWorldExecutableDll.Value;
+ var outputDll = MakeHelloWorldExecutableDll();
var testFolder = _testAssetsManager.CreateTestDirectory().Path;
var extraNonExistDirectory = Path.GetRandomFileName();
var shellShimRepository = new ShellShimRepository(new DirectoryPath(Path.Combine(testFolder, extraNonExistDirectory)), GetAppHostTemplateFromStage2());
@@ -118,7 +115,7 @@ public void GivenAnExecutablePathDirectoryThatDoesNotExistItCanGenerateShimFile(
[InlineData(" \"arg with ' quote\" ", new[] { "arg with ' quote" })]
public void GivenAShimItPassesThroughArguments(string arguments, string[] expectedPassThru)
{
- var outputDll = _reusedHelloWorldExecutableDll.Value;
+ var outputDll = MakeHelloWorldExecutableDll(identifier: arguments);
var pathToShim = GetNewCleanFolderUnderTempRoot();
var shellShimRepository = ConfigBasicTestDependencyShellShimRepository(pathToShim);
var shellCommandName = nameof(ShellShimRepositoryTests) + Path.GetRandomFileName();
@@ -202,7 +199,7 @@ public void GivenAnExceptionItWillRollback(bool testMockBehaviorIsInSync)
TransactionScopeOption.Required,
TimeSpan.Zero))
{
- FilePath targetExecutablePath = _reusedHelloWorldExecutableDll.Value;
+ FilePath targetExecutablePath = MakeHelloWorldExecutableDll(identifier: testMockBehaviorIsInSync.ToString());
shellShimRepository.CreateShim(targetExecutablePath, new ToolCommandName(shellCommandName));
intendedError();
@@ -259,7 +256,7 @@ public void GivenAnInstalledShimRemoveDeletesTheShimFiles(bool testMockBehaviorI
Directory.EnumerateFileSystemEntries(pathToShim).Should().BeEmpty();
- FilePath targetExecutablePath = _reusedHelloWorldExecutableDll.Value;
+ FilePath targetExecutablePath = MakeHelloWorldExecutableDll(identifier: testMockBehaviorIsInSync.ToString());
shellShimRepository.CreateShim(targetExecutablePath, new ToolCommandName(shellCommandName));
Directory.EnumerateFileSystemEntries(pathToShim).Should().NotBeEmpty();
@@ -289,7 +286,7 @@ public void GivenAnInstalledShimRemoveRollsbackIfTransactionIsAborted(bool testM
Directory.EnumerateFileSystemEntries(pathToShim).Should().BeEmpty();
- FilePath targetExecutablePath = _reusedHelloWorldExecutableDll.Value;
+ FilePath targetExecutablePath = MakeHelloWorldExecutableDll(identifier: testMockBehaviorIsInSync.ToString());
shellShimRepository.CreateShim(targetExecutablePath, new ToolCommandName(shellCommandName));
Directory.EnumerateFileSystemEntries(pathToShim).Should().NotBeEmpty();
@@ -326,7 +323,7 @@ public void GivenAnInstalledShimRemoveCommitsIfTransactionIsCompleted(bool testM
Directory.EnumerateFileSystemEntries(pathToShim).Should().BeEmpty();
- FilePath targetExecutablePath = _reusedHelloWorldExecutableDll.Value;
+ FilePath targetExecutablePath = MakeHelloWorldExecutableDll(identifier: testMockBehaviorIsInSync.ToString());
shellShimRepository.CreateShim(targetExecutablePath, new ToolCommandName(shellCommandName));
Directory.EnumerateFileSystemEntries(pathToShim).Should().NotBeEmpty();
@@ -471,18 +468,11 @@ private static string GetAppHostTemplateFromStage2()
return stage2AppHostTemplateDirectory;
}
- private FilePath MakeHelloWorldExecutableDll(string instanceName = null)
+ private FilePath MakeHelloWorldExecutableDll([CallerMemberName] string callingMethod = "", string identifier = null)
{
const string testAppName = "TestAppSimple";
- const string emptySpaceToTestSpaceInPath = " ";
- const string directoryNamePostFix = "Test";
-
- if (instanceName == null)
- {
- instanceName = testAppName + emptySpaceToTestSpaceInPath + directoryNamePostFix;
- }
- var testInstance = _testAssetsManager.CopyTestAsset(testAppName, callingMethod: instanceName)
+ var testInstance = _testAssetsManager.CopyTestAsset(testAppName, callingMethod: callingMethod, identifier: identifier)
.WithSource();
new BuildCommand(testInstance)
diff --git a/src/Tests/Microsoft.DotNet.ToolPackage.Tests/ToolPackageInstallerTests.cs b/src/Tests/Microsoft.DotNet.ToolPackage.Tests/ToolPackageInstallerTests.cs
index 84b6511c1b9d..6bdfb7ab7d42 100644
--- a/src/Tests/Microsoft.DotNet.ToolPackage.Tests/ToolPackageInstallerTests.cs
+++ b/src/Tests/Microsoft.DotNet.ToolPackage.Tests/ToolPackageInstallerTests.cs
@@ -101,7 +101,8 @@ public void GivenNugetConfigInstallSucceeds(bool testMockBehaviorIsInSync)
var (store, storeQuery, installer, uninstaller, reporter, fileSystem) = Setup(
useMock: testMockBehaviorIsInSync,
- writeLocalFeedToNugetConfig: nugetConfigPath);
+ writeLocalFeedToNugetConfig: nugetConfigPath,
+ identiifer: testMockBehaviorIsInSync.ToString());
var package = installer.InstallPackage(new PackageLocation(nugetConfig: nugetConfigPath),
packageId: TestPackageId,
@@ -511,7 +512,8 @@ public void GivenAnInstalledPackageUninstallRemovesThePackage(bool testMockBehav
var (store, storeQuery, installer, uninstaller, reporter, fileSystem) = Setup(
useMock: testMockBehaviorIsInSync,
- feeds: GetMockFeedsForSource(source));
+ feeds: GetMockFeedsForSource(source),
+ identiifer: testMockBehaviorIsInSync.ToString());
var package = installer.InstallPackage(new PackageLocation(additionalFeeds: new[] { source }),
packageId: TestPackageId,
@@ -875,9 +877,10 @@ private static List GetOfflineMockFeed()
FilePath? tempProject = null,
DirectoryPath? offlineFeed = null,
FilePath? writeLocalFeedToNugetConfig = null,
- [CallerMemberName] string callingMethod = "")
+ [CallerMemberName] string callingMethod = "",
+ string identiifer = null)
{
- var root = new DirectoryPath(_testAssetsManager.CreateTestDirectory(callingMethod, identifier: useMock.ToString()).Path);
+ var root = new DirectoryPath(_testAssetsManager.CreateTestDirectory(callingMethod, identifier: useMock.ToString() + identiifer).Path);
var reporter = new BufferedReporter();
IFileSystem fileSystem;
diff --git a/src/Tests/Microsoft.DotNet.ToolPackage.Tests/ToolPackageUninstallerTests.cs b/src/Tests/Microsoft.DotNet.ToolPackage.Tests/ToolPackageUninstallerTests.cs
index a465f8013f83..b954b657db5d 100644
--- a/src/Tests/Microsoft.DotNet.ToolPackage.Tests/ToolPackageUninstallerTests.cs
+++ b/src/Tests/Microsoft.DotNet.ToolPackage.Tests/ToolPackageUninstallerTests.cs
@@ -21,6 +21,7 @@
using Microsoft.NET.TestFramework.Utilities;
using Microsoft.NET.TestFramework;
using Xunit.Abstractions;
+using System.Runtime.CompilerServices;
namespace Microsoft.DotNet.ToolPackage.Tests
{
@@ -35,7 +36,8 @@ public void GivenAnInstalledPackageUninstallRemovesThePackage(bool testMockBehav
var (store, storeQuery, installer, uninstaller, reporter, fileSystem) = Setup(
useMock: testMockBehaviorIsInSync,
- feeds: GetMockFeedsForSource(source));
+ feeds: GetMockFeedsForSource(source),
+ identifier: testMockBehaviorIsInSync.ToString());
var package = installer.InstallPackage(new PackageLocation(additionalFeeds: new[] { source }),
packageId: TestPackageId,
@@ -84,9 +86,11 @@ private static List GetMockFeedsForSource(string source)
bool useMock,
List feeds = null,
FilePath? tempProject = null,
- DirectoryPath? offlineFeed = null)
+ DirectoryPath? offlineFeed = null,
+ [CallerMemberName] string testName = "",
+ string identifier = null)
{
- var root = new DirectoryPath(_testAssetsManager.CreateTestDirectory("root").Path);
+ var root = new DirectoryPath(_testAssetsManager.CreateTestDirectory(testName, identifier).Path);
var reporter = new BufferedReporter();
IFileSystem fileSystem;
diff --git a/src/Tests/Microsoft.NET.Build.Tests/AppHostTests.cs b/src/Tests/Microsoft.NET.Build.Tests/AppHostTests.cs
index 8871be57c815..c62d82a26079 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/AppHostTests.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/AppHostTests.cs
@@ -137,7 +137,7 @@ public void It_uses_an_apphost_based_on_platform_target(string target)
var targetFramework = "netcoreapp3.0";
var testAsset = _testAssetsManager
- .CopyTestAsset("HelloWorld")
+ .CopyTestAsset("HelloWorld", identifier: target)
.WithSource();
var buildCommand = new BuildCommand(testAsset);
diff --git a/src/Tests/Microsoft.NET.Build.Tests/DeleteNuGetArtifactsFixture.cs b/src/Tests/Microsoft.NET.Build.Tests/DeleteNuGetArtifactsFixture.cs
index 6c107497d314..1383c2613604 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/DeleteNuGetArtifactsFixture.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/DeleteNuGetArtifactsFixture.cs
@@ -5,6 +5,7 @@
using Microsoft.NET.TestFramework.ProjectConstruction;
using System;
using System.IO;
+using System.Runtime.CompilerServices;
using System.Text;
namespace Microsoft.NET.Build.Tests
@@ -17,9 +18,9 @@ public class ConstantStringValues
public static string NetstandardTargetFrameworkIdentifier = ".NETStandard";
public static string DependencyDirectoryNamePrefix = "D_";
- public static string ConstructNuGetPackageReferencePath(TestProject dependencyProject)
+ public static string ConstructNuGetPackageReferencePath(TestProject dependencyProject, string identifier, [CallerMemberName] string callingMethod = null)
{
- return TestAssetsManager.GetTestDestinationDirectoryPath(dependencyProject.Name, TestDirectoriesNamePrefix, NuGetSharedDirectoryNamePostfix);
+ return TestAssetsManager.GetTestDestinationDirectoryPath(dependencyProject.Name, callingMethod, identifier);
}
}
diff --git a/src/Tests/Microsoft.NET.Build.Tests/DepsFileSkipTests.cs b/src/Tests/Microsoft.NET.Build.Tests/DepsFileSkipTests.cs
index ed9693bcc6b2..2862584dc2d2 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/DepsFileSkipTests.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/DepsFileSkipTests.cs
@@ -168,7 +168,7 @@ public void ResourceAssetFromPackageCanBeSkipped()
private void TestSkippingFile(TestProject testProject, string filenameToSkip, string assetType)
{
- var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name)
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name, identifier: filenameToSkip + assetType)
.WithProjectChanges(project => AddSkipTarget(project, filenameToSkip));
var buildCommand = new BuildCommand(testAsset);
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenFrameworkReferences.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenFrameworkReferences.cs
index 48dcca156b27..c57dcb70ce47 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenFrameworkReferences.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenFrameworkReferences.cs
@@ -90,7 +90,7 @@ public void Multiple_frameworks_are_written_to_runtimeconfig_for_self_contained_
testProject.SourceFiles.Add("Program.cs", FrameworkReferenceEmptyProgramSource);
- TestAsset testAsset = _testAssetsManager.CreateTestProject(testProject)
+ TestAsset testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: tfm)
.Restore(Log, testProject.Name);
var buildCommand = new BuildCommand(testAsset);
@@ -346,7 +346,7 @@ public void RollForwardCanBeSpecifiedViaProperty(string rollForwardValue, string
testProject.AdditionalProperties["RollForward"] = rollForwardValue;
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: rollForwardValue + tfm);
var buildCommand = new BuildCommand(testAsset);
@@ -395,7 +395,7 @@ public void RollForwardIsNotSupportedOn22(string rollForwardValue, bool valid)
testProject.AdditionalProperties["RollForward"] = rollForwardValue;
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: rollForwardValue.GetHashCode().ToString());
var buildCommand = new BuildCommand(testAsset);
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeHaveAPackageReferenceWithAliases.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeHaveAPackageReferenceWithAliases.cs
index 7b8520b85381..0d808e187367 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeHaveAPackageReferenceWithAliases.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeHaveAPackageReferenceWithAliases.cs
@@ -10,6 +10,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Runtime.CompilerServices;
using Xunit;
using Xunit.Abstractions;
@@ -25,7 +26,7 @@ public GivenThatWeHaveAPackageReferenceWithAliases(ITestOutputHelper log) : base
public void CanBuildProjectWithPackageReferencesWithConflictingTypes()
{
var targetFramework = "net5.0";
- var packageReferences = GetPackageReferencesWithConflictingTypes(targetFramework, "A", "B");
+ var packageReferences = GetPackageReferencesWithConflictingTypes(targetFramework, packageNames: new string[] { "A", "B" });
TestProject testProject = new TestProject()
{
@@ -139,18 +140,20 @@ public void CanBuildProjectWithAPackageReferenceWithMultipleAliases()
.Pass();
}
- private IEnumerable GetPackageReferencesWithConflictingTypes(string targetFramework, params string[] packageNames)
+ private IEnumerable GetPackageReferencesWithConflictingTypes(string targetFramework, string[] packageNames, [CallerMemberName] string callingMethod = "")
{
+ var result = new List();
foreach (var packageName in packageNames)
{
- yield return GetPackageReference(targetFramework, packageName, ClassLibConflictingMethod);
+ result.Add(GetPackageReference(targetFramework, packageName, ClassLibConflictingMethod, callingMethod, packageName));
}
+ return result;
}
- private TestPackageReference GetPackageReference(string targetFramework, string packageName, string projectFileContent)
+ private TestPackageReference GetPackageReference(string targetFramework, string packageName, string projectFileContent, [CallerMemberName] string callingMethod = "", string identifier = null)
{
var project = GetProject(targetFramework, packageName, projectFileContent);
- var packCommand = new PackCommand(Log, _testAssetsManager.CreateTestProject(project).TestRoot, packageName);
+ var packCommand = new PackCommand(Log, _testAssetsManager.CreateTestProject(project, callingMethod: callingMethod, identifier: identifier).TestRoot, packageName);
packCommand
.Execute()
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantSatelliteAssembliesHaveassemblyVersion.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantSatelliteAssembliesHaveassemblyVersion.cs
index 9418fac6ffc5..9568009ce725 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantSatelliteAssembliesHaveassemblyVersion.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantSatelliteAssembliesHaveassemblyVersion.cs
@@ -10,6 +10,7 @@
using System.Diagnostics;
using FluentAssertions;
using System.Reflection;
+using System.Runtime.CompilerServices;
namespace Microsoft.NET.Build.Tests
{
@@ -21,10 +22,10 @@ public GivenThatWeWantSatelliteAssembliesHaveAssemblyVersion(ITestOutputHelper l
{
}
- private void RestoreAndBuildTestAssets()
+ private void RestoreAndBuildTestAssets([CallerMemberName] string callingMethod = "")
{
TestAsset testAsset = _testAssetsManager
- .CopyTestAsset("AllResourcesInSatelliteDisableVersionGenerate")
+ .CopyTestAsset("AllResourcesInSatelliteDisableVersionGenerate", callingMethod)
.WithSource();
var buildCommand = new BuildCommand(testAsset);
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAComServerLibrary.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAComServerLibrary.cs
index c68b614025bd..e2311f1f038e 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAComServerLibrary.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAComServerLibrary.cs
@@ -89,7 +89,7 @@ public void It_generates_a_regfree_com_manifest_when_requested()
public void It_embeds_the_clsidmap_in_the_comhost_when_rid_specified(string rid)
{
var testAsset = _testAssetsManager
- .CopyTestAsset("ComServer")
+ .CopyTestAsset("ComServer", rid)
.WithSource()
.WithProjectChanges(project =>
{
@@ -165,7 +165,7 @@ public void It_fails_to_find_comhost_for_platforms_without_comhost()
public void It_fails_to_embed_clsid_when_not_on_windows(string rid)
{
var testAsset = _testAssetsManager
- .CopyTestAsset("ComServer")
+ .CopyTestAsset("ComServer", identifier: rid)
.WithSource()
.WithProjectChanges(project =>
{
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs
index 067e0b318cd7..06cf030e16bf 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs
@@ -79,14 +79,15 @@ internal static List GetValuesFromTestLibrary(
string[] msbuildArgs = null,
GetValuesCommand.ValueType valueType = GetValuesCommand.ValueType.Item,
[CallerMemberName] string callingMethod = "",
- Action projectChanges = null)
+ Action projectChanges = null,
+ string identifier = null)
{
msbuildArgs = msbuildArgs ?? Array.Empty();
string targetFramework = "netstandard1.5";
var testAsset = testAssetsManager
- .CopyTestAsset("AppWithLibrary", callingMethod)
+ .CopyTestAsset("AppWithLibrary", callingMethod, identifier: identifier)
.WithSource();
if (projectChanges != null)
@@ -331,7 +332,7 @@ public void It_implicitly_defines_compilation_constants_for_the_configuration(st
public void It_implicitly_defines_compilation_constants_for_the_target_framework(string targetFramework, string[] expectedDefines)
{
var testAsset = _testAssetsManager
- .CopyTestAsset("AppWithLibrary", "ImplicitFrameworkConstants", targetFramework)
+ .CopyTestAsset("AppWithLibrary", "ImplicitFrameworkConstants", targetFramework, identifier: expectedDefines.GetHashCode().ToString())
.WithSource()
.WithProjectChanges(project =>
{
@@ -392,7 +393,7 @@ public void It_implicitly_defines_compilation_constants_for_the_target_platform(
{
var targetFramework = "net5.0";
var testAsset = _testAssetsManager
- .CopyTestAsset("AppWithLibrary", "ImplicitFrameworkConstants", targetFramework)
+ .CopyTestAsset("AppWithLibrary", "ImplicitFrameworkConstants", targetFramework, identifier: expectedDefines.GetHashCode().ToString())
.WithSource()
.WithTargetFramework(targetFramework)
.WithProjectChanges(project =>
@@ -482,7 +483,7 @@ public void It_can_use_implicitly_defined_compilation_constants(string targetFra
testProj.AdditionalProperties["TargetPlatformIdentifier"] = targetPlatformIdentifier;
testProj.AdditionalProperties["TargetPlatformVersion"] = targetPlatformVersion;
}
- var testAsset = _testAssetsManager.CreateTestProject(testProj);
+ var testAsset = _testAssetsManager.CreateTestProject(testProj, targetFramework);
File.WriteAllText(Path.Combine(testAsset.Path, testProj.Name, $"{testProj.Name}.cs"), @"
using System;
class Program
@@ -614,7 +615,7 @@ public void It_defines_windows_version_default_correctly(string targetFramework)
TargetFrameworks = targetFramework
};
testProject.AdditionalProperties["TargetPlatformIdentifier"] = "windows";
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework);
var getValuesCommand = new GetValuesCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name), targetFramework, "TargetPlatformVersion");
getValuesCommand
@@ -633,7 +634,7 @@ private void TestInvalidTargetFramework(string testName, string targetFramework,
TargetFrameworks = targetFramework,
};
- string identifier = useSolution ? "_Solution" : "";
+ string identifier = ((useSolution ? "_Solution" : "") + targetFramework + expectedOutput).GetHashCode().ToString();
var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name, identifier);
if (targetFramework.Contains(";"))
@@ -863,7 +864,8 @@ public void It_can_build_with_dynamic_loading_enabled(string targetFramework, st
testProject.AdditionalProperties["CopyLocalLockFileAssemblies"] = copyLocal.ToString().ToLower();
}
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var identifier = targetFramework + shouldSetRollForward + shouldCopyLocal + (rollForwardValue == null? "Null" : rollForwardValue);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: identifier);
var buildCommand = new BuildCommand(testAsset);
@@ -915,7 +917,7 @@ public void It_makes_RootNamespace_safe_when_project_name_has_spaces(string targ
TargetFrameworks = targetFramework,
};
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework);
// Overwrite the default file. CreateTestProject uses the defined project name for the namespace.
// We need a buildable project to extract the property to verify it
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithOSSupportedVersion.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithOSSupportedVersion.cs
index fa09b2ca8e52..e3a39da22f37 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithOSSupportedVersion.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithOSSupportedVersion.cs
@@ -102,7 +102,7 @@ public void WhenUsingTargetPlatformInTargetFrameworkItCanGenerateSupportedOSPlat
{
TestProject testProject = SetUpProject(targetFramework);
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework);
var runCommand = new DotnetCommand(Log, "run");
runCommand.WorkingDirectory = Path.Combine(testAsset.TestRoot, testProject.Name);
@@ -226,7 +226,7 @@ public void WhenNotTargetingNet5TargetPlatformMinVersionPropertyCanBeSet(string
testProject.AdditionalProperties["TargetPlatformMinVersion"] = "10.0.18362.0";
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework);
new BuildCommand(testAsset)
.Execute()
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithVB.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithVB.cs
index 6fed83df9433..15a1b811ae77 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithVB.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibraryWithVB.cs
@@ -203,7 +203,7 @@ public void It_implicitly_defines_compilation_constants_for_the_configuration(st
public void It_implicitly_defines_compilation_constants_for_the_target_framework(string targetFramework, string[] expectedDefines)
{
var testAsset = _testAssetsManager
- .CopyTestAsset("AppWithLibraryVB", "ImplicitFrameworkConstantsVB", targetFramework)
+ .CopyTestAsset("AppWithLibraryVB", "ImplicitFrameworkConstantsVB", targetFramework, identifier: targetFramework)
.WithSource()
.WithProjectChanges(project =>
{
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs
index 3392bd2104fc..37c7563899b1 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs
@@ -24,6 +24,7 @@
using Xunit.Abstractions;
using Microsoft.NET.Build.Tasks;
using NuGet.Versioning;
+using System.Runtime.CompilerServices;
namespace Microsoft.NET.Build.Tests
{
@@ -33,10 +34,10 @@ public GivenThatWeWantToBuildANetCoreApp(ITestOutputHelper log) : base(log)
{
}
- private BuildCommand GetBuildCommand()
+ private BuildCommand GetBuildCommand([CallerMemberName] string callingMethod = "")
{
var testAsset = _testAssetsManager
- .CopyTestAsset("HelloWorldWithSubDirs")
+ .CopyTestAsset("HelloWorldWithSubDirs", callingMethod)
.WithSource();
return new BuildCommand(testAsset);
@@ -217,7 +218,7 @@ public void It_handles_mismatched_implicit_package_versions(bool allowMismatch)
testProject.AdditionalProperties["RuntimeIdentifiers"] = runtimeIdentifier;
- var testAsset = _testAssetsManager.CreateTestProject(testProject)
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: allowMismatch.ToString())
.Restore(Log, testProject.Name);
var buildCommand = new BuildCommand(testAsset);
@@ -454,7 +455,7 @@ public void It_generates_rid_fallback_graph(bool isSelfContained)
RuntimeIdentifier = runtimeIdentifier
};
- var testAsset = _testAssetsManager.CreateTestProject(project);
+ var testAsset = _testAssetsManager.CreateTestProject(project, identifier: isSelfContained.ToString());
var buildCommand = new BuildCommand(testAsset);
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASolutionWithNonDefaultConfiguration.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASolutionWithNonDefaultConfiguration.cs
index 77c64832be23..29f6e8065237 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASolutionWithNonDefaultConfiguration.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASolutionWithNonDefaultConfiguration.cs
@@ -28,7 +28,7 @@ public void Properly_changes_implicit_defines(string configuration, string expec
{
var targetFramework = "netcoreapp2.1";
var testAsset = _testAssetsManager
- .CopyTestAsset("HelloWorld")
+ .CopyTestAsset("HelloWorld", configuration)
.WithSource()
.WithProjectChanges(project =>
{
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASolutionWithNonDefaultConfigurationVB.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASolutionWithNonDefaultConfigurationVB.cs
index 68b70dc332ab..85f6623351c6 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASolutionWithNonDefaultConfigurationVB.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASolutionWithNonDefaultConfigurationVB.cs
@@ -27,7 +27,7 @@ public void Properly_changes_implicit_defines(string configuration, string expec
{
var targetFramework = "netcoreapp1.0";
var testAsset = _testAssetsManager
- .CopyTestAsset("HelloWorldVB")
+ .CopyTestAsset("HelloWorldVB", configuration)
.WithSource()
.WithProjectChanges(project =>
{
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs
index 807a84549c36..dcc2ffab2f23 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs
@@ -204,7 +204,7 @@ public void It_succeeds_if_windows_target_platform_version_does_not_have_trailin
testProject.AdditionalProperties["TargetPlatformIdentifier"] = "Windows";
testProject.AdditionalProperties["TargetPlatformVersion"] = "10.0.18362";
}
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, setInTargetframework.ToString());
var buildCommand = new BuildCommand(testAsset);
buildCommand.Execute()
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsRuntimeComponent.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsRuntimeComponent.cs
index 5b92dd4bb03a..a899a2b262b5 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsRuntimeComponent.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsRuntimeComponent.cs
@@ -58,7 +58,7 @@ public void It_fails_when_referencing_winmds_for_net5_0_or_newer()
public void It_successfully_builds_when_referencing_winmds(string targetFramework)
{
var testAsset = _testAssetsManager
- .CopyTestAsset("WinMDClassLibrary")
+ .CopyTestAsset("WinMDClassLibrary", identifier: targetFramework)
.WithSource()
.WithTargetFramework(targetFramework);
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs
index 65d8e93e60c6..84cb43ccb320 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs
@@ -33,7 +33,7 @@ public void It_defines_target_platform_from_target_framework(string targetFramew
Name = "TargetPlatformTests",
TargetFrameworks = targetFramework
};
- var testAsset = _testAssetsManager.CreateTestProject(testProj);
+ var testAsset = _testAssetsManager.CreateTestProject(testProj, identifier: targetFramework);
Action assertValue = (string valueName, string expected) =>
{
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithGlobalJson.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithGlobalJson.cs
index 32970cd57f48..cdc988e08964 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithGlobalJson.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithGlobalJson.cs
@@ -33,7 +33,7 @@ public void It_fails_build_on_failed_sdk_resolution(bool runningInVS)
TargetFrameworks = "net5.0"
};
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: runningInVS.ToString());
var globalJsonPath = Path.Combine(testAsset.Path, testProject.Name, "global.json");
File.WriteAllText(globalJsonPath, @"{
""sdk"": {
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToControlGeneratedAssemblyInfo.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToControlGeneratedAssemblyInfo.cs
index 8e081561ac3e..733a9bc1d11a 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToControlGeneratedAssemblyInfo.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToControlGeneratedAssemblyInfo.cs
@@ -610,7 +610,7 @@ public void It_includes_repository_url(bool privateRepo)
testProject.AdditionalProperties["RepositoryUrl"] = fakeUrl;
}
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: privateRepo.ToString());
var buildCommand = new BuildCommand(testAsset);
buildCommand.Execute().Should().Pass();
@@ -635,7 +635,7 @@ public void It_does_not_write_to_undefined_assembly_metadata_attribute(string ta
testProject.AdditionalProperties["RepositoryUrl"] = fakeUrl;
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework);
var buildCommand = new BuildCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
buildCommand.Execute()
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToProduceReferenceAssembly.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToProduceReferenceAssembly.cs
index 11c7f8230691..51c66401249d 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToProduceReferenceAssembly.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToProduceReferenceAssembly.cs
@@ -30,7 +30,7 @@ public void It_produces_ref_assembly_for_appropriate_frameworks(string targetFra
TargetFrameworks = targetFramework
};
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework);
var buildCommand = new BuildCommand(testAsset);
buildCommand.Execute()
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAProject.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAProject.cs
index df2ad535cd14..b4471598d3d3 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAProject.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAProject.cs
@@ -177,7 +177,7 @@ public void It_disables_copying_conflicting_transitive_content(bool copyConflict
TargetFrameworks = tfm,
Name = "ChildProject",
};
- var childAsset = _testAssetsManager.CreateTestProject(childProject)
+ var childAsset = _testAssetsManager.CreateTestProject(childProject, identifier: copyConflictingTransitiveContent.ToString() + explicitlySet.ToString())
.WithProjectChanges(project => AddProjectChanges(project));
File.WriteAllText(Path.Combine(childAsset.Path, childProject.Name, contentName), childProject.Name);
@@ -190,7 +190,7 @@ public void It_disables_copying_conflicting_transitive_content(bool copyConflict
{
parentProject.AdditionalProperties["CopyConflictingTransitiveContent"] = copyConflictingTransitiveContent.ToString().ToLower();
}
- var parentAsset = _testAssetsManager.CreateTestProject(parentProject)
+ var parentAsset = _testAssetsManager.CreateTestProject(parentProject, identifier: copyConflictingTransitiveContent.ToString() + explicitlySet.ToString())
.WithProjectChanges(project => AddProjectChanges(project, Path.Combine(childAsset.Path, childProject.Name, childProject.Name + ".csproj")));
File.WriteAllText(Path.Combine(parentAsset.Path, parentProject.Name, contentName), parentProject.Name);
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAnAssembly.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAnAssembly.cs
index 2029010340e8..1f3dab17fd70 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAnAssembly.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAnAssembly.cs
@@ -448,7 +448,7 @@ public void ItRunsAppsReferencingAProjectDirectlyReferencingAssemblies(
return;
}
- string identifier = referencerTarget.ToString() + "_" + dependencyTarget.ToString();
+ string identifier = referencerTarget.ToString() + "_" + dependencyTarget.ToString() + "_" + dllDependencyTarget.ToString();
TestProject dllDependencyProject = new TestProject()
{
@@ -533,7 +533,7 @@ public void ItRunsAppsReferencingAProjectDirectlyReferencingAssembliesWithSatell
return;
}
- string identifier = referencerTarget.ToString() + "_" + dependencyTarget.ToString();
+ string identifier = referencerTarget.ToString() + "_" + dependencyTarget.ToString() + "_" + dllDependencyTarget.ToString();
TestProject dllDependencyProject = new TestProject()
{
@@ -673,7 +673,7 @@ public void ItRunsAppsReferencingAProjectDirectlyReferencingAssembliesWhichRefer
return;
}
- string identifier = referencerTarget.ToString() + "_" + dependencyTarget.ToString();
+ string identifier = referencerTarget.ToString() + "_" + dependencyTarget.ToString() + "_" + dllDependencyTarget.ToString();
TestProject dllDependencyProjectDependency = new TestProject()
{
@@ -775,7 +775,7 @@ public void ItRunsAppsReferencingAProjectDirectlyReferencingAssembliesWhichRefer
return;
}
- string identifier = referencerTarget.ToString() + "_" + dependencyTarget.ToString();
+ string identifier = referencerTarget.ToString() + "_" + dependencyTarget.ToString() + "_" + dllDependencyTarget.ToString();
TestProject dllDependencyProjectDependency = new TestProject()
{
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToResolveConflicts.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToResolveConflicts.cs
index e6f9c39852dc..a0bdf9ab64b1 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToResolveConflicts.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToResolveConflicts.cs
@@ -37,7 +37,8 @@ public void The_same_references_are_used_with_or_without_DisableDefaultPackageCo
defaultProject,
expectConflicts: false,
references: out List defaultReferences,
- referenceCopyLocalPaths: out List defaultReferenceCopyLocalPaths);
+ referenceCopyLocalPaths: out List defaultReferenceCopyLocalPaths,
+ targetFramework);
var disableProject = new TestProject()
{
@@ -50,7 +51,8 @@ public void The_same_references_are_used_with_or_without_DisableDefaultPackageCo
disableProject,
expectConflicts: true,
references: out List disableReferences,
- referenceCopyLocalPaths: out List disableReferenceCopyLocalPaths);
+ referenceCopyLocalPaths: out List disableReferenceCopyLocalPaths,
+ targetFramework);
Assert.Equal(defaultReferences, disableReferences);
Assert.Equal(defaultReferenceCopyLocalPaths, disableReferenceCopyLocalPaths);
@@ -64,10 +66,10 @@ private void AddConflictReferences(TestProject testProject)
}
}
- private void GetReferences(TestProject testProject, bool expectConflicts, out List references, out List referenceCopyLocalPaths)
+ private void GetReferences(TestProject testProject, bool expectConflicts, out List references, out List referenceCopyLocalPaths, string identifier)
{
string targetFramework = testProject.TargetFrameworks;
- TestAsset tempTestAsset = _testAssetsManager.CreateTestProject(testProject);
+ TestAsset tempTestAsset = _testAssetsManager.CreateTestProject(testProject, identifier: identifier);
string projectFolder = Path.Combine(tempTestAsset.TestRoot, testProject.Name);
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToVerifyNuGetReferenceCompat.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToVerifyNuGetReferenceCompat.cs
index 46ede4f6cd31..b82b65ae9815 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToVerifyNuGetReferenceCompat.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToVerifyNuGetReferenceCompat.cs
@@ -13,6 +13,7 @@
using System.Runtime.InteropServices;
using System.Linq;
using Xunit.Abstractions;
+using System.Runtime.CompilerServices;
namespace Microsoft.NET.Build.Tests
{
@@ -63,7 +64,7 @@ public void Nuget_reference_compat(string referencerTarget, string testDescripti
TestPackageReference dependencyPackageReference = new TestPackageReference(
dependencyProject.Name,
"1.0.0",
- ConstantStringValues.ConstructNuGetPackageReferencePath(dependencyProject));
+ ConstantStringValues.ConstructNuGetPackageReferencePath(dependencyProject, identifier: referencerTarget + testDescription + rawDependencyTargets));
// Skip creating the NuGet package if not running on Windows; or if the NuGet package already exists
// https://github.com/dotnet/sdk/issues/335
@@ -72,7 +73,7 @@ public void Nuget_reference_compat(string referencerTarget, string testDescripti
if (!dependencyPackageReference.NuGetPackageExists())
{
// Create the NuGet packages
- var dependencyTestAsset = _testAssetsManager.CreateTestProject(dependencyProject, ConstantStringValues.TestDirectoriesNamePrefix, ConstantStringValues.NuGetSharedDirectoryNamePostfix);
+ var dependencyTestAsset = _testAssetsManager.CreateTestProject(dependencyProject, identifier: referencerTarget + testDescription + rawDependencyTargets);
var dependencyRestoreCommand = dependencyTestAsset.GetRestoreCommand(Log, relativePath: dependencyProject.Name).Execute().Should().Pass();
var dependencyProjectDirectory = Path.Combine(dependencyTestAsset.TestRoot, dependencyProject.Name);
@@ -141,7 +142,7 @@ public void Netfx_is_implicit_for_Netstandard_and_Netcore_20(string targetFramew
{
var testProjectName = targetFramework.Replace(".", "_") + "implicit_atf";
- var (testProjectTestAsset, testPackageReference) = CreateTestAsset(testProjectName, targetFramework, "net461");
+ var (testProjectTestAsset, testPackageReference) = CreateTestAsset(testProjectName, targetFramework, "net461", identifer: targetFramework);
var restoreCommand = testProjectTestAsset.GetRestoreCommand(Log, relativePath: testProjectName);
@@ -161,7 +162,7 @@ public void Netfx_is_not_implicit_for_Netstandard_and_Netcore_less_than_20(strin
{
var testProjectName = targetFramework.Replace(".", "_") + "non_implicit_atf";
- var (testProjectTestAsset, testPackageReference) = CreateTestAsset(testProjectName, targetFramework, "net461");
+ var (testProjectTestAsset, testPackageReference) = CreateTestAsset(testProjectName, targetFramework, "net461", identifer: targetFramework);
var restoreCommand = testProjectTestAsset.GetRestoreCommand(Log, relativePath: testProjectName);
NuGetConfigWriter.Write(testProjectTestAsset.TestRoot, Path.GetDirectoryName(testPackageReference.NupkgPath));
@@ -214,9 +215,11 @@ public void It_chooses_lowest_netfx_in_default_atf()
string testProjectName,
string callerTargetFramework,
string calleeTargetFrameworks,
- Dictionary additionalProperties = null)
+ Dictionary additionalProperties = null,
+ [CallerMemberName] string testName = null,
+ string identifer = null)
{
- var testPackageReference = CreateTestPackage(calleeTargetFrameworks);
+ var testPackageReference = CreateTestPackage(calleeTargetFrameworks, testName, identifer);
var testProject =
new TestProject
@@ -243,7 +246,7 @@ public void It_chooses_lowest_netfx_in_default_atf()
return (testProjectTestAsset, testPackageReference);
}
- private TestPackageReference CreateTestPackage(string targetFrameworks)
+ private TestPackageReference CreateTestPackage(string targetFrameworks, string identifier, [CallerMemberName] string callingMethod = "")
{
var project =
new TestProject
@@ -256,15 +259,15 @@ private TestPackageReference CreateTestPackage(string targetFrameworks)
new TestPackageReference(
project.Name,
"1.0.0",
- ConstantStringValues.ConstructNuGetPackageReferencePath(project));
+ ConstantStringValues.ConstructNuGetPackageReferencePath(project, identifier, callingMethod));
if (!packageReference.NuGetPackageExists())
{
var testAsset =
_testAssetsManager.CreateTestProject(
project,
- ConstantStringValues.TestDirectoriesNamePrefix,
- ConstantStringValues.NuGetSharedDirectoryNamePostfix);
+ callingMethod,
+ identifier);
var packageRestoreCommand =
testAsset.GetRestoreCommand(Log, relativePath: project.Name).Execute().Should().Pass();
var dependencyProjectDirectory = Path.Combine(testAsset.TestRoot, project.Name);
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThereAreDefaultItems.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThereAreDefaultItems.cs
index bd0f27fd6b77..0f3f8ca73578 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThereAreDefaultItems.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThereAreDefaultItems.cs
@@ -292,7 +292,7 @@ public void It_allows_a_CSharp_file_to_be_used_as_an_EmbeddedResource()
compileItems.Should().BeEquivalentTo(expectedItems);
- var embeddedResourceItems = GivenThatWeWantToBuildALibrary.GetValuesFromTestLibrary(Log, _testAssetsManager, "EmbeddedResource", setup, projectChanges: projectChanges);
+ var embeddedResourceItems = GivenThatWeWantToBuildALibrary.GetValuesFromTestLibrary(Log, _testAssetsManager, "EmbeddedResource", setup, projectChanges: projectChanges, identifier: "EmbeddedResource");
var expectedEmbeddedResourceItems = new[]
{
@@ -343,7 +343,7 @@ public void It_allows_a_CSharp_file_to_be_used_as_Content()
compileItems.Should().BeEquivalentTo(expectedItems);
- var contentItems = GivenThatWeWantToBuildALibrary.GetValuesFromTestLibrary(Log, _testAssetsManager, "Content", setup, projectChanges: projectChanges);
+ var contentItems = GivenThatWeWantToBuildALibrary.GetValuesFromTestLibrary(Log, _testAssetsManager, "Content", setup, projectChanges: projectChanges, identifier: "Content");
var expectedContentItems = new[]
{
@@ -354,7 +354,7 @@ public void It_allows_a_CSharp_file_to_be_used_as_Content()
contentItems.Should().BeEquivalentTo(expectedContentItems);
- var noneItems = GivenThatWeWantToBuildALibrary.GetValuesFromTestLibrary(Log, _testAssetsManager, "None", setup, projectChanges: projectChanges);
+ var noneItems = GivenThatWeWantToBuildALibrary.GetValuesFromTestLibrary(Log, _testAssetsManager, "None", setup, projectChanges: projectChanges, identifier: expectedContentItems.GetHashCode().ToString());
var expectedNoneItems = new[]
{
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs
index ac21c95eb5d2..ad991ec4064e 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenWeWantToRequireWindowsForDesktopApps.cs
@@ -13,6 +13,7 @@
using Xunit;
using Xunit.Abstractions;
using System.Linq;
+using System.Runtime.CompilerServices;
namespace Microsoft.NET.Build.Tests
{
@@ -29,7 +30,7 @@ public void It_builds_on_windows_with_the_windows_desktop_sdk(string uiFramework
{
const string ProjectName = "WindowsDesktopSdkTest";
- var asset = CreateWindowsDesktopSdkTestAsset(ProjectName, uiFrameworkProperty);
+ var asset = CreateWindowsDesktopSdkTestAsset(ProjectName, uiFrameworkProperty, uiFrameworkProperty);
var command = new BuildCommand(asset);
@@ -46,7 +47,7 @@ public void It_errors_on_nonwindows_with_the_windows_desktop_sdk(string uiFramew
{
const string ProjectName = "WindowsDesktopSdkErrorTest";
- var asset = CreateWindowsDesktopSdkTestAsset(ProjectName, uiFrameworkProperty);
+ var asset = CreateWindowsDesktopSdkTestAsset(ProjectName, uiFrameworkProperty, uiFrameworkProperty);
var command = new BuildCommand(asset);
@@ -66,7 +67,7 @@ public void It_builds_on_windows_with_a_framework_reference(string desktopFramew
{
const string ProjectName = "WindowsDesktopReferenceTest";
- var asset = CreateWindowsDesktopReferenceTestAsset(ProjectName, desktopFramework);
+ var asset = CreateWindowsDesktopReferenceTestAsset(ProjectName, desktopFramework, desktopFramework);
var command = new BuildCommand(asset);
@@ -84,7 +85,7 @@ public void It_errors_on_nonwindows_with_a_framework_reference(string desktopFra
{
const string ProjectName = "WindowsDesktopReferenceErrorTest";
- var asset = CreateWindowsDesktopReferenceTestAsset(ProjectName, desktopFramework);
+ var asset = CreateWindowsDesktopReferenceTestAsset(ProjectName, desktopFramework, desktopFramework);
var command = new BuildCommand(asset);
@@ -111,7 +112,7 @@ public void It_infers_WinExe_output_type(string targetFramework, string propName
};
testProject.AdditionalProperties[propName] = propValue;
- var asset = _testAssetsManager.CreateTestProject(testProject);
+ var asset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework + propName + propValue);
var getValuesCommand = new GetValuesCommand(asset, "OutputType");
getValuesCommand
@@ -291,7 +292,7 @@ from item in publishItemsOutputGroupOutputsCommand.GetValuesWithMetadata()
.Pass();
}
- private TestAsset CreateWindowsDesktopSdkTestAsset(string projectName, string uiFrameworkProperty)
+ private TestAsset CreateWindowsDesktopSdkTestAsset(string projectName, string uiFrameworkProperty, string identifier, [CallerMemberName] string callingMethod = "")
{
const string tfm = "netcoreapp3.0";
@@ -305,10 +306,10 @@ private TestAsset CreateWindowsDesktopSdkTestAsset(string projectName, string ui
testProject.AdditionalProperties.Add(uiFrameworkProperty, "true");
- return _testAssetsManager.CreateTestProject(testProject);
+ return _testAssetsManager.CreateTestProject(testProject, callingMethod, identifier);
}
- private TestAsset CreateWindowsDesktopReferenceTestAsset(string projectName, string desktopFramework)
+ private TestAsset CreateWindowsDesktopReferenceTestAsset(string projectName, string desktopFramework, string identifier, [CallerMemberName] string callingMethod = "")
{
const string tfm = "netcoreapp3.0";
@@ -321,7 +322,7 @@ private TestAsset CreateWindowsDesktopReferenceTestAsset(string projectName, str
testProject.FrameworkReferences.Add(desktopFramework);
- return _testAssetsManager.CreateTestProject(testProject);
+ return _testAssetsManager.CreateTestProject(testProject, callingMethod, identifier);
}
private readonly string _fileUseWindowsType = @"
diff --git a/src/Tests/Microsoft.NET.Pack.Tests/GivenThatThereAreImplicitPackageReferences.cs b/src/Tests/Microsoft.NET.Pack.Tests/GivenThatThereAreImplicitPackageReferences.cs
index d37c92140c2e..5056526f686f 100644
--- a/src/Tests/Microsoft.NET.Pack.Tests/GivenThatThereAreImplicitPackageReferences.cs
+++ b/src/Tests/Microsoft.NET.Pack.Tests/GivenThatThereAreImplicitPackageReferences.cs
@@ -167,7 +167,7 @@ public void Package_an_aspnetcore_2_1_app_does_not_include_the_implicit_dependen
testProject.PackageReferences.Add(new TestPackageReference(packageId, ""));
- var dependencies = PackAndGetDependencies(testProject);
+ var dependencies = PackAndGetDependencies(testProject, packageId);
dependencies.Should().BeEmpty();
@@ -265,9 +265,9 @@ private List GetFrameworkAssemblies(XDocument nuspec, out XNamespace n
.ToList();
}
- private XDocument PackAndGetNuspec(TestProject testProject)
+ private XDocument PackAndGetNuspec(TestProject testProject, string identifier = null)
{
- var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, testProject.Name);
+ var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, testProject.Name, identifier);
var packCommand = new PackCommand(Log, testProjectInstance.TestRoot, testProject.Name);
@@ -280,9 +280,9 @@ private XDocument PackAndGetNuspec(TestProject testProject)
return nuspec;
}
- private List PackAndGetDependencies(TestProject testProject)
+ private List PackAndGetDependencies(TestProject testProject, string identifier = null)
{
- var dependencyGroups = GetDependencyGroups(PackAndGetNuspec(testProject), out var ns);
+ var dependencyGroups = GetDependencyGroups(PackAndGetNuspec(testProject, identifier), out var ns);
// There should be only one dependency group for these tests
dependencyGroups.Count().Should().Be(1);
diff --git a/src/Tests/Microsoft.NET.Pack.Tests/GivenThatWeWantToPackANetFrameworkLibrary.cs b/src/Tests/Microsoft.NET.Pack.Tests/GivenThatWeWantToPackANetFrameworkLibrary.cs
index 9655a74f7d6e..bc58d7e3059b 100644
--- a/src/Tests/Microsoft.NET.Pack.Tests/GivenThatWeWantToPackANetFrameworkLibrary.cs
+++ b/src/Tests/Microsoft.NET.Pack.Tests/GivenThatWeWantToPackANetFrameworkLibrary.cs
@@ -56,6 +56,7 @@ public void ExplicitReferencesAreIncludedAsFrameworkReferences()
};
var nuspecPath = PackAndGetNuspecPath(testProject,
+ "PackImplicitRefs",
p =>
{
var pns = p.Root.Name.Namespace;
@@ -78,9 +79,9 @@ public void ExplicitReferencesAreIncludedAsFrameworkReferences()
frameworkAssemblies.Should().Contain(i => i.Attribute("assemblyName").Value == "System.Xml.Linq");
}
- private string PackAndGetNuspecPath(TestProject testProject, Action xmlAction = null)
+ private string PackAndGetNuspecPath(TestProject testProject, string identifier = null, Action xmlAction = null)
{
- var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, testProject.Name);
+ var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, testProject.Name, identifier);
if (xmlAction != null)
{
diff --git a/src/Tests/Microsoft.NET.Pack.Tests/GivenThatWeWantToPackAProjectTool.cs b/src/Tests/Microsoft.NET.Pack.Tests/GivenThatWeWantToPackAProjectTool.cs
index 446d43c73255..3996df30851e 100644
--- a/src/Tests/Microsoft.NET.Pack.Tests/GivenThatWeWantToPackAProjectTool.cs
+++ b/src/Tests/Microsoft.NET.Pack.Tests/GivenThatWeWantToPackAProjectTool.cs
@@ -24,7 +24,7 @@ public void It_packs_project_tools_targeting_netcoreapp2_2()
{
TestProject toolProject = new TestProject()
{
- Name = "TestTool",
+ Name = "TestToolNetCore22",
TargetFrameworks = "netcoreapp2.2",
IsExe = true
};
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/FilesCopiedToPublishDirTests.cs b/src/Tests/Microsoft.NET.Publish.Tests/FilesCopiedToPublishDirTests.cs
index 9e79a92f0918..c99b7fb19534 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/FilesCopiedToPublishDirTests.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/FilesCopiedToPublishDirTests.cs
@@ -55,7 +55,7 @@ public void RunFilesCopiedToPublishDirTest(bool specifyRid, bool singleFile)
testProject.AdditionalProperties["PublishSingleFile"] = "true";
}
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: specifyRid.ToString() + singleFile.ToString());
var restoreCommand = new RestoreCommand(testAsset);
restoreCommand
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatAPublishedDepsJsonShouldContainVersionInformation.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatAPublishedDepsJsonShouldContainVersionInformation.cs
index 8c9ecba3da49..ee759c7a66b4 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatAPublishedDepsJsonShouldContainVersionInformation.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatAPublishedDepsJsonShouldContainVersionInformation.cs
@@ -223,7 +223,7 @@ public static void Main()
// framework installed. So we get the RuntimeFrameworkVersion of an app
// that targets .NET Core 2.1, and then use the --fx-version parameter to the host
// to force the .NET Core 2.0 app to run on that version
- string rollForwardVersion = GetRollForwardNetCoreAppVersion();
+ string rollForwardVersion = GetRollForwardNetCoreAppVersion(callingMethod);
var runAppCommand = new DotnetCommand(Log, "exec", "--fx-version", rollForwardVersion, exePath );
@@ -243,7 +243,7 @@ public static void Main()
}
- string GetRollForwardNetCoreAppVersion()
+ string GetRollForwardNetCoreAppVersion([CallerMemberName] string callingMethod = "", string identifier = null)
{
var testProject = new TestProject()
{
@@ -253,7 +253,7 @@ string GetRollForwardNetCoreAppVersion()
};
testProject.AdditionalProperties.Add("TargetLatestRuntimePatch", "true");
- var testAsset = _testAssetsManager.CreateTestProject(testProject)
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, callingMethod, identifier)
.Restore(Log, testProject.Name);
LockFile lockFile = LockFileUtilities.GetLockFile(Path.Combine(testAsset.TestRoot, testProject.Name,
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToFilterSatelliteAssemblies.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToFilterSatelliteAssemblies.cs
index 1a6da9d913ef..6387a33fdc48 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToFilterSatelliteAssemblies.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToFilterSatelliteAssemblies.cs
@@ -36,7 +36,7 @@ public void It_only_publishes_selected_ResourceLanguages(string tfm)
testProject.PackageReferences.Add(new TestPackageReference("System.Spatial", "5.8.3"));
testProject.AdditionalProperties.Add("SatelliteResourceLanguages", "en-US;it;fr");
- var testProjectInstance = _testAssetsManager.CreateTestProject(testProject);
+ var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, identifier: tfm);
var publishCommand = new PublishCommand(testProjectInstance);
var publishResult = publishCommand.Execute();
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs
index 73514c103390..e7697a5618e8 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs
@@ -443,7 +443,7 @@ public void It_preserves_newest_files_on_publish(string tfm)
IsExe = true
};
- var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name, identifier: tfm);
var publishCommand = new PublishCommand(testAsset);
@@ -579,7 +579,8 @@ public void It_publishes_with_a_publish_profile(bool? selfContained, bool? useAp
IsExe = true,
};
- var testProjectInstance = _testAssetsManager.CreateTestProject(testProject);
+ var identifer = (selfContained == null ? "null" : selfContained.ToString()) + (useAppHost == null ? "null" : useAppHost.ToString());
+ var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, identifier: identifer);
var projectDirectory = Path.Combine(testProjectInstance.Path, testProject.Name);
var publishProfilesDirectory = Path.Combine(projectDirectory, "Properties", "PublishProfiles");
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs
index 0a54ff6defd0..0d9e343b4f71 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs
@@ -13,6 +13,7 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
+using System.Runtime.CompilerServices;
namespace Microsoft.NET.Publish.Tests
{
@@ -50,10 +51,10 @@ public GivenThatWeWantToPublishASingleFileApp(ITestOutputHelper log) : base(log)
{
}
- private PublishCommand GetPublishCommand()
+ private PublishCommand GetPublishCommand(string identifier = null, [CallerMemberName] string callingMethod = "")
{
var testAsset = _testAssetsManager
- .CopyTestAsset(TestProjectName)
+ .CopyTestAsset(TestProjectName, callingMethod, identifier)
.WithSource();
// Create the following content:
@@ -325,7 +326,7 @@ public void It_generates_a_single_file_including_pdbs(string targetFramework)
IsExe = true,
};
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework);
var publishCommand = new PublishCommand(testAsset);
publishCommand
@@ -382,7 +383,7 @@ public void It_can_include_ni_pdbs_in_single_file(string targetFramework)
IsExe = true,
};
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework);
var publishCommand = new PublishCommand(testAsset);
publishCommand
@@ -401,7 +402,7 @@ public void It_can_include_ni_pdbs_in_single_file(string targetFramework)
[InlineData(ExcludeAlways, AlwaysContent)]
public void It_generates_a_single_file_excluding_content(string exclusion, string content)
{
- var publishCommand = GetPublishCommand();
+ var publishCommand = GetPublishCommand(exclusion);
publishCommand
.Execute(PublishSingleFile, RuntimeIdentifier, IncludeAllContent, PlaceStamp, exclusion)
.Should()
@@ -641,7 +642,7 @@ public void It_errors_when_including_symbols_targeting_net5(bool selfContained)
};
testProject.AdditionalProperties.Add("SelfContained", $"{selfContained}");
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: selfContained.ToString());
var publishCommand = new PublishCommand(testAsset);
publishCommand.Execute(PublishSingleFile, RuntimeIdentifier, IncludePdb)
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAWebApp.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAWebApp.cs
index 4b3b30a2dce7..4d710fe839b2 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAWebApp.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAWebApp.cs
@@ -133,7 +133,7 @@ public void It_should_publish_framework_dependent_for_2x(string platformLibrary)
testProject.PackageReferences.Add(new TestPackageReference(platformLibrary));
testProject.PackageReferences.Add(new TestPackageReference("Microsoft.AspNetCore.Razor.Design", version: "2.2.0", privateAssets: "all"));
- var testProjectInstance = _testAssetsManager.CreateTestProject(testProject);
+ var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, platformLibrary);
var command = new PublishCommand(testProjectInstance);
@@ -184,7 +184,8 @@ public void It_publishes_with_a_publish_profile(bool? selfContained, bool? useAp
testProject.PackageReferences.Add(new TestPackageReference("Microsoft.AspNetCore.App"));
testProject.PackageReferences.Add(new TestPackageReference("Microsoft.AspNetCore.Razor.Design", version: "2.2.0", privateAssets: "all"));
- var testProjectInstance = _testAssetsManager.CreateTestProject(testProject);
+ var identifier = (selfContained == null ? "null" : selfContained.ToString()) + (useAppHost == null ? "null" : useAppHost.ToString());
+ var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, identifier: identifier);
var projectDirectory = Path.Combine(testProjectInstance.Path, testProject.Name);
var publishProfilesDirectory = Path.Combine(projectDirectory, "Properties", "PublishProfiles");
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishReadyToRun.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishReadyToRun.cs
index 80dec3ba68ad..5f8567a04dbb 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishReadyToRun.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishReadyToRun.cs
@@ -3,6 +3,7 @@
using System.IO;
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using FluentAssertions;
using Microsoft.NET.Build.Tasks;
@@ -34,7 +35,7 @@ public void It_only_runs_readytorun_compiler_when_switch_is_enabled(string targe
projectName,
"ClassLib");
- var testProjectInstance = _testAssetsManager.CreateTestProject(testProject);
+ var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework);
var publishCommand = new PublishCommand(testProjectInstance);
publishCommand.Execute().Should().Pass();
@@ -66,7 +67,7 @@ public void It_creates_readytorun_images_for_all_assemblies_except_excluded_ones
testProject.AdditionalProperties["PublishReadyToRun"] = "True";
testProject.AdditionalItems["PublishReadyToRunExclude"] = new Dictionary { ["Include"] = "Classlib.dll" };
- var testProjectInstance = _testAssetsManager.CreateTestProject(testProject);
+ var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework);
var publishCommand = new PublishCommand(testProjectInstance);
publishCommand.Execute().Should().Pass();
@@ -99,7 +100,7 @@ public void It_creates_readytorun_images_for_all_assemblies_except_excluded_ones
[InlineData("net6.0")]
public void It_creates_readytorun_symbols_when_switch_is_used(string targetFramework)
{
- TestProjectPublishing_Internal("CrossgenTest3", targetFramework, emitNativeSymbols: true);
+ TestProjectPublishing_Internal("CrossgenTest3", targetFramework, emitNativeSymbols: true, identifier: targetFramework);
}
[Theory]
@@ -108,7 +109,7 @@ public void It_creates_readytorun_symbols_when_switch_is_used(string targetFrame
[InlineData("net6.0")]
public void It_supports_framework_dependent_publishing(string targetFramework)
{
- TestProjectPublishing_Internal("FrameworkDependent", targetFramework, isSelfContained: false, emitNativeSymbols:true);
+ TestProjectPublishing_Internal("FrameworkDependent", targetFramework, isSelfContained: false, emitNativeSymbols:true, identifier: targetFramework);
}
[Theory]
@@ -157,7 +158,7 @@ public void It_does_not_support_cross_platform_readytorun_compilation(string tar
testProject.AdditionalProperties["PublishReadyToRun"] = "True";
- var testProjectInstance = _testAssetsManager.CreateTestProject(testProject);
+ var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework);
var publishCommand = new PublishCommand(testProjectInstance);
@@ -195,7 +196,7 @@ public void It_warns_when_targetting_netcoreapp_2_x_readytorun()
[InlineData("net6.0")]
public void It_can_publish_readytorun_for_library_projects(string targetFramework)
{
- TestProjectPublishing_Internal("LibraryProject1", targetFramework, isSelfContained: false, makeExeProject: false);
+ TestProjectPublishing_Internal("LibraryProject1", targetFramework, isSelfContained: false, makeExeProject: false, identifier: targetFramework);
}
[Theory]
@@ -204,7 +205,7 @@ public void It_can_publish_readytorun_for_library_projects(string targetFramewor
[InlineData("net6.0")]
public void It_can_publish_readytorun_for_selfcontained_library_projects(string targetFramework)
{
- TestProjectPublishing_Internal("LibraryProject2", targetFramework, isSelfContained:true, makeExeProject: false);
+ TestProjectPublishing_Internal("LibraryProject2", targetFramework, isSelfContained:true, makeExeProject: false, identifier: targetFramework);
}
[RequiresMSBuildVersionTheory("16.8.0")]
@@ -222,7 +223,7 @@ void It_can_publish_readytorun_using_crossgen2(string targetFramework)
// and will be available from Preview 3 onward.
bool emitNativeSymbols = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
- TestProjectPublishing_Internal("Crossgen2TestApp", targetFramework, isSelfContained: true, emitNativeSymbols: emitNativeSymbols, useCrossgen2: true, composite: false);
+ TestProjectPublishing_Internal("Crossgen2TestApp", targetFramework, isSelfContained: true, emitNativeSymbols: emitNativeSymbols, useCrossgen2: true, composite: false, identifier: targetFramework);
}
[RequiresMSBuildVersionTheory("16.8.0")]
@@ -244,7 +245,7 @@ void It_can_publish_readytorun_using_crossgen2_composite_mode(string targetFrame
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.OSArchitecture != Architecture.X64)
return;
- TestProjectPublishing_Internal("Crossgen2TestApp", targetFramework, isSelfContained: true, emitNativeSymbols: false, useCrossgen2: true, composite: true);
+ TestProjectPublishing_Internal("Crossgen2TestApp", targetFramework, isSelfContained: true, emitNativeSymbols: false, useCrossgen2: true, composite: true, identifier: targetFramework);
}
[RequiresMSBuildVersionTheory("16.8.0")]
@@ -267,13 +268,21 @@ public void It_supports_libraries_when_using_crossgen2(string targetFramework)
testProject.AdditionalProperties["PublishReadyToRunUseCrossgen2"] = "True";
testProject.AdditionalProperties["SelfContained"] = "False";
- var testProjectInstance = _testAssetsManager.CreateTestProject(testProject);
+ var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, targetFramework);
var publishCommand = new PublishCommand(Log, Path.Combine(testProjectInstance.Path, testProject.Name));
publishCommand.Execute().Should().Pass();
}
- private void TestProjectPublishing_Internal(string projectName, string targetFramework, bool makeExeProject = true, bool isSelfContained = true, bool emitNativeSymbols = false, bool useCrossgen2 = false, bool composite = true)
+ private void TestProjectPublishing_Internal(string projectName,
+ string targetFramework,
+ bool makeExeProject = true,
+ bool isSelfContained = true,
+ bool emitNativeSymbols = false,
+ bool useCrossgen2 = false,
+ bool composite = true,
+ [CallerMemberName] string callingMethod = "",
+ string identifier = null)
{
var testProject = CreateTestProjectForR2RTesting(
targetFramework,
@@ -287,7 +296,7 @@ private void TestProjectPublishing_Internal(string projectName, string targetFra
testProject.AdditionalProperties["PublishReadyToRunComposite"] = composite ? "True" : "False";
testProject.AdditionalProperties["SelfContained"] = isSelfContained ? "True" : "False";
- var testProjectInstance = _testAssetsManager.CreateTestProject(testProject);
+ var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, callingMethod, identifier);
var publishCommand = new PublishCommand(testProjectInstance);
publishCommand.Execute().Should().Pass();
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishToClickOnce.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishToClickOnce.cs
index 52c37c6ed06f..f07a3ff59291 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishToClickOnce.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishToClickOnce.cs
@@ -40,7 +40,7 @@ public void It_publishes_with_a_publish_profile(bool? publishSingleFile)
};
testProject.PackageReferences.Add(new TestPackageReference("NewtonSoft.Json", "9.0.1"));
- var testProjectInstance = _testAssetsManager.CreateTestProject(testProject);
+ var testProjectInstance = _testAssetsManager.CreateTestProject(testProject, identifier: publishSingleFile.ToString());
var projectDirectory = Path.Combine(testProjectInstance.Path, testProject.Name);
var publishProfilesDirectory = Path.Combine(projectDirectory, "Properties", "PublishProfiles");
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishWithGeneratePackageOnBuildAndPackAsTool.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishWithGeneratePackageOnBuildAndPackAsTool.cs
index 43605ad43c3a..d305c1452745 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishWithGeneratePackageOnBuildAndPackAsTool.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishWithGeneratePackageOnBuildAndPackAsTool.cs
@@ -56,7 +56,7 @@ public void It_publishes_successfully(bool generatePackageOnBuild, bool packAsTo
[InlineData(false, true)]
[InlineData(true, false)]
[InlineData(true, true)]
- public void It_builds_successfully(bool generatePackageOnBuild, bool packAsTool)
+ public void It_builds_with_GeneratePackageOnBuild_successfully(bool generatePackageOnBuild, bool packAsTool)
{
TestAsset testAsset = _testAssetsManager
.CopyTestAsset("HelloWorld", identifier: generatePackageOnBuild.ToString() + packAsTool.ToString())
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishWithoutConflicts.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishWithoutConflicts.cs
index 1797a60ad017..9b051e786de4 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishWithoutConflicts.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishWithoutConflicts.cs
@@ -72,7 +72,7 @@ public void It_has_consistent_behavior_when_publishing_single_file(bool shouldPu
// runtime package. Without _HandleFileConflictsForPublish this would be caught when by the bundler when publishing single file, but a normal publish would succeed with double writes.
testProject.PackageReferences.Add(new TestPackageReference("Microsoft.TestPlatform.CLI", "16.5.0"));
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: shouldPublishSingleFile.ToString());
var getValuesCommand = new GetValuesCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name), targetFramework, "ResolvedFileToPublish", GetValuesCommand.ValueType.Item)
{
DependsOnTargets = "Publish"
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs
index 9a0ae689bce8..04443703a016 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs
@@ -116,7 +116,7 @@ public void ILLink_links_simple_app_without_analysis_warnings_and_it_runs(string
var rid = EnvironmentInfo.GetCompatibleRid(targetFramework);
var testProject = CreateTestProjectForILLinkTesting(targetFramework, projectName);
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework + trimMode);
var publishCommand = new PublishCommand(testAsset);
publishCommand.Execute($"/p:RuntimeIdentifier={rid}", "/p:SelfContained=true", "/p:PublishTrimmed=true", $"/p:TrimMode={trimMode}", "/p:SuppressTrimAnalysisWarnings=true")
@@ -166,8 +166,8 @@ public void PrepareForILLink_can_set_TrimMode(string targetFramework)
var referenceProjectName = "ClassLibForILLink";
var rid = EnvironmentInfo.GetCompatibleRid(targetFramework);
- var testProject = CreateTestProjectForILLinkTesting(targetFramework, projectName, referenceProjectName);
- var testAsset = _testAssetsManager.CreateTestProject(testProject)
+ var testProject = CreateTestProjectForILLinkTesting(targetFramework, projectName, referenceProjectName, referenceProjectIdentifier: targetFramework);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework)
.WithProjectChanges(project => SetTrimMode(project, referenceProjectName, "link"));
var publishCommand = new PublishCommand(testAsset);
@@ -192,8 +192,8 @@ public void ILLink_respects_global_TrimMode(string targetFramework, string trimM
var referenceProjectName = "ClassLibForILLink";
var rid = EnvironmentInfo.GetCompatibleRid(targetFramework);
- var testProject = CreateTestProjectForILLinkTesting(targetFramework, projectName, referenceProjectName);
- var testAsset = _testAssetsManager.CreateTestProject(testProject)
+ var testProject = CreateTestProjectForILLinkTesting(targetFramework, projectName, referenceProjectName, referenceProjectIdentifier: targetFramework);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework)
.WithProjectChanges(project => SetGlobalTrimMode(project, trimMode))
.WithProjectChanges(project => SetIsTrimmable(project, referenceProjectName))
.WithProjectChanges(project => AddRootDescriptor(project, $"{referenceProjectName}.xml"));
@@ -227,7 +227,7 @@ public void ILLink_roots_IntermediateAssembly(string targetFramework)
var rid = EnvironmentInfo.GetCompatibleRid(targetFramework);
var testProject = CreateTestProjectForILLinkTesting(targetFramework, projectName);
- var testAsset = _testAssetsManager.CreateTestProject(testProject)
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework)
.WithProjectChanges(project => SetGlobalTrimMode(project, "link"))
.WithProjectChanges(project => SetIsTrimmable(project, projectName));
@@ -603,7 +603,7 @@ public void StartupHookSupport_is_false_by_default_on_trimmed_apps(string target
var rid = EnvironmentInfo.GetCompatibleRid(targetFramework);
var testProject = CreateTestProjectForILLinkTesting(targetFramework, projectName);
- var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: projectName);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: projectName + targetFramework);
var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
publishCommand.Execute($"/p:RuntimeIdentifier={rid}", "/p:PublishTrimmed=true")
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupOutputsTests.cs b/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupOutputsTests.cs
index fa95f5e90e35..5226af5c1c5e 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupOutputsTests.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupOutputsTests.cs
@@ -55,7 +55,7 @@ public void RunPublishItemsOutputGroupOutputsTest(bool specifyRid, bool singleFi
testProject.AdditionalProperties["PublishSingleFile"] = "true";
}
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: specifyRid.ToString() + singleFile.ToString());
var restoreCommand = new RestoreCommand(testAsset);
restoreCommand
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs b/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs
index 7334431c2960..acc8bdc15e1d 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/PublishItemsOutputGroupTests.cs
@@ -37,7 +37,7 @@ public PublishItemsOutputGroupTests(ITestOutputHelper log) : base(log)
public void RunPublishItemsOutputGroupTest(bool specifyRid, bool singleFile)
{
var testProject = this.SetupProject(specifyRid, singleFile);
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: specifyRid.ToString() + singleFile.ToString());
var restoreCommand = new RestoreCommand(testAsset);
restoreCommand
diff --git a/src/Tests/Microsoft.NET.Restore.Tests/GivenThatWeWantAutomaticTargetingPackReferences.cs b/src/Tests/Microsoft.NET.Restore.Tests/GivenThatWeWantAutomaticTargetingPackReferences.cs
index 8f737790692f..2ce9dc3b99b3 100644
--- a/src/Tests/Microsoft.NET.Restore.Tests/GivenThatWeWantAutomaticTargetingPackReferences.cs
+++ b/src/Tests/Microsoft.NET.Restore.Tests/GivenThatWeWantAutomaticTargetingPackReferences.cs
@@ -36,7 +36,7 @@ public void It_restores_net_framework_project_successfully(string version)
TargetFrameworks = targetFramework,
};
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: version);
string projectAssetsJsonPath = Path.Combine(
testAsset.Path,
@@ -77,7 +77,7 @@ public void It_restores_multitargeted_net_framework_project_successfully(bool in
if (includeExplicitReference)
{
// Add explicit reference to assembly packs
- testAsset = _testAssetsManager.CreateTestProject(testProject).WithProjectChanges(project =>
+ testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: includeExplicitReference.ToString()).WithProjectChanges(project =>
{
var ns = project.Root.Name.Namespace;
var itemGroup = project.Root.Elements(ns + "ItemGroup").FirstOrDefault();
diff --git a/src/Tests/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/WasmPublishTest.cs b/src/Tests/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/WasmPublishTest.cs
index d2f1957d9152..edeafe87d375 100644
--- a/src/Tests/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/WasmPublishTest.cs
+++ b/src/Tests/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/WasmPublishTest.cs
@@ -250,7 +250,7 @@ public void Publish_WithStaticWebBasePathWorks(string basePath)
{
// Arrange
var testAppName = "BlazorWasmWithLibrary";
- var testInstance = CreateAspNetSdkTestAsset(testAppName);
+ var testInstance = CreateAspNetSdkTestAsset(testAppName, identifier: basePath);
testInstance.WithProjectChanges((path, project) =>
{
@@ -311,7 +311,7 @@ public void Publish_WithStaticWebBasePathWorks(string basePath)
public void Publish_Hosted_WithStaticWebBasePathWorks(string basePath)
{
var testAppName = "BlazorHosted";
- var testInstance = CreateAspNetSdkTestAsset(testAppName);
+ var testInstance = CreateAspNetSdkTestAsset(testAppName, identifier: basePath);
testInstance.WithProjectChanges((path, project) =>
{
diff --git a/src/Tests/Microsoft.NET.TestFramework/AspNetSdkTest.cs b/src/Tests/Microsoft.NET.TestFramework/AspNetSdkTest.cs
index df3aac7345ab..0ad9366ad9be 100644
--- a/src/Tests/Microsoft.NET.TestFramework/AspNetSdkTest.cs
+++ b/src/Tests/Microsoft.NET.TestFramework/AspNetSdkTest.cs
@@ -27,10 +27,11 @@ public TestAsset CreateAspNetSdkTestAsset(
string testAsset,
[CallerMemberName] string callerName = "",
string subdirectory = "",
- string overrideTfm = null)
+ string overrideTfm = null,
+ string identifier = null)
{
var projectDirectory = _testAssetsManager
- .CopyTestAsset(testAsset, callingMethod: callerName, testAssetSubdirectory: subdirectory)
+ .CopyTestAsset(testAsset, callingMethod: callerName, testAssetSubdirectory: subdirectory, identifier: identifier)
.WithSource()
.WithProjectChanges(project =>
{
diff --git a/src/Tests/Microsoft.NET.TestFramework/TestAssetsManager.cs b/src/Tests/Microsoft.NET.TestFramework/TestAssetsManager.cs
index e9e2617b50bb..222d7f5cafcb 100644
--- a/src/Tests/Microsoft.NET.TestFramework/TestAssetsManager.cs
+++ b/src/Tests/Microsoft.NET.TestFramework/TestAssetsManager.cs
@@ -139,7 +139,15 @@ public static string GetTestDestinationDirectoryPath(
}
}
- return Path.Combine(baseDirectory, directoryName.ToString());
+ var directoryPath = Path.Combine(baseDirectory, directoryName.ToString());
+#if CI_BUILD
+ if (Directory.Exists(directoryPath))
+ {
+ throw new Exception($"Test dir {directoryPath} already exists");
+ }
+#endif
+
+ return directoryPath;
}
}
}
diff --git a/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithComplexNugetDependency.cs b/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithComplexNugetDependency.cs
index 381fa9705886..ae43fb67b79e 100644
--- a/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithComplexNugetDependency.cs
+++ b/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithComplexNugetDependency.cs
@@ -30,7 +30,7 @@ public GivenThatWeWantToPackAToolProjectWithComplexNugetDependency(ITestOutputHe
public void It_has_native_and_transitive_dependencies_dll(bool multiTarget)
{
TestAsset helloWorldAsset = _testAssetsManager
- .CopyTestAsset("PortableTool")
+ .CopyTestAsset("PortableTool", identifier: multiTarget.ToString())
.WithSource()
.WithProjectChanges(project =>
{
diff --git a/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithPackagedShim.cs b/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithPackagedShim.cs
index f29a2f08c478..2f257139d26e 100644
--- a/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithPackagedShim.cs
+++ b/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithPackagedShim.cs
@@ -151,7 +151,7 @@ public void It_uses_customized_PackagedShimOutputRootDirectory(bool multiTarget,
{
string shimoutputPath = Path.Combine(TestContext.Current.TestExecutionDirectory, "shimoutput");
TestAsset helloWorldAsset = _testAssetsManager
- .CopyTestAsset("PortableTool", "PackagedShimOutputRootDirectory" + multiTarget.ToString())
+ .CopyTestAsset("PortableTool", "PackagedShimOutputRootDirectory" + multiTarget.ToString(), identifier: multiTarget.ToString() + targetFramework)
.WithSource()
.WithProjectChanges(project =>
{
diff --git a/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolSelfContainedProject.cs b/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolSelfContainedProject.cs
index e69737c16891..0a2dd5ebcc7d 100644
--- a/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolSelfContainedProject.cs
+++ b/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolSelfContainedProject.cs
@@ -12,6 +12,7 @@
using Microsoft.DotNet.Cli.Utils;
using Microsoft.NET.Build.Tasks;
using System.Collections.Generic;
+using System.Runtime.CompilerServices;
namespace Microsoft.NET.ToolPack.Tests
{
@@ -47,10 +48,10 @@ public void It_should_not_fail_on_build()
result.ExitCode.Should().Be(0);
}
- private TestAsset CreateAsset()
+ private TestAsset CreateAsset([CallerMemberName] string callingMethod = "")
{
TestAsset helloWorldAsset = _testAssetsManager
- .CopyTestAsset("PortableTool", "PackSelfContainedTool")
+ .CopyTestAsset("PortableTool", callingMethod)
.WithSource()
.WithProjectChanges(project =>
{
diff --git a/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolTargetingNonSupportedTFM.cs b/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolTargetingNonSupportedTFM.cs
index c1bed95fda64..9de4a6293f97 100644
--- a/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolTargetingNonSupportedTFM.cs
+++ b/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolTargetingNonSupportedTFM.cs
@@ -36,7 +36,7 @@ public void It_should_fail_with_error_message(string targetFrameworkProperty,
string expectedErrorResourceName)
{
TestAsset helloWorldAsset = _testAssetsManager
- .CopyTestAsset("PortableTool", "PackNonSupportedTFM")
+ .CopyTestAsset("PortableTool", "PackNonSupportedTFM", identifier: targetFrameworkProperty + targetFramework)
.WithSource()
.WithProjectChanges(project =>
{
diff --git a/src/Tests/dotnet-add-package.Tests/GivenDotnetPackageAdd.cs b/src/Tests/dotnet-add-package.Tests/GivenDotnetPackageAdd.cs
index 23a5c65fdca9..afc7aea2d0d0 100644
--- a/src/Tests/dotnet-add-package.Tests/GivenDotnetPackageAdd.cs
+++ b/src/Tests/dotnet-add-package.Tests/GivenDotnetPackageAdd.cs
@@ -12,6 +12,7 @@
using Microsoft.NET.TestFramework.ProjectConstruction;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.CompilerServices;
namespace Microsoft.DotNet.Cli.Package.Add.Tests
{
@@ -63,12 +64,12 @@ public void WhenPrereleaseOptionIsPassed(string[] inputVersions, string expected
TargetFrameworks = targetFramework,
};
- var packages = inputVersions.Select(e => GetPackagePath(targetFramework, "A", e)).ToArray();
+ var packages = inputVersions.Select(e => GetPackagePath(targetFramework, "A", e, identifier: expectedVersion + e + inputVersions.GetHashCode().ToString())).ToArray();
testProject.AdditionalProperties.Add("RestoreSources",
- "$(RestoreSources);" + Path.GetDirectoryName(packages[0]));
+ "$(RestoreSources);" + string.Join(";", packages.Select(package => Path.GetDirectoryName(package))));
- var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: inputVersions.GetHashCode().ToString());
var cmd = new DotnetCommand(Log)
.WithWorkingDirectory(Path.Combine(testAsset.TestRoot, testProject.Name))
@@ -249,10 +250,10 @@ private static TestProject GetProject(string targetFramework, string referencePr
return project;
}
- private string GetPackagePath(string targetFramework, string packageName, string version)
+ private string GetPackagePath(string targetFramework, string packageName, string version, [CallerMemberName] string callingMethod = "", string identifier = null)
{
var project = GetProject(targetFramework, packageName, version);
- var packCommand = new PackCommand(Log, _testAssetsManager.CreateTestProject(project).TestRoot, packageName);
+ var packCommand = new PackCommand(Log, _testAssetsManager.CreateTestProject(project, callingMethod: callingMethod, identifier: identifier).TestRoot, packageName);
packCommand
.Execute()
diff --git a/src/Tests/dotnet-add-reference.Tests/GivenDotnetAddReference.cs b/src/Tests/dotnet-add-reference.Tests/GivenDotnetAddReference.cs
index 9a288a157900..127d5bcab47e 100644
--- a/src/Tests/dotnet-add-reference.Tests/GivenDotnetAddReference.cs
+++ b/src/Tests/dotnet-add-reference.Tests/GivenDotnetAddReference.cs
@@ -65,7 +65,7 @@ public GivenDotnetAddReference(ITestOutputHelper log) : base(log)
private TestSetup Setup([System.Runtime.CompilerServices.CallerMemberName] string callingMethod = nameof(Setup), string identifier = "")
{
return new TestSetup(
- _testAssetsManager.CopyTestAsset(TestSetup.ProjectName, callingMethod + nameof(GivenDotnetAddReference), identifier, testAssetSubdirectory: TestSetup.TestGroup)
+ _testAssetsManager.CopyTestAsset(TestSetup.ProjectName, callingMethod + nameof(GivenDotnetAddReference), identifier: identifier + callingMethod, testAssetSubdirectory: TestSetup.TestGroup)
.WithSource()
.Path);
}
@@ -144,7 +144,7 @@ public void WhenTooManyArgumentsArePassedItPrintsError()
[InlineData("ihave?inv@lid/char\\acters")]
public void WhenNonExistingProjectIsPassedItPrintsErrorAndUsage(string projName)
{
- var setup = Setup();
+ var setup = Setup(identifier: projName);
var cmd = new DotnetCommand(Log, "add", projName, "reference")
.WithWorkingDirectory(setup.TestRoot)
@@ -681,7 +681,7 @@ public void WhenFrameworkSwitchIsNotMatchingAnyOfTargetedFrameworksItPrintsError
[InlineData(true)]
public void WhenIncompatibleFrameworkDetectedItPrintsError(bool useFrameworkArg)
{
- var setup = Setup();
+ var setup = Setup(useFrameworkArg.ToString());
var lib = new ProjDir(setup.LibDir);
var net45lib = new ProjDir(Path.Combine(setup.TestRoot, "Net45Lib"));
diff --git a/src/Tests/dotnet-list-package.Tests/GivenDotnetListPackage.cs b/src/Tests/dotnet-list-package.Tests/GivenDotnetListPackage.cs
index 639afa6ae6f7..9e7a87c0efd4 100644
--- a/src/Tests/dotnet-list-package.Tests/GivenDotnetListPackage.cs
+++ b/src/Tests/dotnet-list-package.Tests/GivenDotnetListPackage.cs
@@ -195,7 +195,7 @@ public void ItListsValidFrameworks(string args, string shouldInclude, string sho
{
var testAssetName = "MSBuildAppWithMultipleFrameworks";
var testAsset = _testAssetsManager
- .CopyTestAsset(testAssetName)
+ .CopyTestAsset(testAssetName, identifier: args.GetHashCode().ToString() + shouldInclude)
.WithSource();
var projectDirectory = testAsset.Path;
diff --git a/src/Tests/dotnet-list-reference.Tests/GivenDotnetListReference.cs b/src/Tests/dotnet-list-reference.Tests/GivenDotnetListReference.cs
index 48b82ab6e853..038b7f080f49 100644
--- a/src/Tests/dotnet-list-reference.Tests/GivenDotnetListReference.cs
+++ b/src/Tests/dotnet-list-reference.Tests/GivenDotnetListReference.cs
@@ -91,7 +91,7 @@ public void WhenTooManyArgumentsArePassedItPrintsError()
[InlineData("ihave?inv@lid/char\\acters")]
public void WhenNonExistingProjectIsPassedItPrintsErrorAndUsage(string projName)
{
- var setup = Setup();
+ var setup = Setup(identifier: projName);
var cmd = new ListReferenceCommand(Log)
.WithProject(projName)
diff --git a/src/Tests/dotnet-msbuild.Tests/GivenDotnetMSBuildBuildsProjects.cs b/src/Tests/dotnet-msbuild.Tests/GivenDotnetMSBuildBuildsProjects.cs
index db6b080c776e..0fee23bb6e46 100644
--- a/src/Tests/dotnet-msbuild.Tests/GivenDotnetMSBuildBuildsProjects.cs
+++ b/src/Tests/dotnet-msbuild.Tests/GivenDotnetMSBuildBuildsProjects.cs
@@ -94,7 +94,7 @@ public void WhenRestoreSourcesStartsWithUnixPathThenHttpsSourceIsParsedCorrectly
}
// this is a workaround for https://github.com/Microsoft/msbuild/issues/1622
- var testInstance = _testAssetsManager.CopyTestAsset("LibraryWithUnresolvablePackageReference")
+ var testInstance = _testAssetsManager.CopyTestAsset("LibraryWithUnresolvablePackageReference", identifier: propertyFormat.GetHashCode().ToString())
.WithSource();
var root = testInstance.Path;
diff --git a/src/Tests/dotnet-remove-reference.Tests/GivenDotnetRemoveP2P.cs b/src/Tests/dotnet-remove-reference.Tests/GivenDotnetRemoveP2P.cs
index 5f75e0c14e7d..fe998be7e7ce 100644
--- a/src/Tests/dotnet-remove-reference.Tests/GivenDotnetRemoveP2P.cs
+++ b/src/Tests/dotnet-remove-reference.Tests/GivenDotnetRemoveP2P.cs
@@ -63,7 +63,7 @@ public GivenDotnetRemoveReference(ITestOutputHelper log) : base(log)
private TestSetup Setup([System.Runtime.CompilerServices.CallerMemberName] string callingMethod = nameof(Setup), string identifier = "")
{
return new TestSetup(
- _testAssetsManager.CopyTestAsset(TestSetup.ProjectName, callingMethod: callingMethod + nameof(GivenDotnetRemoveReference), identifier: identifier, testAssetSubdirectory: TestAssetSubdirectories.NonRestoredTestProjects)
+ _testAssetsManager.CopyTestAsset(TestSetup.ProjectName, callingMethod: callingMethod + nameof(GivenDotnetRemoveReference), identifier: identifier + callingMethod, testAssetSubdirectory: TestAssetSubdirectories.NonRestoredTestProjects)
.WithSource()
.Path);
}
@@ -179,7 +179,7 @@ public void WhenTooManyArgumentsArePassedItPrintsError()
[InlineData("ihave?inv@lid/char\\acters")]
public void WhenNonExistingProjectIsPassedItPrintsErrorAndUsage(string projName)
{
- var setup = Setup();
+ var setup = Setup(identifier: projName.GetHashCode().ToString());
var cmd = new RemoveReferenceCommand(Log)
.WithProject(projName)
diff --git a/src/Tests/dotnet-restore.Tests/GivenThatIWantToRestoreApp.cs b/src/Tests/dotnet-restore.Tests/GivenThatIWantToRestoreApp.cs
index 528597147d61..e75f0c7aabc9 100644
--- a/src/Tests/dotnet-restore.Tests/GivenThatIWantToRestoreApp.cs
+++ b/src/Tests/dotnet-restore.Tests/GivenThatIWantToRestoreApp.cs
@@ -28,14 +28,14 @@ public GivenThatIWantToRestoreApp(ITestOutputHelper log) : base(log)
[InlineData(false)]
public void ItRestoresAppToSpecificDirectory(bool useStaticGraphEvaluation)
{
- var rootPath = _testAssetsManager.CreateTestDirectory().Path;
+ var rootPath = _testAssetsManager.CreateTestDirectory(identifier: useStaticGraphEvaluation.ToString()).Path;
string dir = "pkgs";
string fullPath = Path.GetFullPath(Path.Combine(rootPath, dir));
var sln = "TestAppWithSlnAndSolutionFolders";
var projectDirectory = _testAssetsManager
- .CopyTestAsset(sln)
+ .CopyTestAsset(sln, identifier: useStaticGraphEvaluation.ToString())
.WithSource()
.Path;
@@ -67,7 +67,7 @@ public void ItRestoresLibToSpecificDirectory(bool useStaticGraphEvaluation, stri
testProject.PackageReferences.Add(new TestPackageReference("Newtonsoft.Json", "12.0.3"));
- var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: useStaticGraphEvaluation.ToString(), targetExtension: extension);
+ var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: useStaticGraphEvaluation.ToString() + extension, targetExtension: extension);
var rootPath = Path.Combine(testAsset.TestRoot, testProject.Name);
@@ -105,7 +105,7 @@ public void ItRestoresLibToSpecificDirectory(bool useStaticGraphEvaluation, stri
[InlineData(false)]
public void ItRestoresTestAppToSpecificDirectory(bool useStaticGraphEvaluation)
{
- var rootPath = _testAssetsManager.CopyTestAsset("VSTestCore")
+ var rootPath = _testAssetsManager.CopyTestAsset("VSTestCore", identifier: useStaticGraphEvaluation.ToString())
.WithSource()
.WithVersionVariables()
.Path;
@@ -131,7 +131,7 @@ public void ItRestoresTestAppToSpecificDirectory(bool useStaticGraphEvaluation)
[InlineData(false)]
public void ItRestoresWithTheSpecifiedVerbosity(bool useStaticGraphEvaluation)
{
- var rootPath = _testAssetsManager.CreateTestDirectory().Path;
+ var rootPath = _testAssetsManager.CreateTestDirectory(identifier: useStaticGraphEvaluation.ToString()).Path;
string dir = "pkgs";
string fullPath = Path.GetFullPath(Path.Combine(rootPath, dir));
diff --git a/src/Tests/dotnet-sln.Tests/GivenDotnetSlnAdd.cs b/src/Tests/dotnet-sln.Tests/GivenDotnetSlnAdd.cs
index 82109c0e41ba..6b04afea1f47 100644
--- a/src/Tests/dotnet-sln.Tests/GivenDotnetSlnAdd.cs
+++ b/src/Tests/dotnet-sln.Tests/GivenDotnetSlnAdd.cs
@@ -684,7 +684,7 @@ public void WhenProjectDirectoryIsAddedSolutionFoldersAreNotCreated()
public void WhenSolutionFolderExistsItDoesNotGetAdded(string firstComponent)
{
var projectDirectory = _testAssetsManager
- .CopyTestAsset("TestAppWithSlnAndSolutionFolders")
+ .CopyTestAsset("TestAppWithSlnAndSolutionFolders", identifier: firstComponent)
.WithSource()
.Path;
diff --git a/src/Tests/dotnet-watch.Tests/FileWatcherTests.cs b/src/Tests/dotnet-watch.Tests/FileWatcherTests.cs
index bfa47dd46c2a..673907ef2d5e 100644
--- a/src/Tests/dotnet-watch.Tests/FileWatcherTests.cs
+++ b/src/Tests/dotnet-watch.Tests/FileWatcherTests.cs
@@ -38,7 +38,7 @@ public async Task NewFile(bool usePolling)
return;
}
- var dir = _testAssetManager.CreateTestDirectory().Path;
+ var dir = _testAssetManager.CreateTestDirectory(identifier: usePolling.ToString()).Path;
using var watcher = FileWatcherFactory.CreateWatcher(dir, usePolling);
@@ -70,7 +70,7 @@ public async Task ChangeFile(bool usePolling)
return;
}
- var dir = _testAssetManager.CreateTestDirectory().Path;
+ var dir = _testAssetManager.CreateTestDirectory(identifier: usePolling.ToString()).Path;
var testFileFullPath = Path.Combine(dir, "foo");
File.WriteAllText(testFileFullPath, string.Empty);
@@ -117,7 +117,7 @@ public async Task MoveFile(bool usePolling)
return;
}
- var dir = _testAssetManager.CreateTestDirectory().Path;
+ var dir = _testAssetManager.CreateTestDirectory(identifier: usePolling.ToString()).Path;
var srcFile = Path.Combine(dir, "foo");
var dstFile = Path.Combine(dir, "foo2");
@@ -207,7 +207,7 @@ public async Task NoNotificationIfDisabled(bool usePolling)
return;
}
- var dir = _testAssetManager.CreateTestDirectory().Path;
+ var dir = _testAssetManager.CreateTestDirectory(identifier: usePolling.ToString()).Path;
using var watcher = FileWatcherFactory.CreateWatcher(dir, usePolling);
@@ -242,7 +242,7 @@ public async Task DisposedNoEvents(bool usePolling)
return;
}
- var dir = _testAssetManager.CreateTestDirectory().Path;
+ var dir = _testAssetManager.CreateTestDirectory(identifier: usePolling.ToString()).Path;
var changedEv = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
using (var watcher = FileWatcherFactory.CreateWatcher(dir, usePolling))
{
@@ -275,7 +275,7 @@ public async Task MultipleFiles(bool usePolling)
return;
}
- var dir = _testAssetManager.CreateTestDirectory().Path;
+ var dir = _testAssetManager.CreateTestDirectory(identifier: usePolling.ToString()).Path;
File.WriteAllText(Path.Combine(dir, "foo1"), string.Empty);
File.WriteAllText(Path.Combine(dir, "foo2"), string.Empty);
@@ -325,7 +325,7 @@ public async Task MultipleTriggers(bool usePolling)
return;
}
- var dir = _testAssetManager.CreateTestDirectory().Path;
+ var dir = _testAssetManager.CreateTestDirectory(identifier: usePolling.ToString()).Path;
using var watcher = FileWatcherFactory.CreateWatcher(dir, usePolling);
@@ -391,7 +391,7 @@ public async Task DeleteSubfolder(bool usePolling)
return;
}
- var dir = _testAssetManager.CreateTestDirectory().Path;
+ var dir = _testAssetManager.CreateTestDirectory(usePolling.ToString()).Path;
var subdir = Path.Combine(dir, "subdir");
Directory.CreateDirectory(subdir);
diff --git a/src/Tests/dotnet-watch.Tests/GlobbingAppTests.cs b/src/Tests/dotnet-watch.Tests/GlobbingAppTests.cs
index ba22d328a7a6..b6e42ab0c043 100644
--- a/src/Tests/dotnet-watch.Tests/GlobbingAppTests.cs
+++ b/src/Tests/dotnet-watch.Tests/GlobbingAppTests.cs
@@ -31,7 +31,7 @@ public GlobbingAppTests(ITestOutputHelper logger)
[InlineData(false)]
public async Task ChangeCompiledFile(bool usePollingWatcher)
{
- var testAsset = _testAssetsManager.CopyTestAsset(AppName)
+ var testAsset = _testAssetsManager.CopyTestAsset(AppName, identifier: usePollingWatcher.ToString())
.WithSource()
.Path;