Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.IO;
using FluentAssertions;
using Microsoft.NET.TestFramework;
using Xunit;

namespace Microsoft.NET.Build.Tasks.UnitTests
Expand Down Expand Up @@ -39,7 +40,7 @@ public void ItCanGenerateWithoutAssetFile()
var task = new TestableGenerateRuntimeConfigurationFiles
{
BuildEngine = new MockNeverCacheBuildEngine4(),
TargetFrameworkMoniker = ".NETCoreApp,Version=v3.0",
TargetFrameworkMoniker = ".NETCoreApp,Version=v6.0",
RuntimeConfigPath = _runtimeConfigPath,
RuntimeConfigDevPath = _runtimeConfigDevPath,
RuntimeFrameworks = new[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the 3.0.0-preview1.100 should be a 6.0 version since it appears to be trying to roll forward on the latest minor if I'm reading this right.

Expand All @@ -48,7 +49,7 @@ public void ItCanGenerateWithoutAssetFile()
"Microsoft.NETCore.App",
new Dictionary<string, string>
{
{"FrameworkName", "Microsoft.NETCore.App"}, {"Version", "3.0.0-preview1.100"}
{"FrameworkName", "Microsoft.NETCore.App"}, {"Version", "6.0.0"}
}
)
},
Expand All @@ -60,16 +61,16 @@ public void ItCanGenerateWithoutAssetFile()

File.ReadAllText(_runtimeConfigPath).Should()
.Be(
@"{
""runtimeOptions"": {
""tfm"": ""netcoreapp3.0"",
$@"{{
""runtimeOptions"": {{
""tfm"": ""{ToolsetInfo.CurrentTargetFramework}"",
""rollForward"": ""LatestMinor"",
""framework"": {
""framework"": {{
""name"": ""Microsoft.NETCore.App"",
""version"": ""3.0.0-preview1.100""
}
}
}");
""version"": ""6.0.0""
}}
}}
}}");
File.Exists(_runtimeConfigDevPath).Should().BeFalse("No nuget involved, so no extra probing path");
}

Expand All @@ -80,7 +81,7 @@ public void Given3RuntimeFrameworksItCanGenerateWithoutAssetFile()
var task = new TestableGenerateRuntimeConfigurationFiles
{
BuildEngine = new MockNeverCacheBuildEngine4(),
TargetFrameworkMoniker = ".NETCoreApp,Version=v3.0",
TargetFrameworkMoniker = ".NETCoreApp,Version=v6.0",
RuntimeConfigPath = _runtimeConfigPath,
RuntimeConfigDevPath = _runtimeConfigDevPath,
RuntimeFrameworks = new[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mock items below this are all 3.1.0 frameworks. I believe those should get updated too.

Expand All @@ -89,21 +90,21 @@ public void Given3RuntimeFrameworksItCanGenerateWithoutAssetFile()
"Microsoft.NETCore.App",
new Dictionary<string, string>
{
{"FrameworkName", "Microsoft.NETCore.App"}, {"Version", "3.1.0"}
{"FrameworkName", "Microsoft.NETCore.App"}, {"Version", "6.0.0"}
}
),
new MockTaskItem(
"Microsoft.WindowsDesktop.App",
new Dictionary<string, string>
{
{"FrameworkName", "Microsoft.WindowsDesktop.App"}, {"Version", "3.1.0"}
{"FrameworkName", "Microsoft.WindowsDesktop.App"}, {"Version", "6.0.0"}
}
),
new MockTaskItem(
"Microsoft.AspNetCore.App",
new Dictionary<string, string>
{
{"FrameworkName", "Microsoft.AspNetCore.App"}, {"Version", "3.1.0"}
{"FrameworkName", "Microsoft.AspNetCore.App"}, {"Version", "6.0.0"}
}
)
},
Expand All @@ -115,22 +116,22 @@ public void Given3RuntimeFrameworksItCanGenerateWithoutAssetFile()

File.ReadAllText(_runtimeConfigPath).Should()
.Be(
@"{
""runtimeOptions"": {
""tfm"": ""netcoreapp3.0"",
$@"{{
""runtimeOptions"": {{
""tfm"": ""{ToolsetInfo.CurrentTargetFramework}"",
""rollForward"": ""LatestMinor"",
""frameworks"": [
{
{{
""name"": ""Microsoft.WindowsDesktop.App"",
""version"": ""3.1.0""
},
{
""version"": ""6.0.0""
}},
{{
""name"": ""Microsoft.AspNetCore.App"",
""version"": ""3.1.0""
}
""version"": ""6.0.0""
}}
]
}
}",
}}
}}",
"There is no Microsoft.NETCore.App. And it is under frameworkS.");
}

Expand All @@ -140,7 +141,7 @@ public void Given2RuntimeFrameworksItCanGenerateWithoutAssetFile()
var task = new TestableGenerateRuntimeConfigurationFiles
{
BuildEngine = new MockNeverCacheBuildEngine4(),
TargetFrameworkMoniker = ".NETCoreApp,Version=v3.0",
TargetFrameworkMoniker = ".NETCoreApp,Version=v6.0",
RuntimeConfigPath = _runtimeConfigPath,
RuntimeConfigDevPath = _runtimeConfigDevPath,
RuntimeFrameworks = new[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above with the below mocktaskitems.

Expand All @@ -149,14 +150,14 @@ public void Given2RuntimeFrameworksItCanGenerateWithoutAssetFile()
"Microsoft.NETCore.App",
new Dictionary<string, string>
{
{"FrameworkName", "Microsoft.NETCore.App"}, {"Version", "3.1.0"}
{"FrameworkName", "Microsoft.NETCore.App"}, {"Version", "6.0.0"}
}
),
new MockTaskItem(
"Microsoft.WindowsDesktop.App",
new Dictionary<string, string>
{
{"FrameworkName", "Microsoft.WindowsDesktop.App"}, {"Version", "3.1.0"}
{"FrameworkName", "Microsoft.WindowsDesktop.App"}, {"Version", "6.0.0"}
}
)
},
Expand All @@ -168,16 +169,16 @@ public void Given2RuntimeFrameworksItCanGenerateWithoutAssetFile()

File.ReadAllText(_runtimeConfigPath).Should()
.Be(
@"{
""runtimeOptions"": {
""tfm"": ""netcoreapp3.0"",
$@"{{
""runtimeOptions"": {{
""tfm"": ""{ToolsetInfo.CurrentTargetFramework}"",
""rollForward"": ""LatestMinor"",
""framework"": {
""framework"": {{
""name"": ""Microsoft.WindowsDesktop.App"",
""version"": ""3.1.0""
}
}
}",
""version"": ""6.0.0""
}}
}}
}}",
"There is no Microsoft.NETCore.App.");
}

Expand All @@ -187,7 +188,7 @@ public void GivenTargetMonikerItGeneratesShortName()
var task = new TestableGenerateRuntimeConfigurationFiles
{
BuildEngine = new MockNeverCacheBuildEngine4(),
TargetFrameworkMoniker = ".NETCoreApp,Version=v5.0",
TargetFrameworkMoniker = ".NETCoreApp,Version=v6.0",
RuntimeConfigPath = _runtimeConfigPath,
RuntimeConfigDevPath = _runtimeConfigDevPath,
RuntimeFrameworks = new[]
Expand All @@ -196,7 +197,7 @@ public void GivenTargetMonikerItGeneratesShortName()
"Microsoft.NETCore.App",
new Dictionary<string, string>
{
{"FrameworkName", "Microsoft.NETCore.App"}, {"Version", "5.0.0"}
{"FrameworkName", "Microsoft.NETCore.App"}, {"Version", "6.0.0"}
}
)
},
Expand All @@ -208,16 +209,16 @@ public void GivenTargetMonikerItGeneratesShortName()

File.ReadAllText(_runtimeConfigPath).Should()
.Be(
@"{
""runtimeOptions"": {
""tfm"": ""net5.0"",
$@"{{
""runtimeOptions"": {{
""tfm"": ""{ToolsetInfo.CurrentTargetFramework}"",
""rollForward"": ""LatestMinor"",
""framework"": {
""framework"": {{
""name"": ""Microsoft.NETCore.App"",
""version"": ""5.0.0""
}
}
}");
""version"": ""6.0.0""
}}
}}
}}");
}

private class TestableGenerateRuntimeConfigurationFiles : GenerateRuntimeConfigurationFiles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using FluentAssertions;
using Microsoft.NET.TestFramework;
using Xunit;

namespace Microsoft.NET.Build.Tasks.UnitTests
Expand Down Expand Up @@ -47,7 +48,7 @@ public void It_resolves_FrameworkReferences()

task.EnableTargetingPackDownload = true;
task.TargetFrameworkIdentifier = ".NETCoreApp";
task.TargetFrameworkVersion = "3.0";
task.TargetFrameworkVersion = ToolsetInfo.CurrentTargetFrameworkVersion;
task.FrameworkReferences = new[]
{
new MockTaskItem("Microsoft.AspNetCore.App", new Dictionary<string, string>())
Expand All @@ -58,7 +59,7 @@ public void It_resolves_FrameworkReferences()
new MockTaskItem("Microsoft.AspNetCore.App",
new Dictionary<string, string>()
{
{"TargetFramework", "netcoreapp3.0"},
{"TargetFramework", ToolsetInfo.CurrentTargetFramework},
{"RuntimeFrameworkName", "Microsoft.AspNetCore.App"},
{"DefaultRuntimeFrameworkVersion", "1.9.5"},
{"LatestRuntimeFrameworkVersion", "1.9.6"},
Expand All @@ -83,7 +84,7 @@ public void Given_targetPlatform_and_targetPlatform_version_It_resolves_Framewor

task.EnableTargetingPackDownload = true;
task.TargetFrameworkIdentifier = ".NETCoreApp";
task.TargetFrameworkVersion = "3.0";
task.TargetFrameworkVersion = ToolsetInfo.CurrentTargetFrameworkVersion;
task.TargetPlatformIdentifier = "Windows";
task.TargetPlatformVersion = "10.0.18362";
task.FrameworkReferences = new[]
Expand All @@ -96,7 +97,7 @@ public void Given_targetPlatform_and_targetPlatform_version_It_resolves_Framewor
new MockTaskItem("Microsoft.AspNetCore.App",
new Dictionary<string, string>()
{
{"TargetFramework", "netcoreapp3.0"},
{"TargetFramework", ToolsetInfo.CurrentTargetFramework},
{"RuntimeFrameworkName", "Microsoft.AspNetCore.App"},
{"DefaultRuntimeFrameworkVersion", "1.9.5"},
{"LatestRuntimeFrameworkVersion", "1.9.6"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void NoCompileTimeAssetForSpecificFramework()
{
string[] filePaths = new[]
{
@"ref/netcoreapp3.0/TestPackage.dll",
$@"ref/{ToolsetInfo.CurrentTargetFramework}/TestPackage.dll",
@"lib/netstandard2.0/TestPackage.dll",
@"lib/netcoreapp3.1/TestPackage.dll"
};
Expand All @@ -114,14 +114,14 @@ public void NoRuntimeAssetForSpecificFramework()
{
string[] filePaths = new[]
{
@"ref/netcoreapp3.0/TestPackage.dll",
@"runtimes/win/lib/netcoreapp3.0/TestPackage.dll"
$@"ref/{ToolsetInfo.CurrentTargetFramework}/TestPackage.dll",
$@"runtimes/win/lib/{ToolsetInfo.CurrentTargetFramework}/TestPackage.dll"
};

Package package = new("TestPackage", "1.0.0", filePaths, null, null);
new CompatibleTfmValidator(string.Empty, null, false, false, _log, null).Validate(package);
Assert.NotEmpty(_log.errors);
Assert.Contains(DiagnosticIds.CompatibleRuntimeRidLessAsset + " " + string.Format(Resources.NoCompatibleRuntimeAsset, ".NETCoreApp,Version=v3.0"), _log.errors);
Assert.Contains(DiagnosticIds.CompatibleRuntimeRidLessAsset + " " + string.Format(Resources.NoCompatibleRuntimeAsset, ToolsetInfo.CurrentTargetFramework), _log.errors);
}

[Fact]
Expand All @@ -130,9 +130,9 @@ public void NoRuntimeSpecificAssetForSpecificFramework()
string[] filePaths = new[]
{
@"lib/netstandard2.0/TestPackage.dll",
@"lib/netcoreapp3.0/TestPackage.dll",
@"runtimes/win/lib/netcoreapp3.0/TestPackage.dll",
@"runtimes/unix/lib/netcoreapp3.0/TestPackage.dll"
$@"lib/{ToolsetInfo.CurrentTargetFramework}/TestPackage.dll",
$@"runtimes/win/lib/{ToolsetInfo.CurrentTargetFramework}/TestPackage.dll",
$@"runtimes/unix/lib/{ToolsetInfo.CurrentTargetFramework}/TestPackage.dll"
};

Package package = new("TestPackage", "1.0.0", filePaths, null, null);
Expand Down Expand Up @@ -161,8 +161,8 @@ public void CompatibleRidSpecificAsset()
string[] filePaths = new[]
{
@"lib/netcoreapp2.0/TestPackage.dll",
@"lib/netcoreapp3.0/TestPackage.dll",
@"runtimes/win/lib/netcoreapp3.0/TestPackage.dll"
$@"lib/{ToolsetInfo.CurrentTargetFramework}/TestPackage.dll",
$@"runtimes/win/lib/{ToolsetInfo.CurrentTargetFramework}/TestPackage.dll"
};

Package package = new("TestPackage", "1.0.0", filePaths, null, null);
Expand All @@ -178,7 +178,7 @@ public void CompatibleFrameworksWithDifferentAssets()
@"ref/netstandard2.0/TestPackage.dll",
@"ref/netcoreapp3.1/TestPackage.dll",
@"lib/netstandard2.0/TestPackage.dll",
@"lib/net5.0/TestPackage.dll"
$@"lib/{ToolsetInfo.CurrentTargetFramework}/TestPackage.dll"
};

Package package = new("TestPackage", "1.0.0", filePaths, null, null);
Expand Down
4 changes: 2 additions & 2 deletions src/Tests/Microsoft.NET.Build.Tests/COMReferenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public COMReferenceTests(ITestOutputHelper log) : base(log)
[InlineData(false)]
public void COMReferenceBuildsAndRuns(bool embedInteropTypes)
{
var targetFramework = "netcoreapp3.0";
var targetFramework = ToolsetInfo.CurrentTargetFramework;

var testProject = new TestProject
{
Expand Down Expand Up @@ -71,7 +71,7 @@ static void Main(string[] args)
[FullMSBuildOnlyFact]
public void COMReferenceProperlyPublish()
{
var targetFramework = "netcoreapp3.0";
var targetFramework = ToolsetInfo.CurrentTargetFramework;

var testProject = new TestProject
{
Expand Down
12 changes: 6 additions & 6 deletions src/Tests/Microsoft.NET.Build.Tests/DepsFileSkipTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void RuntimeAssemblyFromPackageCanBeSkipped()
var testProject = new TestProject()
{
Name = "SkipRuntimeAssemblyFromPackage",
TargetFrameworks = "netcoreapp3.0",
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
IsExe = true
};

Expand All @@ -48,7 +48,7 @@ public void RuntimeAssemblyFromRuntimePackCanBeSkipped()
var testProject = new TestProject()
{
Name = "SkipRuntimeAssemblyFromRuntimePack",
TargetFrameworks = "netcoreapp3.0",
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
IsExe = true
};

Expand All @@ -65,7 +65,7 @@ public void NativeAssetFromPackageCanBeSkipped()
var testProject = new TestProject()
{
Name = "SkipNativeAssetFromPackage",
TargetFrameworks = "netcoreapp3.0",
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
IsExe = true
};

Expand All @@ -84,7 +84,7 @@ public void RuntimeTargetFromPackageCanBeSkipped()
var testProject = new TestProject()
{
Name = "SkipNativeAssetFromPackage",
TargetFrameworks = "netcoreapp3.0",
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
IsExe = true
};

Expand All @@ -101,7 +101,7 @@ public void NativeAssetFromRuntimePackCanBeSkipped()
var testProject = new TestProject()
{
Name = "SkipNativeAssetFromRuntimePack",
TargetFrameworks = "netcoreapp3.0",
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
IsExe = true
};

Expand All @@ -118,7 +118,7 @@ public void ResourceAssetFromPackageCanBeSkipped()
var testProject = new TestProject()
{
Name = "SkipResourceFromPackage",
TargetFrameworks = "netcoreapp3.0",
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
IsExe = true
};

Expand Down
Loading