Fix argument parsing for hostfxr, add native unit tests. (#635)
This commit is contained in:
parent
00b1948937
commit
ad82bd31d8
|
|
@ -55,6 +55,8 @@ src/AspNetCore/version.h
|
|||
src/RequestHandler/version.h
|
||||
src/CommonLib/aspnetcore_msg.h
|
||||
src/CommonLib/aspnetcore_msg.rc
|
||||
test/AspNetCoreModuleTests/Debug
|
||||
test/AspNetCoreModuleTests/Release
|
||||
.build
|
||||
|
||||
*.VC.*db
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RequestHandler", "src\Reque
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IIS", "src\Microsoft.AspNetCore.Server.IIS\Microsoft.AspNetCore.Server.IIS.csproj", "{46A8612B-418B-4D70-B3A7-A21DD0627473}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AspNetCoreModuleTests", "test\AspNetCoreModuleTests\AspNetCoreModuleTests.vcxproj", "{0692D963-DB10-4387-B3EA-460FBB9BD9A3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -200,6 +202,16 @@ Global
|
|||
{46A8612B-418B-4D70-B3A7-A21DD0627473}.Release|x64.Build.0 = Release|Any CPU
|
||||
{46A8612B-418B-4D70-B3A7-A21DD0627473}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{46A8612B-418B-4D70-B3A7-A21DD0627473}.Release|x86.Build.0 = Release|Any CPU
|
||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Debug|x64.Build.0 = Debug|x64
|
||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Debug|x86.Build.0 = Debug|Win32
|
||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|x64.ActiveCfg = Release|x64
|
||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|x64.Build.0 = Release|x64
|
||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|x86.ActiveCfg = Release|Win32
|
||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -217,6 +229,7 @@ Global
|
|||
{55494E58-E061-4C4C-A0A8-837008E72F85} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD}
|
||||
{D57EA297-6DC2-4BC0-8C91-334863327863} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD}
|
||||
{46A8612B-418B-4D70-B3A7-A21DD0627473} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD}
|
||||
{0692D963-DB10-4387-B3EA-460FBB9BD9A3} = {EF30B533-D715-421A-92B7-92FEF460AC9C}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {DB4F868D-E1AE-4FD7-9333-69FA15B268C5}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
<ItemGroup>
|
||||
<Projects Include="$(SolutionDir)\src\AspNetCore\AspNetCore.vcxproj" />
|
||||
<Projects Include="$(SolutionDir)\src\RequestHandler\RequestHandler.vcxproj" />
|
||||
<Projects Include="$(SolutionDir)\test\AspNetCoreModuleTests\AspNetCoreModuleTests.vcxproj">
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="Build">
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
Condition="'$(VisualStudioMSBuildx86Path)' != ''" />
|
||||
<Exec Command=""$(VisualStudioMSBuildx86Path)" "$(RepositoryRoot)src\RequestHandler\RequestHandler.vcxproj" $(BuildArgs) -p:Platform=%(Platforms.Identity) -bl:$(LogOutputDir)native.%(Platforms.Identity).binlog"
|
||||
Condition="'$(VisualStudioMSBuildx86Path)' != ''" />
|
||||
<Exec Command=""$(VisualStudioMSBuildx86Path)" "$(RepositoryRoot)test\AspNetCoreModuleTests\AspNetCoreModuleTests.vcxproj" $(BuildArgs) -p:Platform=%(Platforms.Identity) -bl:$(LogOutputDir)native.%(Platforms.Identity).binlog"
|
||||
Condition="'$(VisualStudioMSBuildx86Path)' != ''" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup Condition=" '$(OS)' == 'Windows_NT' ">
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
|
|||
PCWSTR pcwzArguments,
|
||||
_Inout_ STRU* struHostFxrDllLocation,
|
||||
_Out_ DWORD* pdwArgCount,
|
||||
_Out_ PWSTR** ppwzArgv
|
||||
_Out_ BSTR** pbstrArgv
|
||||
)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
|
@ -198,7 +198,7 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
|
|||
hEventLog,
|
||||
struHostFxrDllLocation,
|
||||
pdwArgCount,
|
||||
ppwzArgv);
|
||||
pbstrArgv);
|
||||
goto Finished;
|
||||
}
|
||||
}
|
||||
|
|
@ -322,7 +322,7 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
|
|||
pcwzApplicationPhysicalPath,
|
||||
hEventLog,
|
||||
pdwArgCount,
|
||||
ppwzArgv)))
|
||||
pbstrArgv)))
|
||||
{
|
||||
goto Finished;
|
||||
}
|
||||
|
|
@ -352,7 +352,7 @@ HOSTFXR_UTILITY::ParseHostfxrArguments(
|
|||
PCWSTR pcwzApplicationPhysicalPath,
|
||||
HANDLE hEventLog,
|
||||
_Out_ DWORD* pdwArgCount,
|
||||
_Out_ PWSTR** ppwzArgv
|
||||
_Out_ BSTR** pbstrArgv
|
||||
)
|
||||
{
|
||||
UNREFERENCED_PARAMETER( hEventLog ); // TODO use event log to set errors.
|
||||
|
|
@ -362,10 +362,18 @@ HOSTFXR_UTILITY::ParseHostfxrArguments(
|
|||
|
||||
HRESULT hr = S_OK;
|
||||
INT argc = 0;
|
||||
PWSTR* argv = NULL;
|
||||
BSTR* argv = NULL;
|
||||
LPWSTR* pwzArgs = NULL;
|
||||
STRU struTempPath;
|
||||
DWORD dwArgsProcessed = 0;
|
||||
INT intArgsProcessed = 0;
|
||||
|
||||
// If we call CommandLineToArgvW with an empty string, argc is 5 for some interesting reason.
|
||||
// Protectively guard against this by check if the string is null or empty.
|
||||
if (pwzArgumentsFromConfig == NULL || wcscmp(pwzArgumentsFromConfig, L"") == 0)
|
||||
{
|
||||
hr = E_INVALIDARG;
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
pwzArgs = CommandLineToArgvW(pwzArgumentsFromConfig, &argc);
|
||||
|
||||
|
|
@ -375,14 +383,7 @@ HOSTFXR_UTILITY::ParseHostfxrArguments(
|
|||
goto Failure;
|
||||
}
|
||||
|
||||
if (argc < 1)
|
||||
{
|
||||
// Invalid arguments
|
||||
hr = E_INVALIDARG;
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
argv = new PWSTR[argc + 2];
|
||||
argv = new PWSTR[argc + 1];
|
||||
if (argv == NULL)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
|
|
@ -396,55 +397,52 @@ HOSTFXR_UTILITY::ParseHostfxrArguments(
|
|||
hr = E_OUTOFMEMORY;
|
||||
goto Failure;
|
||||
}
|
||||
dwArgsProcessed++;
|
||||
|
||||
argv[1] = SysAllocString(L"exec");
|
||||
if (argv[1] == NULL)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
goto Failure;
|
||||
}
|
||||
dwArgsProcessed++;
|
||||
|
||||
// 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], pcwzApplicationPhysicalPath, &struTempPath)))
|
||||
for (intArgsProcessed = 0; intArgsProcessed < argc; intArgsProcessed++)
|
||||
{
|
||||
argv[2] = SysAllocString(struTempPath.QueryStr());
|
||||
}
|
||||
else
|
||||
{
|
||||
argv[2] = SysAllocString(pwzArgs[0]);
|
||||
}
|
||||
if (argv[2] == NULL)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
goto Failure;
|
||||
}
|
||||
dwArgsProcessed++;
|
||||
|
||||
for (INT i = 1; i < argc; i++)
|
||||
{
|
||||
argv[i + 2] = SysAllocString(pwzArgs[i]);
|
||||
if (argv[i + 2] == NULL)
|
||||
struTempPath.Copy(pwzArgs[intArgsProcessed]);
|
||||
if (struTempPath.EndsWith(L".dll"))
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
goto Failure;
|
||||
if (SUCCEEDED(UTILITY::ConvertPathToFullPath(pwzArgs[intArgsProcessed], pcwzApplicationPhysicalPath, &struTempPath)))
|
||||
{
|
||||
argv[intArgsProcessed + 1] = SysAllocString(struTempPath.QueryStr());
|
||||
}
|
||||
else
|
||||
{
|
||||
argv[intArgsProcessed + 1] = SysAllocString(pwzArgs[intArgsProcessed]);
|
||||
}
|
||||
if (argv[intArgsProcessed + 1] == NULL)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
goto Failure;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
argv[intArgsProcessed + 1] = SysAllocString(pwzArgs[intArgsProcessed]);
|
||||
if (argv[intArgsProcessed + 1] == NULL)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
goto Failure;
|
||||
}
|
||||
}
|
||||
dwArgsProcessed++;
|
||||
}
|
||||
|
||||
*ppwzArgv = argv;
|
||||
*pdwArgCount = dwArgsProcessed;
|
||||
*pbstrArgv = argv;
|
||||
*pdwArgCount = argc + 1;
|
||||
|
||||
goto Finished;
|
||||
|
||||
Failure:
|
||||
if (argv != NULL)
|
||||
{
|
||||
for (DWORD i = 0; i < dwArgsProcessed; i++)
|
||||
// intArgsProcess - 1 here as if we fail to allocated the ith string
|
||||
// we don't want to free it.
|
||||
for (INT i = 0; i < intArgsProcessed - 1; i++)
|
||||
{
|
||||
SysFreeString((BSTR)argv[i]);
|
||||
SysFreeString(argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -458,11 +456,11 @@ Finished:
|
|||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
//
|
||||
// Invoke where.exe to find the location of dotnet.exe
|
||||
// Copies contents of dotnet.exe to a temp file
|
||||
// Respects path ordering.
|
||||
|
||||
HRESULT
|
||||
HOSTFXR_UTILITY::FindDotnetExePath(
|
||||
_Out_ STRU* struDotnetPath
|
||||
|
|
|
|||
|
|
@ -23,10 +23,9 @@ public:
|
|||
PCWSTR pcwzArguments,
|
||||
_Inout_ STRU* struHostFxrDllLocation,
|
||||
_Out_ DWORD* pdwArgCount,
|
||||
_Out_ PWSTR** ppwzArgv
|
||||
_Out_ BSTR** ppwzArgv
|
||||
);
|
||||
|
||||
private:
|
||||
static
|
||||
HRESULT
|
||||
GetStandaloneHostfxrParameters(
|
||||
|
|
@ -36,7 +35,7 @@ private:
|
|||
HANDLE hEventLog,
|
||||
_Inout_ STRU* struHostFxrDllLocation,
|
||||
_Out_ DWORD* pdwArgCount,
|
||||
_Out_ PWSTR** ppwzArgv
|
||||
_Out_ BSTR** ppwzArgv
|
||||
);
|
||||
|
||||
static
|
||||
|
|
@ -47,10 +46,9 @@ private:
|
|||
PCWSTR pcwzApplicationPhysicalPath,
|
||||
HANDLE hEventLog,
|
||||
_Out_ DWORD* pdwArgCount,
|
||||
_Out_ PWSTR** ppwzArgv
|
||||
_Out_ BSTR** ppwzArgv
|
||||
);
|
||||
|
||||
|
||||
static
|
||||
HRESULT
|
||||
FindDotnetExePath(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,182 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{0692D963-DB10-4387-B3EA-460FBB9BD9A3}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>AspNetCoreModuleTests</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||
<ProjectSubType>NativeUnitTestProject</ProjectSubType>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);..\..\src\CommonLib;..\..\src\IISLib</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);..\..\src\CommonLib;..\..\src\IISLib</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);..\..\src\CommonLib;..\..\src\IISLib</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);..\..\src\CommonLib;..\..\src\IISLib</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="hostfxr_utility_tests.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\CommonLib\CommonLib.vcxproj">
|
||||
<Project>{55494e58-e061-4c4c-a0a8-837008e72f85}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\IISLib\IISLib.vcxproj">
|
||||
<Project>{4787a64f-9a3e-4867-a55a-70cb4b2b2ffe}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "CppUnitTest.h"
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace AspNetCoreModuleTests
|
||||
{
|
||||
TEST_CLASS(HOSTFXR_UTILITY_TESTS)
|
||||
{
|
||||
public:
|
||||
|
||||
TEST_METHOD(ParseHostfxrArguments_BasicHostFxrArguments)
|
||||
{
|
||||
DWORD retVal = 0;
|
||||
BSTR* bstrArray;
|
||||
PCWSTR exeStr = L"C:/Program Files/dotnet.exe";
|
||||
|
||||
HRESULT hr = HOSTFXR_UTILITY::ParseHostfxrArguments(
|
||||
L"exec \"test.dll\"", // args
|
||||
exeStr, // exe path
|
||||
L"invalid", // physical path to application
|
||||
NULL, // event log
|
||||
&retVal, // arg count
|
||||
&bstrArray); // args array.
|
||||
|
||||
Assert::AreEqual(hr, S_OK);
|
||||
Assert::AreEqual(DWORD(3), retVal);
|
||||
Assert::AreEqual(exeStr, bstrArray[0]);
|
||||
Assert::AreEqual(L"exec", bstrArray[1]);
|
||||
Assert::AreEqual(L"test.dll", bstrArray[2]);
|
||||
}
|
||||
|
||||
TEST_METHOD(ParseHostfxrArguments_NoExecProvided)
|
||||
{
|
||||
DWORD retVal = 0;
|
||||
BSTR* bstrArray;
|
||||
PCWSTR exeStr = L"C:/Program Files/dotnet.exe";
|
||||
|
||||
HRESULT hr = HOSTFXR_UTILITY::ParseHostfxrArguments(
|
||||
L"test.dll", // args
|
||||
exeStr, // exe path
|
||||
L"ignored", // physical path to application
|
||||
NULL, // event log
|
||||
&retVal, // arg count
|
||||
&bstrArray); // args array.
|
||||
|
||||
Assert::AreEqual(hr, S_OK);
|
||||
Assert::AreEqual(DWORD(2), retVal);
|
||||
Assert::AreEqual(exeStr, bstrArray[0]);
|
||||
Assert::AreEqual(L"test.dll", bstrArray[1]);
|
||||
}
|
||||
|
||||
TEST_METHOD(ParseHostfxrArguments_ConvertDllToAbsolutePath)
|
||||
{
|
||||
DWORD retVal = 0;
|
||||
BSTR* bstrArray;
|
||||
PCWSTR exeStr = L"C:/Program Files/dotnet.exe";
|
||||
|
||||
HRESULT hr = HOSTFXR_UTILITY::ParseHostfxrArguments(
|
||||
L"exec \"test.dll\"", // args
|
||||
exeStr, // exe path
|
||||
L"C:/test", // physical path to application
|
||||
NULL, // event log
|
||||
&retVal, // arg count
|
||||
&bstrArray); // args array.
|
||||
|
||||
Assert::AreEqual(hr, S_OK);
|
||||
Assert::AreEqual(DWORD(3), retVal);
|
||||
Assert::AreEqual(exeStr, bstrArray[0]);
|
||||
Assert::AreEqual(L"exec", bstrArray[1]);
|
||||
Assert::AreEqual(L"\\\\?\\C:\\test\\test.dll", bstrArray[2]);
|
||||
}
|
||||
|
||||
TEST_METHOD(ParseHostfxrArguments_ProvideNoArgs_InvalidArgs)
|
||||
{
|
||||
DWORD retVal = 0;
|
||||
BSTR* bstrArray;
|
||||
PCWSTR exeStr = L"C:/Program Files/dotnet.exe";
|
||||
|
||||
HRESULT hr = HOSTFXR_UTILITY::ParseHostfxrArguments(
|
||||
L"", // args
|
||||
exeStr, // exe path
|
||||
L"ignored", // physical path to application
|
||||
NULL, // event log
|
||||
&retVal, // arg count
|
||||
&bstrArray); // args array.
|
||||
|
||||
Assert::AreEqual(E_INVALIDARG, hr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
#include "stdafx.h"
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <Windows.h>
|
||||
#include <atlbase.h>
|
||||
#include <pdh.h>
|
||||
#include <vector>
|
||||
#include <Shlobj.h>
|
||||
#include <httpserv.h>
|
||||
#include <winhttp.h>
|
||||
#include <httptrace.h>
|
||||
#include <cstdlib>
|
||||
#include <wchar.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <hashfn.h>
|
||||
#include <hashtable.h>
|
||||
#include "stringa.h"
|
||||
#include "stringu.h"
|
||||
#include "dbgutil.h"
|
||||
#include "ahutil.h"
|
||||
#include "multisz.h"
|
||||
#include "multisza.h"
|
||||
#include "base64.h"
|
||||
#include <listentry.h>
|
||||
#include <datetime.h>
|
||||
#include <reftrace.h>
|
||||
#include <acache.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "..\..\src\IISLib\hashtable.h"
|
||||
#include "..\..\src\IISLib\stringu.h"
|
||||
#include "..\..\src\IISLib\stringa.h"
|
||||
#include "..\..\src\IISLib\multisz.h"
|
||||
#include "..\..\src\IISLib\dbgutil.h"
|
||||
#include "..\..\src\IISLib\ahutil.h"
|
||||
#include "..\..\src\IISLib\hashfn.h"
|
||||
|
||||
#include "..\..\src\CommonLib\hostfxr_utility.h"
|
||||
#include "..\..\src\CommonLib\environmentvariablehash.h"
|
||||
#include "..\..\src\CommonLib\aspnetcoreconfig.h"
|
||||
#include "..\..\src\CommonLib\application.h"
|
||||
#include "..\..\src\CommonLib\utility.h"
|
||||
#include "..\..\src\CommonLib\debugutil.h"
|
||||
#include "..\..\src\CommonLib\requesthandler.h"
|
||||
#include "..\..\src\CommonLib\resources.h"
|
||||
#include "..\..\src\CommonLib\aspnetcore_msg.h"
|
||||
|
||||
#include "CppUnitTest.h"
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SDKDDKVer.h>
|
||||
Loading…
Reference in New Issue