diff --git a/src/installer/tests/Assets/TestProjects/StaticHostApp/Program.cs b/src/installer/tests/Assets/TestProjects/StaticHostApp/Program.cs deleted file mode 100644 index c631d81d54048..0000000000000 --- a/src/installer/tests/Assets/TestProjects/StaticHostApp/Program.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace StaticHostApp -{ - public static class Program - { - public static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - } - } -} diff --git a/src/installer/tests/Assets/TestProjects/StaticHostApp/StaticHostApp.csproj b/src/installer/tests/Assets/TestProjects/StaticHostApp/StaticHostApp.csproj deleted file mode 100644 index eff31e8532b40..0000000000000 --- a/src/installer/tests/Assets/TestProjects/StaticHostApp/StaticHostApp.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - $(NETCoreAppFramework) - Exe - $(TestTargetRid) - $(MNAVersion) - - - - - - diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs index 3a0ed2c7f33e6..8decb64146690 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs @@ -23,7 +23,6 @@ public BundleRename(SharedTestState fixture) } [Theory] - [ActiveIssue("https://github.com/dotnet/runtime/issues/38013")] [InlineData(true)] // Test renaming the single-exe when contents are extracted [InlineData(false)] // Test renaming the single-exe when contents are not extracted private void Bundle_can_be_renamed_while_running(bool testExtraction) diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs index 78b5c9449fe1b..504ebe33e42e7 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs @@ -82,7 +82,7 @@ public class SharedTestState : IDisposable public SharedTestState() { RepoDirectories = new RepoDirectoriesProvider(); - TestFixture = new TestProjectFixture("StaticHostApp", RepoDirectories); + TestFixture = new TestProjectFixture("StandaloneApp", RepoDirectories); TestFixture .EnsureRestoredForRid(TestFixture.CurrentRid, RepoDirectories.CorehostPackages) .PublishProject(runtime: TestFixture.CurrentRid, diff --git a/src/installer/tests/TestUtils/TestApp.cs b/src/installer/tests/TestUtils/TestApp.cs index a1ff67d95c82e..4936dfe3cdb33 100644 --- a/src/installer/tests/TestUtils/TestApp.cs +++ b/src/installer/tests/TestUtils/TestApp.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.DotNet.CoreSetup.Test.HostActivation; using System.IO; namespace Microsoft.DotNet.CoreSetup.Test @@ -37,8 +36,6 @@ public TestApp(TestApp source) public static TestApp CreateEmpty(string name) { string location = GetNewTestArtifactPath(name); - FileUtils.EnsureDirectoryExists(location); - return new TestApp(location); } diff --git a/src/installer/tests/TestUtils/TestArtifact.cs b/src/installer/tests/TestUtils/TestArtifact.cs index d989a37e8f9f9..d514d21161019 100644 --- a/src/installer/tests/TestUtils/TestArtifact.cs +++ b/src/installer/tests/TestUtils/TestArtifact.cs @@ -2,9 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.DotNet.CoreSetup.Test.HostActivation; using System; using System.Collections.Generic; using System.IO; +using System.Threading; namespace Microsoft.DotNet.CoreSetup.Test { @@ -67,25 +69,26 @@ public virtual void Dispose() _copies.Clear(); } + private static readonly object _pathCountLock = new object(); protected static string GetNewTestArtifactPath(string artifactName) { int projectCount = 0; - string projectDirectory = Path.Combine(TestArtifactsPath, projectCount.ToString(), artifactName); + string projectCountDir() => Path.Combine(TestArtifactsPath, projectCount.ToString(), artifactName); - while (Directory.Exists(projectDirectory)) + for (; Directory.Exists(projectCountDir()); projectCount++); + + lock (_pathCountLock) { - projectDirectory = Path.Combine(TestArtifactsPath, (++projectCount).ToString(), artifactName); + string projectDirectory; + for (; Directory.Exists(projectDirectory = projectCountDir()); projectCount++); + FileUtils.EnsureDirectoryExists(projectDirectory); + return projectDirectory; } - - return projectDirectory; } protected static void CopyRecursive(string sourceDirectory, string destinationDirectory, bool overwrite = false) { - if (!Directory.Exists(destinationDirectory)) - { - Directory.CreateDirectory(destinationDirectory); - } + FileUtils.EnsureDirectoryExists(destinationDirectory); foreach (var dir in Directory.EnumerateDirectories(sourceDirectory)) {