Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: phmonte/Buildalyzer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 145248ceb9244e8663091ed17e933165e0d2865d
Choose a base ref
..
head repository: phmonte/Buildalyzer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3d8f61a4fcdbb4e34fa3878104fb2a386671cbd2
Choose a head ref
1 change: 1 addition & 0 deletions src/Buildalyzer/EmptyDisposable.cs
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

namespace Buildalyzer;

[Obsolete("Will be dropped in the next major version.")]
public class EmptyDisposable : IDisposable
{
public void Dispose()
47 changes: 47 additions & 0 deletions src/Buildalyzer/Environment/DotNetInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#nullable enable

namespace Buildalyzer.Environment;

/// <summary>Information about the .NET environment.</summary>
/// <remarks>
/// Retrieved via `dotnet --info`.
/// </remarks>
public sealed class DotNetInfo
{
/// <summary>The version of the SDK.</summary>
public Version? SdkVersion { get; init; }

/// <summary>The name of the operating system.</summary>
public string? OSName { get; init; }

/// <summary>The platform of the operating system.</summary>
public string? OSPlatform { get; init; }

/// <summary>The version of the operating system.</summary>
public Version? OSVersion { get; init; }

/// <summary>The RID of the operating system.</summary>
public string? RID { get; init; }

/// <summary>The base path to the .NET environment.</summary>
public string? BasePath { get; init; }

/// <summary>The location of the global.json.</summary>
public string? GlobalJson { get; init; }

/// <summary>The installed SDK's.</summary>
public ImmutableDictionary<string, string> SDKs { get; init; } = ImmutableDictionary<string, string>.Empty;

/// <summary>The installed Runtimes.</summary>
public ImmutableDictionary<string, string> Runtimes { get; init; } = ImmutableDictionary<string, string>.Empty;

/// <summary>Parses the input.</summary>
[Pure]
public static DotNetInfo Parse(string? s)
=> Parse(s?.Split([System.Environment.NewLine], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) ?? []);

/// <summary>Parses the input.</summary>
[Pure]
public static DotNetInfo Parse(IEnumerable<string>? lines)
=> DotNetInfoParser.Parse(lines ?? []);
}
163 changes: 163 additions & 0 deletions src/Buildalyzer/Environment/DotNetInfoParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
#nullable enable

using System.IO;

namespace Buildalyzer.Environment;

internal static class DotNetInfoParser
{
private const StringComparison IgnoreCase = StringComparison.OrdinalIgnoreCase;

[Pure]
public static DotNetInfo Parse(IEnumerable<string> lines)
{
var header = string.Empty;

Check warning on line 14 in src/Buildalyzer/Environment/DotNetInfoParser.cs

GitHub Actions / Build (ubuntu-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1008)

Check warning on line 14 in src/Buildalyzer/Environment/DotNetInfoParser.cs

GitHub Actions / Build (macos-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1008)

Version? sdkVersion = null;
string? osName = null;
string? osPlatform = null;
Version? osVersion = null;
string? basePath = null;
string? globalJson = null;
string? rid = null;
var sdks = new Dictionary<string, string>();

Check warning on line 23 in src/Buildalyzer/Environment/DotNetInfoParser.cs

GitHub Actions / Build (ubuntu-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1012)
var runtimes = new Dictionary<string, string>();

Check warning on line 24 in src/Buildalyzer/Environment/DotNetInfoParser.cs

GitHub Actions / Build (ubuntu-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1012)

foreach (var line in lines.Select(l => l.Trim()).Where(l => l is { Length: > 0 }))

Check warning on line 26 in src/Buildalyzer/Environment/DotNetInfoParser.cs

GitHub Actions / Build (ubuntu-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1009)

Check warning on line 26 in src/Buildalyzer/Environment/DotNetInfoParser.cs

GitHub Actions / Build (macos-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1009)
{
// Update read header.
if (Headers.Contains(line))
{
header = line.ToUpperInvariant();
continue;
}

switch (header)
{
case "":
case ".NET SDK:":
sdkVersion ??= Version("Version:", line);
break;

case "RUNTIME ENVIRONMENT:":
basePath ??= BasePath(line);
osName ??= Label("OS Name:", line);
osPlatform ??= Label("OS Platform:", line);
osVersion ??= Version("OS Version:", line);
rid ??= Label("RID:", line);
break;

case ".NET SDKS INSTALLED:":
case ".NET CORE SDKS INSTALLED:":
AddSdk(line);
break;

case ".NET RUNTIMES INSTALLED:":
case ".NET CORE RUNTIMES INSTALLED:":
AddRunTime(line);
break;

case "GLOBAL.JSON FILE:":
globalJson ??= GlobalJson(line);
break;
}
}

return new DotNetInfo()
{
SdkVersion = sdkVersion,
OSName = osName,
OSPlatform = osPlatform,
OSVersion = osVersion,
RID = rid,
BasePath = basePath,
GlobalJson = globalJson,
SDKs = sdks.ToImmutableDictionary(),
Runtimes = runtimes.ToImmutableDictionary(),
};

void AddSdk(string line)
{
if (line.Split(new[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) is { Length: 2 } parts)
{
sdks[parts[0]] = UnifyPath(Path.Combine(parts[1], parts[0]));
}
}
void AddRunTime(string line)
{
if (line.Split(new[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) is { Length: 2 } parts)
{
runtimes[parts[0]] = UnifyPath(parts[1]);
}
}
}

[Pure]
private static Version? Version(string prefix, string line)
=> line.StartsWith(prefix, IgnoreCase) && System.Version.TryParse(line[prefix.Length..].Trim(), out var parsed)

Check warning on line 97 in src/Buildalyzer/Environment/DotNetInfoParser.cs

GitHub Actions / Build (ubuntu-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1008)

Check warning on line 97 in src/Buildalyzer/Environment/DotNetInfoParser.cs

GitHub Actions / Build (macos-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1008)

Check warning on line 97 in src/Buildalyzer/Environment/DotNetInfoParser.cs

GitHub Actions / Build (macos-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1012)
? parsed
: null;

[Pure]
private static string? Label(string prefix, string line)
=> line.StartsWith(prefix, IgnoreCase) && line[prefix.Length..].Trim() is { Length: > 0 } label
? label
: null;

[Pure]
private static string? BasePath(string line)
{
if (line.StartsWith("Base Path:", IgnoreCase))
{
var path = line[10..].Trim();

Check warning on line 112 in src/Buildalyzer/Environment/DotNetInfoParser.cs

GitHub Actions / Build (macos-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1008)

// Make sure the base path matches the runtime architecture if on Windows
// Note that this only works for the default installation locations under "Program Files"
if (path.Contains(@"\Program Files\") && !System.Environment.Is64BitProcess)
{
string newBasePath = path.Replace(@"\Program Files\", @"\Program Files (x86)\");
if (Directory.Exists(newBasePath))
{
path = newBasePath;
}
}
else if (path.Contains(@"\Program Files (x86)\") && System.Environment.Is64BitProcess)
{
string newBasePath = path.Replace(@"\Program Files (x86)\", @"\Program Files\");
if (Directory.Exists(newBasePath))
{
path = newBasePath;
}
}

return UnifyPath(path);
}
else
{
return null;
}
}

[Pure]
private static string UnifyPath(string path) => path.Replace('\\', '/').TrimEnd('/');

[Pure]
private static string? GlobalJson(string line)
=> line.Equals("Not found", IgnoreCase) ? null : line;

private static readonly HashSet<string> Headers = new(StringComparer.InvariantCultureIgnoreCase)
{
".NET SDK:",
"Runtime Environment:",
"Host:",
".NET workloads installed:",
".NET SDKs installed:",
".NET Core SDKs installed:",
".NET runtimes installed:",
".NET Core runtimes installed:",
"Other architectures found:",
"global.json file:",
"Learn more:",
"Download .NET:",
};
}
93 changes: 4 additions & 89 deletions src/Buildalyzer/Environment/DotnetPathResolver.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Extensions.Logging;

namespace Buildalyzer.Environment;
@@ -22,19 +19,13 @@ public DotnetPathResolver(ILoggerFactory loggerFactory)
// Don't cache the result because it might change project to project due to global.json
public string ResolvePath(string projectPath, string dotnetExePath)
{
dotnetExePath = dotnetExePath ?? "dotnet";
dotnetExePath ??= "dotnet";
List<string> output = GetInfo(projectPath, dotnetExePath);

// Did we get any output?
if (output == null || output.Count == 0)
{
_logger?.LogWarning($"Could not get results from `{dotnetExePath} --info` call");
return null;
}
var info = DotNetInfo.Parse(output);

Check warning on line 25 in src/Buildalyzer/Environment/DotnetPathResolver.cs

GitHub Actions / Build (ubuntu-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1012)

Check warning on line 25 in src/Buildalyzer/Environment/DotnetPathResolver.cs

GitHub Actions / Build (macos-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1012)
var basePath = info.BasePath ?? info.Runtimes.Values.FirstOrDefault();

Check warning on line 26 in src/Buildalyzer/Environment/DotnetPathResolver.cs

GitHub Actions / Build (ubuntu-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1008)

Check warning on line 26 in src/Buildalyzer/Environment/DotnetPathResolver.cs

GitHub Actions / Build (macos-latest)

([deprecated] Use RCS1264 instead) Use explicit type instead of 'var' (https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1008)

// Try to get a path
string basePath = ParseBasePath(output) ?? ParseInstalledSdksPath(output);
if (string.IsNullOrWhiteSpace(basePath))
if (basePath is null)
{
_logger?.LogWarning($"Could not locate SDK path in `{dotnetExePath} --info` results");
return null;
@@ -68,80 +59,4 @@ private List<string> GetInfo(string projectPath, string dotnetExePath)
return processRunner.Output;
}
}

// Try to find a base path
internal static string ParseBasePath(List<string> lines)
{
foreach (string line in lines.Where(x => x != null))
{
int colonIndex = line.IndexOf(':');
if (colonIndex >= 0
&& line.Substring(0, colonIndex).Trim().Equals("Base Path", StringComparison.OrdinalIgnoreCase))
{
string basePath = line.Substring(colonIndex + 1).Trim();

// Make sure the base path matches the runtime architecture if on Windows
// Note that this only works for the default installation locations under "Program Files"
if (basePath.Contains(@"\Program Files\") && !System.Environment.Is64BitProcess)
{
string newBasePath = basePath.Replace(@"\Program Files\", @"\Program Files (x86)\");
if (Directory.Exists(newBasePath))
{
basePath = newBasePath;
}
}
else if (basePath.Contains(@"\Program Files (x86)\") && System.Environment.Is64BitProcess)
{
string newBasePath = basePath.Replace(@"\Program Files (x86)\", @"\Program Files\");
if (Directory.Exists(newBasePath))
{
basePath = newBasePath;
}
}

return basePath;
}
}
return null;
}

// Fallback if a base path couldn't be found (I.e., global.json version is not available)
internal static string ParseInstalledSdksPath(List<string> lines)
{
int index = lines.IndexOf(".NET SDKs installed:");
if (index == -1)
{
index = lines.IndexOf(".NET Core SDKs installed:");
if (index == -1)
{
return null;
}
}

index++;
while (true)
{
if (index >= lines.Count - 1)
{
throw new InvalidOperationException("Could not find the .NET SDK.");
}

// Not a version number or an empty string?
string temp = lines[index].Trim();
if (string.IsNullOrWhiteSpace(temp) || !char.IsDigit(temp[0]))
{
index--;
break;
}

index++;
}

string[] segments = lines[index]
.Split(new[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries)
.Where(x => !string.IsNullOrWhiteSpace(x))
.Select(x => x.Trim())
.ToArray();
return $"{segments[1]}{Path.DirectorySeparatorChar}{segments[0]}{Path.DirectorySeparatorChar}";
}
}
23 changes: 15 additions & 8 deletions src/Buildalyzer/Logging/TextWriterLogger.cs
Original file line number Diff line number Diff line change
@@ -4,19 +4,26 @@

namespace Buildalyzer.Logging;

internal class TextWriterLogger : ILogger
/// <summary>Implements <see cref="ILogger"/> using a <see cref="TextWriter"/>.</summary>
internal sealed class TextWriterLogger(TextWriter textWriter) : ILogger
{
private readonly TextWriter _textWriter;

public TextWriterLogger(TextWriter textWriter)
{
_textWriter = textWriter;
}
private readonly TextWriter _textWriter = textWriter;

/// <inheritdoc />
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter) =>
_textWriter.Write(formatter(state, exception));

/// <inheritdoc />
public bool IsEnabled(LogLevel logLevel) => true;

public IDisposable BeginScope<TState>(TState state) => new EmptyDisposable();
/// <inheritdoc />
public IDisposable BeginScope<TState>(TState state) => new Scope();

private sealed class Scope : IDisposable
{
public void Dispose()
{
// Nothing to dispose.
}
}
}
6 changes: 6 additions & 0 deletions src/Buildalyzer/Properties/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
global using System;
global using System.Collections.Generic;
global using System.Collections.Immutable;
global using System.Diagnostics.Contracts;
global using System.Linq;
global using System.Text;
203 changes: 203 additions & 0 deletions tests/Buildalyzer.Tests/Environment/DotNetInfoFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
using Buildalyzer.Environment;
using FluentAssertions;

namespace Buildalyzer.Tests.Environment;

public class DotNetInfoFixture
{
[Test]
public void Parses_Windows_NET8()
{
var lines = @"
.NET SDK:
Version: 8.0.200
Commit: 438cab6a9d
Workload version: 8.0.200-manifests.e575128c
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows10
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.200\
.NET workloads installed:
There are no installed workloads to display.
Host:
Version: 8.0.2
Architecture: x64
Commit: 1381d5ebd2
.NET SDKs installed:
8.0.200 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0-rc.2.22472.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotn
et\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download";

var info = DotNetInfo.Parse(lines);

info.Should().BeEquivalentTo(new
{
SdkVersion = new Version(8, 0, 200),
OSName = "Windows",
OSVersion = new Version(10, 0, 22631),
OSPlatform = "Windows10",
RID = "win-x64",
SDKs = new Dictionary<string, string>()
{
["8.0.200"] = "C:/Program Files/dotnet/sdk/8.0.200"
},
Runtimes = new { Count = 25, },
BasePath = "C:/Program Files/dotnet/sdk/8.0.200",
});
}

[Test]
public void Parses_Windows_NET_Core()
{
var lines = @".NET Core SDK (reflecting any global.json):
Version: 2.1.300
Commit: adab45bf0c
Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.300\
Host (useful for support):
Version: 2.1.0
Commit: caa7b7e2ba
.NET Core SDKs installed:
2.1.200 [C:\Program Files\dotnet\sdk]
2.1.300 [C:\Program Files\dotnet\sdk]
2.1.201 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download";

var info = DotNetInfo.Parse(lines);

info.Should().BeEquivalentTo(new
{
SdkVersion = new Version(2, 1, 300),
OSName = "Windows",
OSVersion = new Version(6, 1, 7601),
OSPlatform = "Windows",
RID = "win7-x64",
SDKs = new Dictionary<string, string>()
{
["2.1.200"] = "C:/Program Files/dotnet/sdk/2.1.200",
["2.1.300"] = "C:/Program Files/dotnet/sdk/2.1.300",
["2.1.201"] = "C:/Program Files/dotnet/sdk/2.1.201",
},
Runtimes = new Dictionary<string, string>()
{
["Microsoft.AspNetCore.All 2.1.0"] = "C:/Program Files/dotnet/shared/Microsoft.AspNetCore.All",
["Microsoft.AspNetCore.App 2.1.0"] = "C:/Program Files/dotnet/shared/Microsoft.AspNetCore.App",
["Microsoft.NETCore.App 1.0.0"] = "C:/Program Files/dotnet/shared/Microsoft.NETCore.App",
["Microsoft.NETCore.App 1.0.1"] = "C:/Program Files/dotnet/shared/Microsoft.NETCore.App",
["Microsoft.NETCore.App 2.0.7"] = "C:/Program Files/dotnet/shared/Microsoft.NETCore.App",
["Microsoft.NETCore.App 2.1.0"] = "C:/Program Files/dotnet/shared/Microsoft.NETCore.App",
},
BasePath = "C:/Program Files/dotnet/sdk/2.1.300",
});
}

[Test]
public void Parses_Linux()
{
var lines = @"
.NET Core SDK (reflecting any global.json):
Version: 2.1.401
Commit: 91b1c13032
Runtime Environment:
OS Name: ubuntu
OS Version: 16.04
OS Platform: Linux
RID: ubuntu.16.04-x64
Base Path: /usr/share/dotnet/sdk/2.1.401/
Host (useful for support):
Version: 2.1.3
Commit: 124038c13e
.NET Core SDKs installed:
1.1.5 [/usr/share/dotnet/sdk]
1.1.6 [/usr/share/dotnet/sdk]
2.1.201 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.NETCore.App 2.1.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download";

var info = DotNetInfo.Parse(lines);

info.Should().BeEquivalentTo(new
{
SdkVersion = new Version(2, 1, 401),
OSName = "ubuntu",
OSVersion = new Version(16, 4),
OSPlatform = "Linux",
RID = "ubuntu.16.04-x64",
SDKs = new Dictionary<string, string>()
{
["1.1.5"] = "/usr/share/dotnet/sdk/1.1.5",
["1.1.6"] = "/usr/share/dotnet/sdk/1.1.6",
["2.1.201"] = "/usr/share/dotnet/sdk/2.1.201",
},
Runtimes = new Dictionary<string, string>()
{
["Microsoft.AspNetCore.All 2.1.3"] = "/usr/share/dotnet/shared/Microsoft.AspNetCore.All",
["Microsoft.NETCore.App 2.1.3"] = "/usr/share/dotnet/shared/Microsoft.NETCore.App",
},
BasePath = "/usr/share/dotnet/sdk/2.1.401",
});
}
}
234 changes: 0 additions & 234 deletions tests/Buildalyzer.Tests/Environment/DotnetPathResolverFixture.cs

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Buildalyzer.Tests/Properties/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
global using System;
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Text;