diff --git a/src/Workspaces/Core/MSBuild.BuildHost/BuildHost.cs b/src/Workspaces/Core/MSBuild.BuildHost/BuildHost.cs
index 08e8008ad8046..7a39c7190ef54 100644
--- a/src/Workspaces/Core/MSBuild.BuildHost/BuildHost.cs
+++ b/src/Workspaces/Core/MSBuild.BuildHost/BuildHost.cs
@@ -161,9 +161,15 @@ private void EnsureMSBuildLoaded(string projectFilePath)
///
/// Returns the target ID of the object created for this.
///
- public async Task LoadProjectFileAsync(string projectFilePath, string languageName, CancellationToken cancellationToken)
+ public Task LoadProjectFileAsync(string projectFilePath, string languageName, CancellationToken cancellationToken)
{
EnsureMSBuildLoaded(projectFilePath);
+ return LoadProjectFileCoreAsync(projectFilePath, languageName, cancellationToken);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)] // Do not inline this, since this uses MSBuild types which are being loaded by the caller
+ private async Task LoadProjectFileCoreAsync(string projectFilePath, string languageName, CancellationToken cancellationToken)
+ {
CreateBuildManager();
ProjectFileLoader projectLoader = languageName switch