Skip to content

Fix ANCM search for dotnet.exe #18311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="ConfigUtilityTests.cpp" />
<ClCompile Include="dotnet_exe_path_tests.cpp" />
<ClCompile Include="GlobalVersionTests.cpp" />
<ClCompile Include="Helpers.cpp" />
<ClCompile Include="inprocess_application_tests.cpp" />
Expand Down Expand Up @@ -71,6 +72,17 @@
<Project>{d57ea297-6dc2-4bc0-8c91-334863327863}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Fake\hello-dotnet.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Fake\hello-dotnet.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Fake\hostfxr.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemDefinitionGroup />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down Expand Up @@ -185,4 +197,4 @@
</AdditionalDependencies>
</Lib>
</ItemDefinitionGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this a is faked hello-dotnet.dll used for tests
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this a is faked hello-dotnet.exe used for tests
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this a is faked hostfxr.dll used for tests
Original file line number Diff line number Diff line change
@@ -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 <array>
#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<std::wstring> 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");
}
}