Only run fallback logic for dotnet and dotnet.exe (#1004)
This commit is contained in:
parent
e7d36a42e6
commit
724cc3ce88
|
|
@ -128,11 +128,6 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
|
|||
fs::path processPath = Environment::ExpandEnvironmentVariables(pcwzProcessPath);
|
||||
std::wstring arguments = Environment::ExpandEnvironmentVariables(pcwzArguments);
|
||||
|
||||
if (processPath.is_relative())
|
||||
{
|
||||
processPath = applicationPhysicalPath / processPath;
|
||||
}
|
||||
|
||||
// Check if the absolute path is to dotnet or not.
|
||||
if (IsDotnetExecutable(processPath))
|
||||
{
|
||||
|
|
@ -143,7 +138,7 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
|
|||
// Get the absolute path to dotnet. If the path is already an absolute path, it will return that path
|
||||
//
|
||||
// Make sure to append the dotnet.exe path correctly here (pass in regular path)?
|
||||
auto fullProcessPath = GetAbsolutePathToDotnet(processPath);
|
||||
auto fullProcessPath = GetAbsolutePathToDotnet(applicationPhysicalPath, processPath);
|
||||
if (!fullProcessPath.has_value())
|
||||
{
|
||||
return E_FAIL;
|
||||
|
|
@ -172,6 +167,11 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
|
|||
{
|
||||
WLOG_INFOF(L"Process path %s is not dotnet, treating application as standalone", processPath.c_str());
|
||||
|
||||
if (processPath.is_relative())
|
||||
{
|
||||
processPath = applicationPhysicalPath / processPath;
|
||||
}
|
||||
|
||||
//
|
||||
// The processPath is a path to the application executable
|
||||
// like: C:\test\MyApp.Exe or MyApp.Exe
|
||||
|
|
@ -331,11 +331,18 @@ Finished:
|
|||
|
||||
std::optional<fs::path>
|
||||
HOSTFXR_UTILITY::GetAbsolutePathToDotnet(
|
||||
const fs::path & applicationPath,
|
||||
const fs::path & requestedPath
|
||||
)
|
||||
{
|
||||
WLOG_INFOF(L"Resolving absolute path to dotnet.exe from %s", requestedPath.c_str());
|
||||
|
||||
auto processPath = requestedPath;
|
||||
if (processPath.is_relative())
|
||||
{
|
||||
processPath = applicationPath / processPath;
|
||||
}
|
||||
|
||||
//
|
||||
// If we are given an absolute path to dotnet.exe, we are done
|
||||
//
|
||||
|
|
@ -360,7 +367,7 @@ HOSTFXR_UTILITY::GetAbsolutePathToDotnet(
|
|||
// If we encounter any failures, try getting dotnet.exe from the
|
||||
// backup location.
|
||||
// Only do it if no path is specified
|
||||
if (!requestedPath.has_parent_path())
|
||||
if (requestedPath.has_parent_path())
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ public:
|
|||
static
|
||||
std::optional<std::experimental::filesystem::path>
|
||||
GetAbsolutePathToDotnet(
|
||||
_In_ const std::experimental::filesystem::path & applicationPath,
|
||||
_In_ const std::experimental::filesystem::path & requestedPath
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -33,20 +33,18 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
deploymentParameters => deploymentParameters.EnvironmentVariables["DotnetPath"] = _dotnetLocation);
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
public async Task InvalidProcessPath_ExpectServerError()
|
||||
[ConditionalTheory]
|
||||
[InlineData("bogus")]
|
||||
[InlineData("c:\\random files\\dotnet.exe")]
|
||||
[InlineData(".\\dotnet.exe")]
|
||||
public async Task InvalidProcessPath_ExpectServerError(string path)
|
||||
{
|
||||
var dotnetLocation = "bogus";
|
||||
|
||||
var deploymentParameters = GetBaseDeploymentParameters();
|
||||
// Point to dotnet installed in user profile.
|
||||
deploymentParameters.EnvironmentVariables["DotnetPath"] = Environment.ExpandEnvironmentVariables(dotnetLocation); // Path to dotnet.
|
||||
|
||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||
|
||||
Helpers.ModifyAspNetCoreSectionInWebConfig(deploymentResult, "processPath", "%DotnetPath%");
|
||||
Helpers.ModifyAspNetCoreSectionInWebConfig(deploymentResult, "processPath", path);
|
||||
|
||||
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
||||
var response = await deploymentResult.RetryingHttpClient.GetAsync("HelloWorld");
|
||||
|
||||
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
||||
|
|
|
|||
Loading…
Reference in New Issue