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

Build NetCoreApp2.1 test project with .NET Core SDK 2.1 #2040

Merged
merged 5 commits into from
Dec 15, 2020
Merged
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
2 changes: 2 additions & 0 deletions build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"DotNetInstallScriptURL": "https://dot.net/v1",
"DotNetChannel": "Preview",
"DotNetVersions": [
"2.1.811",
"3.1.403",
"5.0.100"
],
Expand Down Expand Up @@ -44,6 +45,7 @@
"ProjectWithDisabledAnalyzers2",
"ProjectWithAnalyzers",
"NetCore21Project",
"NetCore31Project",
"Net50Project",
"ProjectWithAnalyzersAndEditorConfig",
"ProjectWithParentEditorConfig"
Expand Down
5 changes: 5 additions & 0 deletions test-assets/test-projects/NetCore21Project/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "2.1.811"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

</Project>
12 changes: 12 additions & 0 deletions test-assets/test-projects/NetCore31Project/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace ProjectAndSolution
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
5 changes: 5 additions & 0 deletions test-assets/test-projects/NetCore31Project/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "3.1.403"
}
}
18 changes: 15 additions & 3 deletions tests/OmniSharp.MSBuild.Tests/ProjectLoadListenerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,35 @@ public async Task The_correct_project_capablities_is_emitted()
using var testProject = await TestAssets.Instance.GetTestProjectAsync("NetCore21Project");
using var host = CreateMSBuildTestHost(testProject.Directory, emitter.AsExportDescriptionProvider(LoggerFactory));
Assert.Single(emitter.ReceivedMessages);
Assert.Equal("GenerateDocumentationFile CSharp Managed ReferencesFolder LanguageService RelativePathDerivedDefaultNamespace AssemblyReferences COMReferences ProjectReferences SharedProjectReferences OutputGroups AllTargetOutputGroups VisualStudioWellKnownOutputGroups SingleFileGenerators DeclaredSourceItems UserSourceItems BuildWindowsDesktopTarget CrossPlatformExecutable Pack", string.Join(" ", emitter.ReceivedMessages[0].ProjectCapabilities));
Assert.Equal("GenerateDocumentationFile CSharp Managed ReferencesFolder LanguageService RelativePathDerivedDefaultNamespace AssemblyReferences COMReferences ProjectReferences SharedProjectReferences OutputGroups AllTargetOutputGroups VisualStudioWellKnownOutputGroups SingleFileGenerators DeclaredSourceItems UserSourceItems BuildWindowsDesktopTarget CrossPlatformExecutable FolderPublish Pack", string.Join(" ", emitter.ReceivedMessages[0].ProjectCapabilities));
}

[Fact]
public async Task The_correct_sdk_version_is_emitted()
public async Task The_correct_sdk_version_is_emitted_NETCore2_1()
{
// Arrange
var emitter = new ProjectLoadTestEventEmitter();

using var testProject = await TestAssets.Instance.GetTestProjectAsync("NetCore21Project");
using var host = CreateMSBuildTestHost(testProject.Directory, emitter.AsExportDescriptionProvider(LoggerFactory));
Assert.Single(emitter.ReceivedMessages);
Assert.Equal(GetHashedFileExtension("2.1.811"), emitter.ReceivedMessages[0].SdkVersion);
}

[Fact]
public async Task The_correct_sdk_version_is_emitted_NETCore3_1()
{
// Arrange
var emitter = new ProjectLoadTestEventEmitter();

using var testProject = await TestAssets.Instance.GetTestProjectAsync("NetCore31Project");
using var host = CreateMSBuildTestHost(testProject.Directory, emitter.AsExportDescriptionProvider(LoggerFactory));
Assert.Single(emitter.ReceivedMessages);
Assert.Equal(GetHashedFileExtension("3.1.403"), emitter.ReceivedMessages[0].SdkVersion);
}

[Fact]
public async Task The_correct_sdk_version_is_emitted_2()
public async Task The_correct_sdk_version_is_emitted_NET5()
{
// Arrange
var emitter = new ProjectLoadTestEventEmitter();
Expand Down