Fail fast on .NET Full Framework and log exceptions in hostfxr utility (#533)
This commit is contained in:
parent
462c1c042a
commit
e035d0ed96
|
|
@ -3,33 +3,33 @@
|
|||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Package Versions">
|
||||
<InternalAspNetCoreSdkPackageVersion>2.1.0-preview1-15677</InternalAspNetCoreSdkPackageVersion>
|
||||
<MicrosoftAspNetCoreAllPackageVersion>2.1.0-preview2-28214</MicrosoftAspNetCoreAllPackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.1.0-preview2-28214</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
|
||||
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.1.0-preview2-28214</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
|
||||
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview2-28214</MicrosoftAspNetCoreHostingPackageVersion>
|
||||
<MicrosoftAspNetCoreHttpExtensionsPackageVersion>2.1.0-preview2-28214</MicrosoftAspNetCoreHttpExtensionsPackageVersion>
|
||||
<MicrosoftAspNetCoreHttpOverridesPackageVersion>2.1.0-preview2-28214</MicrosoftAspNetCoreHttpOverridesPackageVersion>
|
||||
<MicrosoftAspNetCoreHttpPackageVersion>2.1.0-preview2-28214</MicrosoftAspNetCoreHttpPackageVersion>
|
||||
<MicrosoftAspNetCoreHttpSysSourcesPackageVersion>2.1.0-preview2-28214</MicrosoftAspNetCoreHttpSysSourcesPackageVersion>
|
||||
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.5.0-preview2-28214</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
|
||||
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-preview2-28214</MicrosoftAspNetCoreServerKestrelPackageVersion>
|
||||
<MicrosoftAspNetCoreTestHostPackageVersion>2.1.0-preview2-28214</MicrosoftAspNetCoreTestHostPackageVersion>
|
||||
<MicrosoftAspNetCoreTestingPackageVersion>2.1.0-preview2-28214</MicrosoftAspNetCoreTestingPackageVersion>
|
||||
<MicrosoftAspNetCoreWebUtilitiesPackageVersion>2.1.0-preview2-28214</MicrosoftAspNetCoreWebUtilitiesPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.1.0-preview2-28214</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.1.0-preview2-28214</MicrosoftExtensionsConfigurationJsonPackageVersion>
|
||||
<MicrosoftExtensionsLoggingAbstractionsPackageVersion>2.1.0-preview2-28214</MicrosoftExtensionsLoggingAbstractionsPackageVersion>
|
||||
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview2-28214</MicrosoftExtensionsLoggingConsolePackageVersion>
|
||||
<MicrosoftExtensionsLoggingDebugPackageVersion>2.1.0-preview2-28214</MicrosoftExtensionsLoggingDebugPackageVersion>
|
||||
<MicrosoftExtensionsLoggingPackageVersion>2.1.0-preview2-28214</MicrosoftExtensionsLoggingPackageVersion>
|
||||
<MicrosoftExtensionsLoggingTestingPackageVersion>2.1.0-preview2-28214</MicrosoftExtensionsLoggingTestingPackageVersion>
|
||||
<MicrosoftExtensionsOptionsPackageVersion>2.1.0-preview2-28214</MicrosoftExtensionsOptionsPackageVersion>
|
||||
<InternalAspNetCoreSdkPackageVersion>2.1.0-preview2-15693</InternalAspNetCoreSdkPackageVersion>
|
||||
<MicrosoftAspNetCoreAllPackageVersion>2.1.0-preview2-30015</MicrosoftAspNetCoreAllPackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.1.0-preview2-30015</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
|
||||
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.1.0-preview2-30015</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
|
||||
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview2-30015</MicrosoftAspNetCoreHostingPackageVersion>
|
||||
<MicrosoftAspNetCoreHttpExtensionsPackageVersion>2.1.0-preview2-30015</MicrosoftAspNetCoreHttpExtensionsPackageVersion>
|
||||
<MicrosoftAspNetCoreHttpOverridesPackageVersion>2.1.0-preview2-30015</MicrosoftAspNetCoreHttpOverridesPackageVersion>
|
||||
<MicrosoftAspNetCoreHttpPackageVersion>2.1.0-preview2-30015</MicrosoftAspNetCoreHttpPackageVersion>
|
||||
<MicrosoftAspNetCoreHttpSysSourcesPackageVersion>2.1.0-preview2-30015</MicrosoftAspNetCoreHttpSysSourcesPackageVersion>
|
||||
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.5.0-preview2-30015</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
|
||||
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-preview2-30015</MicrosoftAspNetCoreServerKestrelPackageVersion>
|
||||
<MicrosoftAspNetCoreTestHostPackageVersion>2.1.0-preview2-30015</MicrosoftAspNetCoreTestHostPackageVersion>
|
||||
<MicrosoftAspNetCoreTestingPackageVersion>2.1.0-preview2-30015</MicrosoftAspNetCoreTestingPackageVersion>
|
||||
<MicrosoftAspNetCoreWebUtilitiesPackageVersion>2.1.0-preview2-30015</MicrosoftAspNetCoreWebUtilitiesPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.1.0-preview2-30015</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.1.0-preview2-30015</MicrosoftExtensionsConfigurationJsonPackageVersion>
|
||||
<MicrosoftExtensionsLoggingAbstractionsPackageVersion>2.1.0-preview2-30015</MicrosoftExtensionsLoggingAbstractionsPackageVersion>
|
||||
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview2-30015</MicrosoftExtensionsLoggingConsolePackageVersion>
|
||||
<MicrosoftExtensionsLoggingDebugPackageVersion>2.1.0-preview2-30015</MicrosoftExtensionsLoggingDebugPackageVersion>
|
||||
<MicrosoftExtensionsLoggingPackageVersion>2.1.0-preview2-30015</MicrosoftExtensionsLoggingPackageVersion>
|
||||
<MicrosoftExtensionsLoggingTestingPackageVersion>2.1.0-preview2-30015</MicrosoftExtensionsLoggingTestingPackageVersion>
|
||||
<MicrosoftExtensionsOptionsPackageVersion>2.1.0-preview2-30015</MicrosoftExtensionsOptionsPackageVersion>
|
||||
<MicrosoftExtensionsPlatformAbstractionsPackageVersion>1.1.0</MicrosoftExtensionsPlatformAbstractionsPackageVersion>
|
||||
<MicrosoftExtensionsSecurityHelperSourcesPackageVersion>2.1.0-preview2-28214</MicrosoftExtensionsSecurityHelperSourcesPackageVersion>
|
||||
<MicrosoftExtensionsSecurityHelperSourcesPackageVersion>2.1.0-preview2-30015</MicrosoftExtensionsSecurityHelperSourcesPackageVersion>
|
||||
<MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion>
|
||||
<MicrosoftNETCoreApp21PackageVersion>2.1.0-preview2-26130-04</MicrosoftNETCoreApp21PackageVersion>
|
||||
<MicrosoftNetHttpHeadersPackageVersion>2.1.0-preview2-28214</MicrosoftNetHttpHeadersPackageVersion>
|
||||
<MicrosoftNetHttpHeadersPackageVersion>2.1.0-preview2-30015</MicrosoftNetHttpHeadersPackageVersion>
|
||||
<MicrosoftNETTestSdkPackageVersion>15.3.0</MicrosoftNETTestSdkPackageVersion>
|
||||
<MicrosoftWebAdministrationPackageVersion>7.0.0</MicrosoftWebAdministrationPackageVersion>
|
||||
<SystemBuffersPackageVersion>4.5.0-preview2-26130-01</SystemBuffersPackageVersion>
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
version:2.1.0-preview1-15677
|
||||
commithash:76ac40e0d67a4cc253cb4ecf35dda18c90a272ac
|
||||
version:2.1.0-preview2-15693
|
||||
commithash:bbc5ba7e5acafd36dcdcf865d528660892b6418a
|
||||
|
|
|
|||
|
|
@ -161,7 +161,9 @@ APPLICATION_INFO::EnsureApplicationCreated()
|
|||
BOOL fLocked = FALSE;
|
||||
APPLICATION* pApplication = NULL;
|
||||
STACK_STRU(struFileName, 300); // >MAX_PATH
|
||||
STRU hostFxrDllLocation;
|
||||
STRU struHostFxrDllLocation;
|
||||
PWSTR* pwzArgv;
|
||||
DWORD dwArgCount;
|
||||
|
||||
if (m_pApplication != NULL)
|
||||
{
|
||||
|
|
@ -170,10 +172,24 @@ APPLICATION_INFO::EnsureApplicationCreated()
|
|||
|
||||
if ( m_pConfiguration->QueryHostingModel() == APP_HOSTING_MODEL::HOSTING_IN_PROCESS )
|
||||
{
|
||||
if ( FAILED( hr = HOSTFXR_UTILITY::GetHostFxrParameters( m_pConfiguration ) ) )
|
||||
if (FAILED(hr = HOSTFXR_UTILITY::GetHostFxrParameters(
|
||||
g_hEventLog,
|
||||
m_pConfiguration->QueryProcessPath()->QueryStr(),
|
||||
m_pConfiguration->QueryApplicationPhysicalPath()->QueryStr(),
|
||||
m_pConfiguration->QueryArguments()->QueryStr(),
|
||||
&struHostFxrDllLocation,
|
||||
&dwArgCount,
|
||||
&pwzArgv)))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
if (FAILED(hr = m_pConfiguration->SetHostFxrFullPath(struHostFxrDllLocation.QueryStr())))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
m_pConfiguration->SetHostFxrArguments(dwArgCount, pwzArgv);
|
||||
}
|
||||
|
||||
hr = FindRequestHandlerAssembly();
|
||||
|
|
|
|||
|
|
@ -56,4 +56,4 @@ ASPNET_CORE_GLOBAL_MODULE::OnGlobalApplicationStop(
|
|||
|
||||
// Return processing to the pipeline.
|
||||
return GL_NOTIFICATION_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,43 @@ Language=English
|
|||
%1
|
||||
.
|
||||
|
||||
Messageid=1014
|
||||
SymbolicName=ASPNETCORE_EVENT_INPROCESS_FULL_FRAMEWORK_APP
|
||||
Language=English
|
||||
%1
|
||||
.
|
||||
|
||||
Messageid=1015
|
||||
SymbolicName=ASPNETCORE_EVENT_PORTABLE_APP_DOTNET_MISSING
|
||||
Language=English
|
||||
%1
|
||||
.
|
||||
|
||||
Messageid=1016
|
||||
SymbolicName=ASPNETCORE_EVENT_HOSTFXR_DIRECTORY_NOT_FOUND
|
||||
Language=English
|
||||
%1
|
||||
.
|
||||
|
||||
Messageid=1017
|
||||
SymbolicName=ASPNETCORE_EVENT_HOSTFXR_DLL_NOT_FOUND
|
||||
Language=English
|
||||
%1
|
||||
.
|
||||
|
||||
Messageid=1018
|
||||
SymbolicName=ASPNETCORE_EVENT_INPROCESS_THREAD_EXCEPTION
|
||||
Language=English
|
||||
%1
|
||||
.
|
||||
|
||||
Messageid=1019
|
||||
SymbolicName=ASPNETCORE_EVENT_APPLICATION_EXE_NOT_FOUND
|
||||
Language=English
|
||||
%1
|
||||
.
|
||||
|
||||
|
||||
;
|
||||
;#endif // _ASPNETCORE_MODULE_MSG_H_
|
||||
;
|
||||
|
|
|
|||
|
|
@ -525,4 +525,4 @@ Finished:
|
|||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ public:
|
|||
VOID
|
||||
SetHostFxrArguments(
|
||||
DWORD dwArgc,
|
||||
PCWSTR* ppStrArguments
|
||||
PWSTR* ppStrArguments
|
||||
)
|
||||
{
|
||||
if (m_ppStrArguments != NULL)
|
||||
|
|
@ -319,6 +319,6 @@ private:
|
|||
APP_HOSTING_MODEL m_hostingModel;
|
||||
ENVIRONMENT_VAR_HASH* m_pEnvironmentVariables;
|
||||
STRU m_struHostFxrLocation;
|
||||
PCWSTR* m_ppStrArguments;
|
||||
PWSTR* m_ppStrArguments;
|
||||
DWORD m_dwArgc;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,36 +25,98 @@ HOSTFXR_UTILITY::~HOSTFXR_UTILITY()
|
|||
//
|
||||
HRESULT
|
||||
HOSTFXR_UTILITY::GetStandaloneHostfxrParameters(
|
||||
PCWSTR pwzExePath,
|
||||
ASPNETCORE_CONFIG *pConfig
|
||||
PCWSTR pwzExeAbsolutePath, // includes .exe file extension.
|
||||
PCWSTR pcwzApplicationPhysicalPath,
|
||||
PCWSTR pcwzArguments,
|
||||
HANDLE hEventLog,
|
||||
_Inout_ STRU* struHostFxrDllLocation,
|
||||
_Out_ DWORD* pdwArgCount,
|
||||
_Out_ PWSTR** ppwzArgv
|
||||
)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
STRU struDllPath;
|
||||
STRU struArguments;
|
||||
STRU struHostFxrPath;
|
||||
STRU struRuntimeConfigLocation;
|
||||
STRU strEventMsg;
|
||||
DWORD dwPosition;
|
||||
|
||||
if (FAILED(hr))
|
||||
// Obtain the app name from the processPath section.
|
||||
if ( FAILED( hr = struDllPath.Copy( pwzExeAbsolutePath ) ) )
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
if (FAILED(hr = struDllPath.Copy(pwzExePath)))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
dwPosition = struDllPath.LastIndexOf(L'.', 0);
|
||||
if (dwPosition == -1)
|
||||
dwPosition = struDllPath.LastIndexOf( L'.', 0 );
|
||||
if ( dwPosition == -1 )
|
||||
{
|
||||
hr = E_FAIL;
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
struDllPath.QueryStr()[dwPosition] = L'\0';
|
||||
hr = UTILITY::ConvertPathToFullPath( L".\\hostfxr.dll", pcwzApplicationPhysicalPath, &struHostFxrPath );
|
||||
if ( FAILED( hr ) )
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
if (FAILED(hr = struDllPath.SyncWithBuffer()) ||
|
||||
FAILED(hr = struDllPath.Append(L".dll")))
|
||||
struDllPath.QueryStr()[dwPosition] = L'\0';
|
||||
if (FAILED(hr = struDllPath.SyncWithBuffer()))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
if ( !UTILITY::CheckIfFileExists( struHostFxrPath.QueryStr() ) )
|
||||
{
|
||||
// Most likely a full framework app.
|
||||
// Check that the runtime config file doesn't exist in the folder as another heuristic.
|
||||
if (FAILED(hr = struRuntimeConfigLocation.Copy(struDllPath)) ||
|
||||
FAILED(hr = struRuntimeConfigLocation.Append( L".runtimeconfig.json" )))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
if (!UTILITY::CheckIfFileExists(struRuntimeConfigLocation.QueryStr()))
|
||||
{
|
||||
|
||||
hr = E_APPLICATION_ACTIVATION_EXEC_FAILURE;
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_INPROCESS_FULL_FRAMEWORK_APP_MSG,
|
||||
pcwzApplicationPhysicalPath,
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent( hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_INPROCESS_FULL_FRAMEWORK_APP,
|
||||
strEventMsg.QueryStr() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If a runtime config file does exist, report a file not found on the app.exe
|
||||
hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
|
||||
if (SUCCEEDED(strEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_APPLICATION_EXE_NOT_FOUND_MSG,
|
||||
pcwzApplicationPhysicalPath,
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_APPLICATION_EXE_NOT_FOUND,
|
||||
strEventMsg.QueryStr());
|
||||
}
|
||||
}
|
||||
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
if (FAILED(hr = struHostFxrDllLocation->Copy(struHostFxrPath)))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
|
||||
if (FAILED(hr = struDllPath.Append(L".dll")))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
|
@ -62,18 +124,28 @@ HOSTFXR_UTILITY::GetStandaloneHostfxrParameters(
|
|||
if (!UTILITY::CheckIfFileExists(struDllPath.QueryStr()))
|
||||
{
|
||||
// Treat access issue as File not found
|
||||
hr = ERROR_FILE_NOT_FOUND;
|
||||
hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
if (FAILED(hr = struArguments.Copy(struDllPath)) ||
|
||||
FAILED(hr = struArguments.Append(L" ")) ||
|
||||
FAILED(hr = struArguments.Append(pConfig->QueryArguments())))
|
||||
FAILED(hr = struArguments.Append(pcwzArguments)))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
if (FAILED(hr = SetHostFxrArguments(struArguments.QueryStr(), pwzExePath, pConfig)))
|
||||
if (FAILED(hr = ParseHostfxrArguments(
|
||||
struArguments.QueryStr(),
|
||||
pwzExeAbsolutePath,
|
||||
pcwzApplicationPhysicalPath,
|
||||
hEventLog,
|
||||
pdwArgCount,
|
||||
ppwzArgv)))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
if (FAILED(hr = struHostFxrDllLocation->Copy(struDllPath)))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
|
@ -85,7 +157,13 @@ Finished:
|
|||
|
||||
HRESULT
|
||||
HOSTFXR_UTILITY::GetHostFxrParameters(
|
||||
ASPNETCORE_CONFIG *pConfig
|
||||
HANDLE hEventLog,
|
||||
PCWSTR pcwzProcessPath,
|
||||
PCWSTR pcwzApplicationPhysicalPath,
|
||||
PCWSTR pcwzArguments,
|
||||
_Inout_ STRU* struHostFxrDllLocation,
|
||||
_Out_ DWORD* pdwArgCount,
|
||||
_Out_ PWSTR** ppwzArgv
|
||||
)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
|
@ -94,13 +172,14 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
|
|||
STRU struExeLocation;
|
||||
STRU struHostFxrSearchExpression;
|
||||
STRU struHighestDotnetVersion;
|
||||
STRU struEventMsg;
|
||||
std::vector<std::wstring> vVersionFolders;
|
||||
DWORD dwPosition;
|
||||
|
||||
// Convert the process path an absolute path.
|
||||
hr = UTILITY::ConvertPathToFullPath(
|
||||
pConfig->QueryProcessPath()->QueryStr(),
|
||||
pConfig->QueryApplicationPhysicalPath()->QueryStr(),
|
||||
pcwzProcessPath,
|
||||
pcwzApplicationPhysicalPath,
|
||||
&struExeLocation
|
||||
);
|
||||
|
||||
|
|
@ -113,30 +192,22 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
|
|||
{
|
||||
// Check if hostfxr is in this folder, if it is, we are a standalone application,
|
||||
// else we assume we received an absolute path to dotnet.exe
|
||||
hr = UTILITY::ConvertPathToFullPath(L".\\hostfxr.dll", pConfig->QueryApplicationPhysicalPath()->QueryStr(), &struHostFxrPath);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
if (UTILITY::CheckIfFileExists(struHostFxrPath.QueryStr()))
|
||||
{
|
||||
// Standalone application
|
||||
if (FAILED(hr = pConfig->SetHostFxrFullPath(struHostFxrPath.QueryStr())))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
hr = GetStandaloneHostfxrParameters(struExeLocation.QueryStr(), pConfig);
|
||||
goto Finished;
|
||||
}
|
||||
hr = GetStandaloneHostfxrParameters(
|
||||
struExeLocation.QueryStr(),
|
||||
pcwzApplicationPhysicalPath,
|
||||
pcwzArguments,
|
||||
hEventLog,
|
||||
struHostFxrDllLocation,
|
||||
pdwArgCount,
|
||||
ppwzArgv);
|
||||
goto Finished;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FAILED(hr = HOSTFXR_UTILITY::FindDotnetExePath(&struExeLocation))) {
|
||||
if (FAILED(hr = HOSTFXR_UTILITY::FindDotnetExePath(&struExeLocation)))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (FAILED(hr = struExeLocation.SyncWithBuffer()) ||
|
||||
|
|
@ -168,8 +239,17 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
|
|||
|
||||
if (!UTILITY::DirectoryExists(&struHostFxrPath))
|
||||
{
|
||||
// error, not found in folder
|
||||
hr = ERROR_BAD_ENVIRONMENT;
|
||||
if (SUCCEEDED(struEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_HOSTFXR_DIRECTORY_NOT_FOUND_MSG,
|
||||
struHostFxrPath.QueryStr(),
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_HOSTFXR_DIRECTORY_NOT_FOUND,
|
||||
struEventMsg.QueryStr());
|
||||
}
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
|
|
@ -192,8 +272,17 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
|
|||
|
||||
if (vVersionFolders.size() == 0)
|
||||
{
|
||||
// no core framework was found
|
||||
hr = ERROR_BAD_ENVIRONMENT;
|
||||
hr = HRESULT_FROM_WIN32(ERROR_BAD_ENVIRONMENT);
|
||||
if (SUCCEEDED(struEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_HOSTFXR_DIRECTORY_NOT_FOUND_MSG,
|
||||
struHostFxrPath.QueryStr(),
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_HOSTFXR_DIRECTORY_NOT_FOUND,
|
||||
struEventMsg.QueryStr());
|
||||
}
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
|
|
@ -212,16 +301,33 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
|
|||
|
||||
if (!UTILITY::CheckIfFileExists(struHostFxrPath.QueryStr()))
|
||||
{
|
||||
hr = ERROR_FILE_INVALID;
|
||||
// ASPNETCORE_EVENT_HOSTFXR_DLL_NOT_FOUND_MSG
|
||||
hr = HRESULT_FROM_WIN32(ERROR_FILE_INVALID);
|
||||
if (SUCCEEDED(struEventMsg.SafeSnwprintf(
|
||||
ASPNETCORE_EVENT_HOSTFXR_DLL_NOT_FOUND_MSG,
|
||||
struHostFxrPath.QueryStr(),
|
||||
hr)))
|
||||
{
|
||||
UTILITY::LogEvent(hEventLog,
|
||||
EVENTLOG_ERROR_TYPE,
|
||||
ASPNETCORE_EVENT_HOSTFXR_DLL_NOT_FOUND,
|
||||
struEventMsg.QueryStr());
|
||||
}
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
if (FAILED(hr = SetHostFxrArguments(pConfig->QueryArguments()->QueryStr(), struExeLocation.QueryStr(), pConfig)))
|
||||
if (FAILED(hr = ParseHostfxrArguments(
|
||||
pcwzArguments,
|
||||
struExeLocation.QueryStr(),
|
||||
pcwzApplicationPhysicalPath,
|
||||
hEventLog,
|
||||
pdwArgCount,
|
||||
ppwzArgv)))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
if (FAILED(hr = pConfig->SetHostFxrFullPath(struHostFxrPath.QueryStr())))
|
||||
if (FAILED(hr = struHostFxrDllLocation->Copy(struHostFxrPath)))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
|
@ -240,15 +346,23 @@ Finished:
|
|||
// argv[2] = absolute path to dll.
|
||||
//
|
||||
HRESULT
|
||||
HOSTFXR_UTILITY::SetHostFxrArguments(
|
||||
PCWSTR pwzArgumentsFromConfig,
|
||||
PCWSTR pwzExePath,
|
||||
ASPNETCORE_CONFIG* pConfig
|
||||
HOSTFXR_UTILITY::ParseHostfxrArguments(
|
||||
PCWSTR pwzArgumentsFromConfig,
|
||||
PCWSTR pwzExePath,
|
||||
PCWSTR pcwzApplicationPhysicalPath,
|
||||
HANDLE hEventLog,
|
||||
_Out_ DWORD* pdwArgCount,
|
||||
_Out_ PWSTR** ppwzArgv
|
||||
)
|
||||
{
|
||||
UNREFERENCED_PARAMETER( hEventLog ); // TODO use event log to set errors.
|
||||
|
||||
DBG_ASSERT(dwArgCount != NULL);
|
||||
DBG_ASSERT(pwzArgv != NULL);
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
INT argc = 0;
|
||||
PCWSTR* argv = NULL;
|
||||
PWSTR* argv = NULL;
|
||||
LPWSTR* pwzArgs = NULL;
|
||||
STRU struTempPath;
|
||||
DWORD dwArgsProcessed = 0;
|
||||
|
|
@ -268,7 +382,7 @@ HOSTFXR_UTILITY::SetHostFxrArguments(
|
|||
goto Failure;
|
||||
}
|
||||
|
||||
argv = new PCWSTR[argc + 2];
|
||||
argv = new PWSTR[argc + 2];
|
||||
if (argv == NULL)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
|
|
@ -294,7 +408,7 @@ HOSTFXR_UTILITY::SetHostFxrArguments(
|
|||
|
||||
// Try to convert the application dll from a relative to an absolute path
|
||||
// Don't record this failure as pwzArgs[0] may already be an absolute path to the dll.
|
||||
if (SUCCEEDED(UTILITY::ConvertPathToFullPath(pwzArgs[0], pConfig->QueryApplicationPhysicalPath()->QueryStr(), &struTempPath)))
|
||||
if (SUCCEEDED(UTILITY::ConvertPathToFullPath(pwzArgs[0], pcwzApplicationPhysicalPath, &struTempPath)))
|
||||
{
|
||||
argv[2] = SysAllocString(struTempPath.QueryStr());
|
||||
}
|
||||
|
|
@ -320,7 +434,9 @@ HOSTFXR_UTILITY::SetHostFxrArguments(
|
|||
dwArgsProcessed++;
|
||||
}
|
||||
|
||||
pConfig->SetHostFxrArguments(argc + 2, argv);
|
||||
*ppwzArgv = argv;
|
||||
*pdwArgCount = dwArgsProcessed;
|
||||
|
||||
goto Finished;
|
||||
|
||||
Failure:
|
||||
|
|
|
|||
|
|
@ -14,33 +14,47 @@ public:
|
|||
HOSTFXR_UTILITY();
|
||||
~HOSTFXR_UTILITY();
|
||||
|
||||
static
|
||||
HRESULT
|
||||
GetHostFxrParameters(
|
||||
ASPNETCORE_CONFIG *pConfig
|
||||
);
|
||||
static
|
||||
HRESULT
|
||||
GetHostFxrParameters(
|
||||
HANDLE hEventLog,
|
||||
PCWSTR pcwzProcessPath,
|
||||
PCWSTR pcwzApplicationPhysicalPath,
|
||||
PCWSTR pcwzArguments,
|
||||
_Inout_ STRU* struHostFxrDllLocation,
|
||||
_Out_ DWORD* pdwArgCount,
|
||||
_Out_ PWSTR** ppwzArgv
|
||||
);
|
||||
|
||||
private:
|
||||
static
|
||||
HRESULT
|
||||
GetStandaloneHostfxrParameters(
|
||||
PCWSTR pStruExePath,
|
||||
ASPNETCORE_CONFIG *pConfig
|
||||
PCWSTR pwzExeAbsolutePath, // includes .exe file extension.
|
||||
PCWSTR pcwzApplicationPhysicalPath,
|
||||
PCWSTR pcwzArguments,
|
||||
HANDLE hEventLog,
|
||||
_Inout_ STRU* struHostFxrDllLocation,
|
||||
_Out_ DWORD* pdwArgCount,
|
||||
_Out_ PWSTR** ppwzArgv
|
||||
);
|
||||
|
||||
static
|
||||
HRESULT
|
||||
SetHostFxrArguments(
|
||||
PCWSTR struArguments,
|
||||
PCWSTR pStruExePath,
|
||||
ASPNETCORE_CONFIG *pConfig
|
||||
ParseHostfxrArguments(
|
||||
PCWSTR pwzArgumentsFromConfig,
|
||||
PCWSTR pwzExePath,
|
||||
PCWSTR pcwzApplicationPhysicalPath,
|
||||
HANDLE hEventLog,
|
||||
_Out_ DWORD* pdwArgCount,
|
||||
_Out_ PWSTR** ppwzArgv
|
||||
);
|
||||
|
||||
|
||||
static
|
||||
HRESULT
|
||||
FindDotnetExePath(
|
||||
STRU * struDotnetLocation
|
||||
STRU* struDotnetLocation
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,14 +16,20 @@
|
|||
#define ASPNETCORE_EVENT_PROCESS_START_POSTCREATE_ERROR_MSG L"Application '%s' with physical root '%s' created process with commandline '%s'but failed to get its status, ErrorCode = '0x%x', retryCounter '%d'."
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_ERROR_MSG L"Application '%s' with physical root '%s' failed to start process with commandline '%s', ErrorCode = '0x%x', retryCounter '%d'."
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_WRONGPORT_ERROR_MSG L"Application '%s' with physical root '%s' created process with commandline '%s' but failed to listen on the given port '%d'"
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_NOTREADY_ERROR_MSG L"Application '%s' with physical root '%s' created process with commandline '%s' but either crashed or did not response or did not listen on the given port '%d', ErrorCode = '0x%x'"
|
||||
#define ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG L"Warning: Could not create stdoutLogFile %s, ErrorCode = %d."
|
||||
#define ASPNETCORE_EVENT_PROCESS_START_NOTREADY_ERROR_MSG L"Application '%s' with physical root '%s' created process with commandline '%s' but either crashed or did not respond or did not listen on the given port '%d', ErrorCode = '0x%x'"
|
||||
#define ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG L"Warning: Could not create stdoutLogFile %s, ErrorCode = '0x%x'."
|
||||
#define ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE_MSG L"Failed to gracefully shutdown process '%d'."
|
||||
#define ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST_MSG L"Sent shutdown HTTP message to process '%d' and received http status '%d'."
|
||||
#define ASPNETCORE_EVENT_LOAD_CLR_FALIURE_MSG L"Application '%s' with physical root '%s' failed to load clr and managed application, ErrorCode = '0x%x."
|
||||
#define ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP_MSG L"Only one inprocess application is allowed per IIS application pool. Please assign the application '%s' to a different IIS application pool."
|
||||
#define ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR_MSG L"Mixed hosting model is not supported. Application '%s' configured with different hostingModel value '%d' other than the one of running application(s)."
|
||||
#define ASPNETCORE_EVENT_ADD_APPLICATION_ERROR_MSG L"Failed to start application '%s', ErrorCode '0x%x'."
|
||||
#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_MSG L"Application '%s' with physical root '%s' hit unexpected managed background thread exit, ErrorCode = '0x%x."
|
||||
#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_MSG L"Application '%s' with physical root '%s' hit unexpected managed background thread exit, ErrorCode = '0x%x. Please check the stderr logs for more information."
|
||||
#define ASPNETCORE_EVENT_RECYCLE_APPOFFLINE_MSG L"Application '%s' is recycled due to app_offline file was detected."
|
||||
#define ASPNETCORE_EVENT_MODULE_DISABLED_MSG L"AspNetCore Module is disabled"
|
||||
#define ASPNETCORE_EVENT_INPROCESS_FULL_FRAMEWORK_APP_MSG L"Application '%s' was compiled for .NET Framework. Please compile for .NET core to run the inprocess application or change the process mode to out of process. ErrorCode = '0x%x'."
|
||||
#define ASPNETCORE_EVENT_PORTABLE_APP_DOTNET_MISSING_MSG L"Could not find dotnet.exe on the system PATH environment variable for portable application '%s'. Check that a valid path to dotnet is on the PATH and the bitness of dotnet matches the bitness of the IIS worker process. ErrorCode = '0x%x'."
|
||||
#define ASPNETCORE_EVENT_HOSTFXR_DIRECTORY_NOT_FOUND_MSG L"Could not find the hostfxr directory '%s' in the dotnet directory. ErrorCode = '0x%x'."
|
||||
#define ASPNETCORE_EVENT_HOSTFXR_DLL_NOT_FOUND_MSG L"Could not find hostfxr.dll in '%s'. ErrorCode = '0x%x'."
|
||||
#define ASPNETCORE_EVENT_APPLICATION_EXE_NOT_FOUND_MSG L"Could not find application executable in '%s'. ErrorCode = '0x%x'."
|
||||
#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXCEPTION_MSG L"Application '%s' with physical root '%s' hit unexpected managed exception, ErrorCode = '0x%x. Please check the stderr logs for more information."
|
||||
|
|
|
|||
|
|
@ -28,3 +28,5 @@
|
|||
#include "requesthandler.h"
|
||||
#include "fx_ver.h"
|
||||
#include "hostfxr_utility.h"
|
||||
#include "resources.h"
|
||||
#include "aspnetcore_msg.h"
|
||||
|
|
|
|||
Loading…
Reference in New Issue