Skip to content

Allow MSBuild tests to access root of drive #7330

@mruxmohan4

Description

@mruxmohan4

Issue Description

Allow drive enumerating tests to access the root of a drive inside of Visual Studio. Currently, an UnauthorizedAccessException is thrown (so drive substitution is required for such tests to pass in VS).

Steps to Reproduce

Run subst z: <drive>:\<path> (or preferably, subst z: %TEMP%) on the command line for the below test to pass. This test can be added inside of CreateItem_Tests.cs.

       [Fact]
       public void WildcardDriveEnumerationTaskItemLogsWarning()
       {
           using (var env = TestEnvironment.Create())
           {
               ChangeWaves.ResetStateForTests();
               env.SetEnvironmentVariable("MSBUILDFAILONDRIVEENUMERATINGWILDCARD", "0");
               BuildEnvironmentHelper.ResetInstance_ForUnitTestsOnly();

               CreateItem t = new CreateItem();
               MockEngine engine = new MockEngine();

               t.BuildEngine = engine;
               t.Include = new ITaskItem[] { new TaskItem(@"z:\**\*.log") };
               bool succeeded = t.Execute();

               Assert.True(succeeded);
               Assert.Equal(1, engine.Warnings);
               engine.AssertLogContains("results in drive enumeration");

               ChangeWaves.ResetStateForTests();
           }
       }

Expected Behavior

The test case should pass and allow for drive enumeration to occur for MSBuild to properly log a warning when a drive enumerating wildcard is detected.

Actual Behavior

The test case throws an UnauthorizedAccessException and hangs.

Analysis

This occurs for attempts to log a warning in ProjectItem_Tests.cs and ProjectItemInstance_Tests.cs as well.

Versions & Configurations

Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

17.0.0.52104

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions