Skip to content

Commit 6daa2be

Browse files
Update the place for AllowQueryAllRuntimeVersions (#281)
* update the plae for AllowQueryAllRuntimeVersions and bump Microsoft.VisualStudio.Setup.Configuration.Interop version * undo version updates * fix review comments
1 parent 604477e commit 6daa2be

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/MSBuildLocator/MSBuildLocator.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
using System;
55
using System.Collections.Generic;
66
using System.ComponentModel;
7-
using System.Diagnostics;
87
using System.IO;
98
using System.Linq;
109
using System.Reflection;
1110
using System.Text;
1211

1312
#if NETCOREAPP
1413
using System.Runtime.Loader;
14+
#else
15+
using System.Diagnostics;
1516
#endif
1617

1718
namespace Microsoft.Build.Locator
@@ -367,14 +368,16 @@ private static IEnumerable<VisualStudioInstance> GetInstances(VisualStudioInstan
367368
if (devConsole != null)
368369
yield return devConsole;
369370

370-
#if FEATURE_VISUALSTUDIOSETUP
371+
#if FEATURE_VISUALSTUDIOSETUP
371372
foreach (var instance in VisualStudioLocationHelper.GetInstances())
372373
yield return instance;
373-
#endif
374+
#endif
374375
#endif
375376

376377
#if NETCOREAPP
377-
foreach (var dotnetSdk in DotNetSdkLocationHelper.GetInstances(options.WorkingDirectory, AllowQueryAllRuntimeVersions))
378+
// AllowAllRuntimeVersions was added to VisualStudioInstanceQueryOptions for fulfilling Roslyn's needs. One of the properties will be removed in v2.0.
379+
bool allowAllRuntimeVersions = AllowQueryAllRuntimeVersions || options.AllowAllRuntimeVersions;
380+
foreach (var dotnetSdk in DotNetSdkLocationHelper.GetInstances(options.WorkingDirectory, allowAllRuntimeVersions))
378381
yield return dotnetSdk;
379382
#endif
380383
}

src/MSBuildLocator/VisualStudioInstanceQueryOptions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ public class VisualStudioInstanceQueryOptions
2929
/// </summary>
3030
public DiscoveryType DiscoveryTypes { get; set; }
3131

32+
#if NETCOREAPP
33+
/// <summary>
34+
/// Allow discovery of .NET SDK versions that are unlikely to be successfully loaded in the current process.
35+
/// </summary>
36+
/// <remarks>
37+
/// 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.
38+
/// </remarks.
39+
public bool AllowAllRuntimeVersions { get; set; } = false;
40+
#endif
41+
3242
/// <summary>
3343
/// Working directory to use when querying for instances. Ensure it is the project directory to pick up the right global.json.
3444
/// </summary>

0 commit comments

Comments
 (0)