forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only resolve FrameworkReferences on correct target framework
Fixes dotnet#2527
- Loading branch information
1 parent
6e54f4a
commit c6be6bc
Showing
4 changed files
with
163 additions
and
17 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/ResolveFrameworkReferencesTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Microsoft.NET.Build.Tasks.UnitTests | ||
{ | ||
public class ResolveFrameworkReferencesTests | ||
{ | ||
[Fact] | ||
public void It_resolves_FrameworkReferences() | ||
{ | ||
var task = new ResolveFrameworkReferences(); | ||
|
||
task.TargetFrameworkIdentifier = ".NETCoreApp"; | ||
task.TargetFrameworkVersion = "3.0"; | ||
task.FrameworkReferences = new[] | ||
{ | ||
new MockTaskItem("Microsoft.AspNetCore.App", new Dictionary<string, string>()) | ||
}; | ||
|
||
task.KnownFrameworkReferences = new[] | ||
{ | ||
new MockTaskItem("Microsoft.AspNetCore.App", | ||
new Dictionary<string, string>() | ||
{ | ||
{ "TargetFramework", "netcoreapp3.0" }, | ||
{ "RuntimeFrameworkName", "Microsoft.AspNetCore.App" }, | ||
{ "DefaultRuntimeFrameworkVersion", "1.9.5" }, | ||
{ "LatestRuntimeFrameworkVersion", "1.9.6" }, | ||
{ "TargetingPackName", "Microsoft.AspNetCore.App" }, | ||
{ "TargetingPackVersion", "1.9.0" } | ||
}) | ||
}; | ||
|
||
task.Execute().Should().BeTrue(); | ||
|
||
task.PackageReferencesToAdd.Length.Should().Be(1); | ||
|
||
task.RuntimeFrameworks.Length.Should().Be(1); | ||
task.RuntimeFrameworks[0].ItemSpec.Should().Be("Microsoft.AspNetCore.App"); | ||
task.RuntimeFrameworks[0].GetMetadata(MetadataKeys.Version).Should().Be("1.9.5"); | ||
|
||
task.UnresolvedFrameworkReferences.Should().BeNull(); | ||
} | ||
|
||
[Fact] | ||
public void It_does_not_resolve_FrameworkReferences_if_targetframework_doesnt_match() | ||
{ | ||
var task = new ResolveFrameworkReferences(); | ||
|
||
task.TargetFrameworkIdentifier = ".NETCoreApp"; | ||
task.TargetFrameworkVersion = "2.0"; | ||
task.FrameworkReferences = new[] | ||
{ | ||
new MockTaskItem("Microsoft.AspNetCore.App", new Dictionary<string, string>()) | ||
}; | ||
|
||
task.KnownFrameworkReferences = new[] | ||
{ | ||
new MockTaskItem("Microsoft.AspNetCore.App", | ||
new Dictionary<string, string>() | ||
{ | ||
{ "TargetFramework", "netcoreapp3.0" }, | ||
{ "RuntimeFrameworkName", "Microsoft.AspNetCore.App" }, | ||
{ "DefaultRuntimeFrameworkVersion", "1.9.5" }, | ||
{ "LatestRuntimeFrameworkVersion", "1.9.6" }, | ||
{ "TargetingPackName", "Microsoft.AspNetCore.App" }, | ||
{ "TargetingPackVersion", "1.9.0" } | ||
}) | ||
}; | ||
|
||
task.Execute().Should().BeTrue(); | ||
|
||
task.PackageReferencesToAdd.Should().BeNull(); | ||
task.RuntimeFrameworks.Should().BeNull(); | ||
|
||
task.UnresolvedFrameworkReferences.Length.Should().Be(1); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters