Skip to content

Commit 6fe4ea5

Browse files
committed
Set current directory by default (#4798)
1 parent 070f12b commit 6fe4ea5

File tree

11 files changed

+21
-14
lines changed

11 files changed

+21
-14
lines changed

src/Servers/IIS/AspNetCoreModuleV2/InProcessRequestHandler/InProcessOptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ InProcessOptions::InProcessOptions(const ConfigurationSource &configurationSourc
5555
m_environmentVariables = aspNetCoreSection->GetKeyValuePairs(CS_ASPNETCORE_ENVIRONMENT_VARIABLES);
5656

5757
const auto handlerSettings = aspNetCoreSection->GetKeyValuePairs(CS_ASPNETCORE_HANDLER_SETTINGS);
58-
m_fSetCurrentDirectory = equals_ignore_case(find_element(handlerSettings, CS_ASPNETCORE_HANDLER_SET_CURRENT_DIRECTORY).value_or(L"false"), L"true");
58+
m_fSetCurrentDirectory = equals_ignore_case(find_element(handlerSettings, CS_ASPNETCORE_HANDLER_SET_CURRENT_DIRECTORY).value_or(L"true"), L"true");
5959

6060
m_dwStartupTimeLimitInMS = aspNetCoreSection->GetRequiredLong(CS_ASPNETCORE_PROCESS_STARTUP_TIME_LIMIT) * 1000;
6161
m_dwShutdownTimeLimitInMS = aspNetCoreSection->GetRequiredLong(CS_ASPNETCORE_PROCESS_SHUTDOWN_TIME_LIMIT) * 1000;

src/Servers/IIS/IIS/test/Common.FunctionalTests/Inprocess/ErrorPagesTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public async Task IncludesAdditionalErrorPageTextInProcessStartupFailure_Correct
105105

106106
private static void VerifyNoExtraTrailingBytes(string responseString)
107107
{
108-
if (!DeployerSelector.IsBackwardsCompatiblityTest)
108+
if (DeployerSelector.HasNewShim)
109109
{
110110
Assert.EndsWith("</html>\r\n", responseString);
111111
}

src/Servers/IIS/IIS/test/Common.FunctionalTests/Inprocess/HostingEnvironmentTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public async Task HostingEnvironmentIsCorrect()
2525
{
2626
Assert.Equal(_fixture.DeploymentResult.ContentRoot, await _fixture.Client.GetStringAsync("/ContentRootPath"));
2727
Assert.Equal(_fixture.DeploymentResult.ContentRoot + "\\wwwroot", await _fixture.Client.GetStringAsync("/WebRootPath"));
28-
Assert.Equal(Path.GetDirectoryName(_fixture.DeploymentResult.HostProcess.MainModule.FileName), await _fixture.Client.GetStringAsync("/CurrentDirectory"));
28+
Assert.Equal(_fixture.DeploymentResult.ContentRoot, await _fixture.DeploymentResult.HttpClient.GetStringAsync("/CurrentDirectory"));
2929
Assert.Equal(_fixture.DeploymentResult.ContentRoot + "\\", await _fixture.Client.GetStringAsync("/BaseDirectory"));
3030
Assert.Equal(_fixture.DeploymentResult.ContentRoot + "\\", await _fixture.Client.GetStringAsync("/ASPNETCORE_IIS_PHYSICAL_PATH"));
3131
}

src/Servers/IIS/IIS/test/Common.FunctionalTests/Inprocess/StartupTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,16 +454,15 @@ public static Dictionary<string, Func<IISDeploymentParameters, string>> InitStan
454454
public async Task SetCurrentDirectoryHandlerSettingWorks()
455455
{
456456
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
457-
deploymentParameters.HandlerSettings["SetCurrentDirectory"] = "true";
457+
deploymentParameters.HandlerSettings["SetCurrentDirectory"] = "false";
458458

459459
var deploymentResult = await DeployAsync(deploymentParameters);
460460

461461
Assert.Equal(deploymentResult.ContentRoot, await deploymentResult.HttpClient.GetStringAsync("/ContentRootPath"));
462462
Assert.Equal(deploymentResult.ContentRoot + "\\wwwroot", await deploymentResult.HttpClient.GetStringAsync("/WebRootPath"));
463-
Assert.Equal(deploymentResult.ContentRoot, await deploymentResult.HttpClient.GetStringAsync("/CurrentDirectory"));
463+
Assert.Equal(Path.GetDirectoryName(deploymentResult.HostProcess.MainModule.FileName), await deploymentResult.HttpClient.GetStringAsync("/CurrentDirectory"));
464464
Assert.Equal(deploymentResult.ContentRoot + "\\", await deploymentResult.HttpClient.GetStringAsync("/BaseDirectory"));
465465
Assert.Equal(deploymentResult.ContentRoot + "\\", await deploymentResult.HttpClient.GetStringAsync("/ASPNETCORE_IIS_PHYSICAL_PATH"));
466-
Assert.Equal(Path.GetDirectoryName(deploymentResult.HostProcess.MainModule.FileName), await deploymentResult.HttpClient.GetStringAsync("/DllDirectory"));
467466
}
468467

469468
private static void MoveApplication(

src/Servers/IIS/IIS/test/Common.FunctionalTests/OutOfProcess/HelloWorldTest.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,14 @@ public async Task HelloWorld(TestVariant variant)
7171

7272
Assert.Equal(deploymentResult.ContentRoot, await deploymentResult.HttpClient.GetStringAsync("/ContentRootPath"));
7373
Assert.Equal(deploymentResult.ContentRoot + "\\wwwroot", await deploymentResult.HttpClient.GetStringAsync("/WebRootPath"));
74-
Assert.Equal(deploymentResult.ContentRoot, await deploymentResult.HttpClient.GetStringAsync("/CurrentDirectory"));
75-
7674
var expectedDll = variant.AncmVersion == AncmVersion.AspNetCoreModule ? "aspnetcore.dll" : "aspnetcorev2.dll";
7775
Assert.Contains(deploymentResult.HostProcess.Modules.OfType<ProcessModule>(), m=> m.FileName.Contains(expectedDll));
76+
77+
if (DeployerSelector.HasNewHandler && variant.HostingModel == HostingModel.InProcess)
78+
{
79+
Assert.Equal(deploymentResult.ContentRoot, await deploymentResult.HttpClient.GetStringAsync("/CurrentDirectory"));
80+
Assert.Equal(Path.GetDirectoryName(deploymentResult.HostProcess.MainModule.FileName), await deploymentResult.HttpClient.GetStringAsync("/DllDirectory"));
81+
}
7882
}
7983
}
8084
}

src/Servers/IIS/IIS/test/Common.FunctionalTests/RequiresNewHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
99
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
1010
public sealed class RequiresNewHandlerAttribute : Attribute, ITestCondition
1111
{
12-
public bool IsMet => !DeployerSelector.IsForwardsCompatibilityTest;
12+
public bool IsMet => DeployerSelector.HasNewHandler;
1313

1414
public string SkipReason => "Test verifies new behavior in the aspnetcorev2_inprocess.dll that isn't supported in earlier versions.";
1515
}

src/Servers/IIS/IIS/test/Common.FunctionalTests/RequiresNewShim.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
99
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
1010
public sealed class RequiresNewShimAttribute : Attribute, ITestCondition
1111
{
12-
public bool IsMet => !DeployerSelector.IsBackwardsCompatiblityTest;
12+
public bool IsMet => DeployerSelector.HasNewShim;
1313

1414
public string SkipReason => "Test verifies new behavior in the aspnetcorev2.dll that isn't supported in earlier versions.";
1515
}

src/Servers/IIS/IIS/test/IIS.BackwardsCompatibility.FunctionalTests/DeployerSelector.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
88
public static class DeployerSelector
99
{
1010
public static ServerType ServerType => ServerType.IIS;
11-
public static bool IsBackwardsCompatiblityTest => true;
1211
public static bool IsForwardsCompatibilityTest => false;
12+
public static bool HasNewShim => false;
13+
public static bool HasNewHandler => true;
1314
}
1415
}

src/Servers/IIS/IIS/test/IIS.ForwardsCompatibility.FunctionalTests/DeployerSelector.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
88
public static class DeployerSelector
99
{
1010
public static ServerType ServerType => ServerType.IIS;
11-
public static bool IsBackwardsCompatiblityTest => false;
1211
public static bool IsForwardsCompatibilityTest => true;
12+
public static bool HasNewShim => true;
13+
public static bool HasNewHandler => false;
1314
}
1415
}

src/Servers/IIS/IIS/test/IIS.FunctionalTests/DeployerSelector.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
88
public static class DeployerSelector
99
{
1010
public static ServerType ServerType => ServerType.IIS;
11-
public static bool IsBackwardsCompatiblityTest => false;
1211
public static bool IsForwardsCompatibilityTest => false;
12+
public static bool HasNewShim => true;
13+
public static bool HasNewHandler => true;
1314
}
1415
}

0 commit comments

Comments
 (0)