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

Indicates whether Roslyn is included #109

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion src/MSBuildLocator/DotNetSdkLocationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public static VisualStudioInstance GetInstance(string workingDirectory)
name: ".NET Core SDK",
path: dotNetSdkPath,
version: new Version(major, minor, patch),
discoveryType: DiscoveryType.DotNetSdk);
discoveryType: DiscoveryType.DotNetSdk,
true);
}

private static string GetDotNetBasePath(string workingDirectory)
Expand Down
2 changes: 1 addition & 1 deletion src/MSBuildLocator/MSBuildLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ private static VisualStudioInstance GetDevConsoleInstance()

if(version != null)
{
return new VisualStudioInstance("DEVCONSOLE", path, version, DiscoveryType.DeveloperConsole);
return new VisualStudioInstance("DEVCONSOLE", path, version, DiscoveryType.DeveloperConsole, false);
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/MSBuildLocator/VisualStudioInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ namespace Microsoft.Build.Locator
/// </summary>
public class VisualStudioInstance
{
internal VisualStudioInstance(string name, string path, Version version, DiscoveryType discoveryType)
internal VisualStudioInstance(string name, string path, Version version, DiscoveryType discoveryType, bool hasCSharp)
{
Name = name;
VisualStudioRootPath = path;
Version = version;
DiscoveryType = discoveryType;
ContainsRoslynCompiler = hasCSharp;

switch (discoveryType)
{
Expand Down Expand Up @@ -59,5 +60,10 @@ internal VisualStudioInstance(string name, string path, Version version, Discove
/// Indicates how this instance was discovered.
/// </summary>
public DiscoveryType DiscoveryType { get; }

/// <summary>
/// Indicates whether this instance has the C# package installed.
/// </summary>
public bool ContainsRoslynCompiler { get; }
}
}
16 changes: 5 additions & 11 deletions src/MSBuildLocator/VisualStudioLocationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Setup.Configuration;

Expand Down Expand Up @@ -53,24 +54,17 @@ internal static IList<VisualStudioInstance> GetInstances()
if (state == InstanceState.Complete ||
(state.HasFlag(InstanceState.Registered) && state.HasFlag(InstanceState.NoRebootRequired)))
{
bool instanceHasMSBuild = false;

foreach (ISetupPackageReference package in instance.GetPackages())
{
if (string.Equals(package.GetId(), "Microsoft.Component.MSBuild", StringComparison.OrdinalIgnoreCase))
{
instanceHasMSBuild = true;
break;
}
}
bool instanceHasMSBuild = instance.GetPackages().Any(package => package.GetId().Equals("Microsoft.Component.MSBuild", StringComparison.OrdinalIgnoreCase));

if (instanceHasMSBuild)
{
bool instanceHasCSCompiler = instance.GetPackages().Any(package => package.GetId().Equals("Microsoft.VisualStudio.Component.Roslyn.Compiler", StringComparison.OrdinalIgnoreCase));
validInstances.Add(new VisualStudioInstance(
instance.GetDisplayName(),
instance.GetInstallationPath(),
version,
DiscoveryType.VisualStudioSetup));
DiscoveryType.VisualStudioSetup,
instanceHasCSCompiler));
}
}
} while (fetched > 0);
Expand Down