Skip to content

Commit

Permalink
Update the place for AllowQueryAllRuntimeVersions (#281)
Browse files Browse the repository at this point in the history
* update the plae for AllowQueryAllRuntimeVersions and bump Microsoft.VisualStudio.Setup.Configuration.Interop version

* undo version updates

* fix review comments
  • Loading branch information
YuliiaKovalova authored Mar 4, 2024
1 parent 604477e commit 6daa2be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
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 @@ -367,14 +368,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

0 comments on commit 6daa2be

Please sign in to comment.