Skip to content

Commit

Permalink
Build on .NET 7 SDK.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Apr 10, 2022
1 parent b7b0ced commit 10947a7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<MicrosoftExtensionPackageVersion>6.0.0</MicrosoftExtensionPackageVersion>
<MicrosoftTestPackageVersion>17.0.0</MicrosoftTestPackageVersion>
<MSBuildPackageVersion>17.0.0</MSBuildPackageVersion>
<NuGetPackageVersion>6.1.0</NuGetPackageVersion>
<NuGetPackageVersion>6.2.0-preview.2.80</NuGetPackageVersion>
<RoslynPackageVersion>4.2.0-3.22169.1</RoslynPackageVersion>
<XunitPackageVersion>2.4.1</XunitPackageVersion>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "6.0.201"
"version": "7.0.100-preview.2.22153.17"
}
}
24 changes: 7 additions & 17 deletions tests/OmniSharp.MSBuild.Tests/AbstractMSBuildTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Composition.Hosting.Core;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OmniSharp.MSBuild.Discovery;
using OmniSharp.Roslyn.Utilities;
Expand All @@ -13,34 +11,26 @@

namespace OmniSharp.MSBuild.Tests
{
public abstract class AbstractMSBuildTestFixture : AbstractTestFixture, IDisposable
public abstract class AbstractMSBuildTestFixture : AbstractTestFixture
{
private readonly IAssemblyLoader _assemblyLoader;
private readonly IMSBuildLocator _msbuildLocator;
private readonly IAnalyzerAssemblyLoader _analyzerAssemblyLoader;

public AbstractMSBuildTestFixture(ITestOutputHelper output)
: base(output)
{
_assemblyLoader = new AssemblyLoader(this.LoggerFactory);
_analyzerAssemblyLoader = ShadowCopyAnalyzerAssemblyLoader.Instance;
_msbuildLocator = MSBuildLocator.CreateDefault(this.LoggerFactory, _assemblyLoader, configuration: null);

// Some tests require MSBuild to be discovered early
// to ensure that the Microsoft.Build.* assemblies can be located
_msbuildLocator.RegisterDefaultInstance(this.LoggerFactory.CreateLogger("MSBuildTests"), dotNetInfo: null);
}

public void Dispose()
{
(_msbuildLocator as IDisposable)?.Dispose();
}

protected OmniSharpTestHost CreateMSBuildTestHost(string path, IEnumerable<ExportDescriptorProvider> additionalExports = null,
protected OmniSharpTestHost CreateMSBuildTestHost(
string path,
IEnumerable<ExportDescriptorProvider> additionalExports = null,
IConfiguration configurationData = null)
{
var environment = new OmniSharpEnvironment(path, logLevel: LogLevel.Trace);
var serviceProvider = TestServiceProvider.Create(this.TestOutput, environment, this.LoggerFactory, _assemblyLoader, _analyzerAssemblyLoader, _msbuildLocator,
using var msbuildLocator = MSBuildLocator.CreateDefault(this.LoggerFactory, _assemblyLoader, configurationData);
var serviceProvider = TestServiceProvider.Create(this.TestOutput, environment, this.LoggerFactory, _assemblyLoader, _analyzerAssemblyLoader, msbuildLocator,
configurationData);

return OmniSharpTestHost.Create(serviceProvider, additionalExports);
Expand Down
7 changes: 6 additions & 1 deletion tests/OmniSharp.MSBuild.Tests/ProjectLoadListenerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,16 @@ public async Task The_correct_sdk_version_is_emitted_NET6()
[ConditionalFact(typeof(NonMonoRuntimeOnly))]
public async Task The_correct_sdk_version_is_emitted_NET7()
{
var configuration = new Dictionary<string, string>
{
["sdk:IncludePrereleases"] = bool.TrueString
}.ToConfiguration();

// Arrange
var emitter = new ProjectLoadTestEventEmitter();

using var testProject = await TestAssets.Instance.GetTestProjectAsync("Net70Project");
using var host = CreateMSBuildTestHost(testProject.Directory, emitter.AsExportDescriptionProvider(LoggerFactory));
using var host = CreateMSBuildTestHost(testProject.Directory, emitter.AsExportDescriptionProvider(LoggerFactory), configuration);
Assert.Single(emitter.ReceivedMessages);
Assert.Equal(GetHashedFileExtension("7.0.100-preview.2.22153.17"), emitter.ReceivedMessages[0].SdkVersion);
}
Expand Down

0 comments on commit 10947a7

Please sign in to comment.