diff --git a/src/Servers/IIS/AspNetCoreModuleV2/CommonLib/HostFxrResolver.cpp b/src/Servers/IIS/AspNetCoreModuleV2/CommonLib/HostFxrResolver.cpp
index 45e3699fadc3..bd74be56b291 100644
--- a/src/Servers/IIS/AspNetCoreModuleV2/CommonLib/HostFxrResolver.cpp
+++ b/src/Servers/IIS/AspNetCoreModuleV2/CommonLib/HostFxrResolver.cpp
@@ -145,9 +145,10 @@ HostFxrResolver::GetHostFxrParameters(
}
BOOL
-HostFxrResolver::IsDotnetExecutable(const std::filesystem::path & dotnetPath)
+HostFxrResolver::IsDotnetExecutable(const std::filesystem::path& dotnetPath)
{
- return ends_with(dotnetPath, L"dotnet.exe", true);
+ std::wstring filename = dotnetPath.filename().wstring();
+ return equals_ignore_case(filename, L"dotnet.exe");
}
void
diff --git a/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/CommonLibTests.vcxproj b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/CommonLibTests.vcxproj
index 091a99e221ee..d8d0ef653b16 100644
--- a/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/CommonLibTests.vcxproj
+++ b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/CommonLibTests.vcxproj
@@ -43,6 +43,7 @@
+
@@ -71,6 +72,17 @@
{d57ea297-6dc2-4bc0-8c91-334863327863}
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
@@ -185,4 +197,4 @@
-
+
\ No newline at end of file
diff --git a/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/Fake/hello-dotnet.dll b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/Fake/hello-dotnet.dll
new file mode 100644
index 000000000000..88a3d89dd6ea
--- /dev/null
+++ b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/Fake/hello-dotnet.dll
@@ -0,0 +1 @@
+this a is faked hello-dotnet.dll used for tests
diff --git a/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/Fake/hello-dotnet.exe b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/Fake/hello-dotnet.exe
new file mode 100644
index 000000000000..18f1759669ac
--- /dev/null
+++ b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/Fake/hello-dotnet.exe
@@ -0,0 +1 @@
+this a is faked hello-dotnet.exe used for tests
diff --git a/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/Fake/hostfxr.dll b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/Fake/hostfxr.dll
new file mode 100644
index 000000000000..e96043e8c4f8
--- /dev/null
+++ b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/Fake/hostfxr.dll
@@ -0,0 +1 @@
+this a is faked hostfxr.dll used for tests
diff --git a/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/dotnet_exe_path_tests.cpp b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/dotnet_exe_path_tests.cpp
new file mode 100644
index 000000000000..1d767accdeba
--- /dev/null
+++ b/src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/dotnet_exe_path_tests.cpp
@@ -0,0 +1,44 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+#include "stdafx.h"
+
+#include
+#include "fakeclasses.h"
+#include "HostFxrResolver.h"
+
+using ::testing::_;
+using ::testing::NiceMock;
+
+// Externals defined in inprocess
+namespace InprocessTests
+{
+
+ TEST(Dotnet_EXE_Path_Tests, EndWith_dotnet)
+ {
+ HostFxrResolver resolver;
+ std::filesystem::path hostFxrDllPath;
+ std::vector arguments;
+ ErrorContext errorContext;
+ auto currentPath = std::filesystem::current_path();
+ auto appPath= currentPath /= L"Fake";
+ auto processPath = L"hello-dotnet";
+ auto args = L"-a --tag t -x";
+ std::filesystem::path knownDotnetLocation=L"C:/Program Files/dotnet";
+ // expected no exception should be thrown
+ HostFxrResolver::GetHostFxrParameters(
+ processPath,
+ appPath,
+ args,
+ hostFxrDllPath,
+ knownDotnetLocation,
+ arguments,
+ errorContext);
+
+ ASSERT_TRUE(ends_with(arguments[0], L"\\Fake\\hello-dotnet.exe", true));
+ ASSERT_STREQ(arguments[1].c_str(), L"-a");
+ ASSERT_STREQ(arguments[2].c_str(), L"--tag");
+ ASSERT_STREQ(arguments[3].c_str(), L"t");
+ ASSERT_STREQ(arguments[4].c_str(), L"-x");
+ }
+}