Skip to content

Commit 1c517b7

Browse files
authored
Revert "Merged PR 49480: [internal/release/8.0] Fix issue where libhost scena…" (#116553)
This reverts commit 5b9ae97.
1 parent 5b9ae97 commit 1c517b7

File tree

10 files changed

+4
-149
lines changed

10 files changed

+4
-149
lines changed

src/installer/tests/HostActivation.Tests/NativeHosting/Comhost.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -116,35 +116,6 @@ public void ActivateClass_IgnoreAppLocalHostFxr()
116116
}
117117
}
118118

119-
[Fact]
120-
public void ActivateClass_IgnoreWorkingDirectory()
121-
{
122-
using (TestArtifact cwd = TestArtifact.Create("cwd"))
123-
{
124-
// Validate that hosting components in the working directory will not be used
125-
File.Copy(Binaries.CoreClr.MockPath, Path.Combine(cwd.Location, Binaries.CoreClr.FileName));
126-
File.Copy(Binaries.HostFxr.MockPath_5_0, Path.Combine(cwd.Location, Binaries.HostFxr.FileName));
127-
File.Copy(Binaries.HostPolicy.MockPath, Path.Combine(cwd.Location, Binaries.HostPolicy.FileName));
128-
129-
string[] args = {
130-
"comhost",
131-
"synchronous",
132-
"1",
133-
sharedState.ComHostPath,
134-
sharedState.ClsidString
135-
};
136-
sharedState.CreateNativeHostCommand(args, sharedState.ComLibraryFixture.BuiltDotnet.BinPath)
137-
.WorkingDirectory(cwd.Location)
138-
.Execute()
139-
.Should().Pass()
140-
.And.HaveStdOutContaining("New instance of Server created")
141-
.And.HaveStdOutContaining($"Activation of {sharedState.ClsidString} succeeded.")
142-
.And.ResolveHostFxr(sharedState.ComLibraryFixture.BuiltDotnet)
143-
.And.ResolveHostPolicy(sharedState.ComLibraryFixture.BuiltDotnet)
144-
.And.ResolveCoreClr(sharedState.ComLibraryFixture.BuiltDotnet);
145-
}
146-
}
147-
148119
[Fact]
149120
public void ActivateClass_ValidateIErrorInfoResult()
150121
{

src/installer/tests/HostActivation.Tests/NativeHosting/NativeHostingResultExtensions.cs renamed to src/installer/tests/HostActivation.Tests/NativeHosting/FunctionPointerResultExtensions.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5-
using System.IO;
65

76
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeHosting
87
{
9-
internal static class NativeHostingResultExtensions
8+
internal static class FunctionPointerResultExtensions
109
{
1110
public static FluentAssertions.AndConstraint<CommandResultAssertions> ExecuteFunctionPointer(this CommandResultAssertions assertion, string methodName, int callCount, int returnValue)
1211
{
@@ -48,21 +47,5 @@ public static FluentAssertions.AndConstraint<CommandResultAssertions> ExecuteWit
4847
{
4948
return assertion.HaveStdOutContaining($"{assemblyName}: Location = '{location}'");
5049
}
51-
52-
public static FluentAssertions.AndConstraint<CommandResultAssertions> ResolveHostFxr(this CommandResultAssertions assertion, Microsoft.DotNet.Cli.Build.DotNetCli dotnet)
53-
{
54-
return assertion.HaveStdErrContaining($"Resolved fxr [{dotnet.GreatestVersionHostFxrFilePath}]");
55-
}
56-
57-
public static FluentAssertions.AndConstraint<CommandResultAssertions> ResolveHostPolicy(this CommandResultAssertions assertion, Microsoft.DotNet.Cli.Build.DotNetCli dotnet)
58-
{
59-
return assertion.HaveStdErrContaining($"{Binaries.HostPolicy.FileName} directory is [{dotnet.GreatestVersionSharedFxPath}]");
60-
}
61-
62-
public static FluentAssertions.AndConstraint<CommandResultAssertions> ResolveCoreClr(this CommandResultAssertions assertion, Microsoft.DotNet.Cli.Build.DotNetCli dotnet)
63-
{
64-
return assertion.HaveStdErrContaining($"CoreCLR path = '{Path.Combine(dotnet.GreatestVersionSharedFxPath, Binaries.CoreClr.FileName)}'")
65-
.And.HaveStdErrContaining($"CoreCLR dir = '{dotnet.GreatestVersionSharedFxPath}{Path.DirectorySeparatorChar}'");
66-
}
6750
}
6851
}

src/installer/tests/HostActivation.Tests/NativeHosting/Ijwhost.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,6 @@ public void LoadLibrary_ContextConfig(bool load_isolated)
7373
}
7474
}
7575

76-
[Fact]
77-
public void LoadLibrary_IgnoreWorkingDirectory()
78-
{
79-
using (TestArtifact cwd = TestArtifact.Create("cwd"))
80-
{
81-
// Validate that hosting components in the working directory will not be used
82-
File.Copy(Binaries.CoreClr.MockPath, Path.Combine(cwd.Location, Binaries.CoreClr.FileName));
83-
File.Copy(Binaries.HostFxr.MockPath_5_0, Path.Combine(cwd.Location, Binaries.HostFxr.FileName));
84-
File.Copy(Binaries.HostPolicy.MockPath, Path.Combine(cwd.Location, Binaries.HostPolicy.FileName));
85-
86-
string [] args = {
87-
"ijwhost",
88-
sharedState.IjwApp.AppDll,
89-
"NativeEntryPoint"
90-
};
91-
var dotnet = new Microsoft.DotNet.Cli.Build.DotNetCli(sharedState.RepoDirectories.BuiltDotnet);
92-
sharedState.CreateNativeHostCommand(args, sharedState.RepoDirectories.BuiltDotnet)
93-
.WorkingDirectory(cwd.Location)
94-
.Execute()
95-
.Should().Pass()
96-
.And.HaveStdOutContaining("[C++/CLI] NativeEntryPoint: calling managed class")
97-
.And.HaveStdOutContaining("[C++/CLI] ManagedClass: AssemblyLoadContext = \"Default\" System.Runtime.Loader.DefaultAssemblyLoadContext")
98-
.And.ResolveHostFxr(dotnet)
99-
.And.ResolveHostPolicy(dotnet)
100-
.And.ResolveCoreClr(dotnet);
101-
}
102-
}
103-
10476
[Theory]
10577
[InlineData(true)]
10678
[InlineData(false)]

src/installer/tests/HostActivation.Tests/NativeHosting/LoadAssemblyAndGetFunctionPointer.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -234,38 +234,6 @@ public void CallDelegateOnComponentContext_UnhandledException()
234234
.And.ExecuteFunctionPointerWithException(entryPoint, 1);
235235
}
236236

237-
[Fact]
238-
public void CallDelegateOnComponentContext_IgnoreWorkingDirectory()
239-
{
240-
using (TestArtifact cwd = TestArtifact.Create("cwd"))
241-
{
242-
// Validate that hosting components in the working directory will not be used
243-
File.Copy(Binaries.CoreClr.MockPath, Path.Combine(cwd.Location, Binaries.CoreClr.FileName));
244-
File.Copy(Binaries.HostPolicy.MockPath, Path.Combine(cwd.Location, Binaries.HostPolicy.FileName));
245-
246-
var component = sharedState.ComponentWithNoDependenciesFixture.TestProject;
247-
string[] args =
248-
{
249-
ComponentLoadAssemblyAndGetFunctionPointerArg,
250-
sharedState.HostFxrPath,
251-
component.RuntimeConfigJson,
252-
component.AppDll,
253-
sharedState.ComponentTypeName,
254-
sharedState.ComponentEntryPoint1,
255-
};
256-
257-
var dotnet = new Microsoft.DotNet.Cli.Build.DotNetCli(sharedState.DotNetRoot);
258-
sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
259-
.WorkingDirectory(cwd.Location)
260-
.Execute()
261-
.Should().Pass()
262-
.And.InitializeContextForConfig(component.RuntimeConfigJson)
263-
.And.ExecuteFunctionPointer(sharedState.ComponentEntryPoint1, 1, 1)
264-
.And.ResolveHostPolicy(dotnet)
265-
.And.ResolveCoreClr(dotnet);
266-
}
267-
}
268-
269237
public class SharedTestState : SharedTestStateBase
270238
{
271239
public string HostFxrPath { get; }

src/installer/tests/TestUtils/TestArtifact.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,6 @@ protected TestArtifact(TestArtifact source)
5252
source._copies.Add(this);
5353
}
5454

55-
/// <summary>
56-
/// Create a new test artifact.
57-
/// </summary>
58-
/// <param name="name">Name of the test artifact</param>
59-
/// <returns>Test artifact containing no files</returns>
60-
public static TestArtifact Create(string name)
61-
{
62-
var (location, parentPath) = GetNewTestArtifactPath(name);
63-
return new TestArtifact(location)
64-
{
65-
DirectoryToDelete = parentPath
66-
};
67-
}
68-
6955
protected void RegisterCopy(TestArtifact artifact)
7056
{
7157
_copies.Add(artifact);

src/native/corehost/apphost/standalone/hostfxr_resolver.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ hostfxr_resolver_t::hostfxr_resolver_t(const pal::string_t& app_root)
3838
{
3939
m_status_code = StatusCode::CoreHostLibMissingFailure;
4040
}
41-
else if (!pal::is_path_rooted(m_fxr_path))
42-
{
43-
// We should always be loading hostfxr from an absolute path
44-
m_status_code = StatusCode::CoreHostLibMissingFailure;
45-
}
4641
else if (pal::load_library(&m_fxr_path, &m_hostfxr_dll))
4742
{
4843
m_status_code = StatusCode::Success;

src/native/corehost/fxr/standalone/hostpolicy_resolver.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,6 @@ int hostpolicy_resolver::load(
180180
return StatusCode::CoreHostLibMissingFailure;
181181
}
182182

183-
// We should always be loading hostpolicy from an absolute path
184-
if (!pal::is_path_rooted(host_path))
185-
return StatusCode::CoreHostLibMissingFailure;
186-
187183
// Load library
188184
// We expect to leak hostpolicy - just as we do not unload coreclr, we do not unload hostpolicy
189185
if (!pal::load_library(&host_path, &g_hostpolicy))

src/native/corehost/fxr_resolver.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ int load_fxr_and_get_delegate(hostfxr_delegate_type type, THostPathToConfigCallb
4444
return StatusCode::CoreHostLibMissingFailure;
4545
}
4646

47-
// We should always be loading hostfxr from an absolute path
48-
if (!pal::is_path_rooted(fxr_path))
49-
return StatusCode::CoreHostLibMissingFailure;
50-
5147
// Load library
5248
if (!pal::load_library(&fxr_path, &fxr))
5349
{

src/native/corehost/hostpolicy/deps_resolver.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -830,21 +830,13 @@ bool deps_resolver_t::resolve_probe_dirs(
830830
}
831831
}
832832

833-
// If the deps file is missing for the app, add known locations.
834-
// For libhost scenarios, there is no app or app path
835-
if (m_host_mode != host_mode_t::libhost && !get_app_deps().exists())
833+
// If the deps file is missing add known locations.
834+
if (!get_app_deps().exists())
836835
{
837-
assert(!m_app_dir.empty());
838-
839836
// App local path
840837
add_unique_path(asset_type, m_app_dir, &items, output, &non_serviced, core_servicing);
841838

842-
if (m_coreclr_path.empty())
843-
{
844-
// deps_resolver treats being able to get the coreclr path as optional, so we ignore the return value here.
845-
// The caller is responsible for checking whether coreclr path is set and handling as appropriate.
846-
(void) library_exists_in_dir(m_app_dir, LIBCORECLR_NAME, &m_coreclr_path);
847-
}
839+
(void) library_exists_in_dir(m_app_dir, LIBCORECLR_NAME, &m_coreclr_path);
848840
}
849841

850842
// Handle any additional deps.json that were specified.

src/native/corehost/hostpolicy/standalone/coreclr_resolver.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ bool coreclr_resolver_t::resolve_coreclr(const pal::string_t& libcoreclr_path, c
1313
pal::string_t coreclr_dll_path(libcoreclr_path);
1414
append_path(&coreclr_dll_path, LIBCORECLR_NAME);
1515

16-
// We should always be loading coreclr from an absolute path
17-
if (!pal::is_path_rooted(coreclr_dll_path))
18-
return false;
19-
2016
if (!pal::load_library(&coreclr_dll_path, &coreclr_resolver_contract.coreclr))
2117
{
2218
return false;

0 commit comments

Comments
 (0)