Skip to content
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

Update the place for AllowQueryAllRuntimeVersions #281

Merged
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
11 changes: 7 additions & 4 deletions src/MSBuildLocator/MSBuildLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

#if NETCOREAPP
using System.Runtime.Loader;
#else
using System.Diagnostics;
#endif

namespace Microsoft.Build.Locator
Expand Down Expand Up @@ -354,14 +355,16 @@ private static IEnumerable<VisualStudioInstance> GetInstances(VisualStudioInstan
if (devConsole != null)
yield return devConsole;

#if FEATURE_VISUALSTUDIOSETUP
#if FEATURE_VISUALSTUDIOSETUP
foreach (var instance in VisualStudioLocationHelper.GetInstances())
yield return instance;
#endif
#endif
#endif

#if NETCOREAPP
foreach (var dotnetSdk in DotNetSdkLocationHelper.GetInstances(options.WorkingDirectory, AllowQueryAllRuntimeVersions))
// AllowAllRuntimeVersions was added to VisualStudioInstanceQueryOptions for fulfilling Roslyn's needs. One of the properties will be removed in v2.0.
bool allowAllRuntimeVersions = AllowQueryAllRuntimeVersions || options.AllowAllRuntimeVersions;
foreach (var dotnetSdk in DotNetSdkLocationHelper.GetInstances(options.WorkingDirectory, allowAllRuntimeVersions))
yield return dotnetSdk;
#endif
}
Expand Down
10 changes: 10 additions & 0 deletions src/MSBuildLocator/VisualStudioInstanceQueryOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ public class VisualStudioInstanceQueryOptions
/// </summary>
public DiscoveryType DiscoveryTypes { get; set; }

#if NETCOREAPP
/// <summary>
/// Allow discovery of .NET SDK versions that are unlikely to be successfully loaded in the current process.
/// </summary>
/// <remarks>
/// Defaults to <see langword="false"/>. Set this to <see langword="true"/> only if your application has special logic to handle loading an incompatible SDK, such as launching a new process with the target SDK's runtime.
/// </remarks.
public bool AllowAllRuntimeVersions { get; set; } = false;
#endif

/// <summary>
/// Working directory to use when querying for instances. Ensure it is the project directory to pick up the right global.json.
/// </summary>
Expand Down
Loading