diff --git a/scripts/build/TestPlatform.Dependencies.props b/scripts/build/TestPlatform.Dependencies.props index 04a239235d..c9d3ebcd31 100644 --- a/scripts/build/TestPlatform.Dependencies.props +++ b/scripts/build/TestPlatform.Dependencies.props @@ -21,6 +21,7 @@ 4.3.7 1.1.1 + 5.0.0 9.0.1 4.7.63 16.0.0-preview-2148743 diff --git a/scripts/verify-nupkgs.ps1 b/scripts/verify-nupkgs.ps1 index 84ed4d6a4e..eb20f2ed9f 100644 --- a/scripts/verify-nupkgs.ps1 +++ b/scripts/verify-nupkgs.ps1 @@ -14,12 +14,12 @@ function Verify-Nuget-Packages($packageDirectory) Write-Log "Starting Verify-Nuget-Packages." $expectedNumOfFiles = @{"Microsoft.CodeCoverage" = 29; "Microsoft.NET.Test.Sdk" = 13; - "Microsoft.TestPlatform" = 422; + "Microsoft.TestPlatform" = 423; "Microsoft.TestPlatform.Build" = 19; - "Microsoft.TestPlatform.CLI" = 301; + "Microsoft.TestPlatform.CLI" = 303; "Microsoft.TestPlatform.Extensions.TrxLogger" = 33; "Microsoft.TestPlatform.ObjectModel" = 62; - "Microsoft.TestPlatform.Portable" = 471; + "Microsoft.TestPlatform.Portable" = 474; "Microsoft.TestPlatform.TestHost" = 140; "Microsoft.TestPlatform.TranslationLayer" = 121} diff --git a/src/Microsoft.TestPlatform.ObjectModel/Constants.cs b/src/Microsoft.TestPlatform.ObjectModel/Constants.cs index edb2d4d7c3..8bd3ee6a0d 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Constants.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Constants.cs @@ -203,7 +203,7 @@ public static class Constants public const string DotNetFrameworkCore10 = ".NETCoreApp,Version=v1.0"; - public const string DotNetFrameworkUap10 = "Uap,Version=v10.0"; + public const string DotNetFrameworkUap10 = "UAP,Version=v10.0"; public const string TargetFrameworkName = "TargetFrameworkName"; } diff --git a/src/Microsoft.TestPlatform.ObjectModel/Framework.cs b/src/Microsoft.TestPlatform.ObjectModel/Framework.cs index 9302aad51a..a84d074e58 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Framework.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Framework.cs @@ -3,8 +3,8 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel { - using System; - using System.Runtime.Versioning; + using NuGet.Frameworks; + using static NuGet.Frameworks.FrameworkConstants; /// /// Class for target Framework for the test container @@ -48,7 +48,7 @@ public static Framework FromString(string frameworkString) return null; } - FrameworkName frameworkName; + NuGetFramework nugetFramework; try { // IDE always sends framework in form of ENUM, which always throws exception @@ -56,23 +56,24 @@ public static Framework FromString(string frameworkString) switch (frameworkString.Trim().ToLower()) { case "framework35": - frameworkName = new FrameworkName(Constants.DotNetFramework35); + nugetFramework = CommonFrameworks.Net35; break; case "framework40": - frameworkName = new FrameworkName(Constants.DotNetFramework40); + nugetFramework = CommonFrameworks.Net4; break; case "framework45": - frameworkName = new FrameworkName(Constants.DotNetFramework45); + nugetFramework = CommonFrameworks.Net45; break; case "frameworkcore10": - frameworkName = new FrameworkName(Constants.DotNetFrameworkCore10); + nugetFramework = CommonFrameworks.NetCoreApp10; break; case "frameworkuap10": - frameworkName = new FrameworkName(Constants.DotNetFrameworkUap10); + nugetFramework = CommonFrameworks.UAP10; break; default: - // FrameworkName already trims the input identifier. - frameworkName = new FrameworkName(frameworkString); + nugetFramework = NuGetFramework.Parse(frameworkString); + if (nugetFramework.IsUnsupported) + return null; break; } } @@ -81,7 +82,7 @@ public static Framework FromString(string frameworkString) return null; } - return new Framework() { Name = frameworkName.FullName, Version = frameworkName.Version.ToString() }; + return new Framework() { Name = nugetFramework.DotNetFrameworkName, Version = nugetFramework.Version.ToString() }; } /// diff --git a/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj b/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj index 053efa75da..cd06e0ee08 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj +++ b/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj @@ -31,6 +31,7 @@ + 1.6.0 diff --git a/src/package/nuspec/Microsoft.TestPlatform.Portable.nuspec b/src/package/nuspec/Microsoft.TestPlatform.Portable.nuspec index 81d63e9f40..5c56f5415d 100644 --- a/src/package/nuspec/Microsoft.TestPlatform.Portable.nuspec +++ b/src/package/nuspec/Microsoft.TestPlatform.Portable.nuspec @@ -44,6 +44,8 @@ + + @@ -243,6 +245,8 @@ + + @@ -365,6 +369,7 @@ + @@ -488,6 +493,5 @@ - diff --git a/src/package/nuspec/Microsoft.TestPlatform.nuspec b/src/package/nuspec/Microsoft.TestPlatform.nuspec index de164d2d71..ba9eb38a9d 100644 --- a/src/package/nuspec/Microsoft.TestPlatform.nuspec +++ b/src/package/nuspec/Microsoft.TestPlatform.nuspec @@ -96,6 +96,7 @@ + diff --git a/src/package/nuspec/TestPlatform.ObjectModel.nuspec b/src/package/nuspec/TestPlatform.ObjectModel.nuspec index 38fd784a6d..342628c057 100644 --- a/src/package/nuspec/TestPlatform.ObjectModel.nuspec +++ b/src/package/nuspec/TestPlatform.ObjectModel.nuspec @@ -17,6 +17,10 @@ + + + + diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs index 2fa5b9823e..3a1622c7b0 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs @@ -23,6 +23,20 @@ public void FrameworkArgumentShouldWork(RunnerInfo runnerInfo) this.ValidateSummaryStatus(1, 1, 1); } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void FrameworkShortNameArgumentShouldWork(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + + var arguments = PrepareArguments(GetSampleTestAssembly(), string.Empty, string.Empty, this.testEnvironment.TargetFramework); + arguments = string.Concat(arguments, " ", $"/Framework:{this.testEnvironment.TargetFramework}"); + + this.InvokeVsTest(arguments); + this.ValidateSummaryStatus(1, 1, 1); + } + [TestMethod] [NetFullTargetFrameworkDataSource] [NetCoreTargetFrameworkDataSource] diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/FrameworkTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/FrameworkTests.cs index 0c4aaad5b0..e6db242f84 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/FrameworkTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/FrameworkTests.cs @@ -45,7 +45,7 @@ public void FrameworkFromStringShouldIgnoreCase() Assert.AreEqual(".NETCoreApp,Version=v1.0", fx.Name); fx = Framework.FromString("frameworkUAP10"); - Assert.AreEqual("Uap,Version=v10.0", fx.Name); + Assert.AreEqual("UAP,Version=v10.0", fx.Name); } [TestMethod] @@ -54,7 +54,19 @@ public void FrameworkFromStringShouldTrimSpacesAroundFrameworkString() var fx = Framework.FromString(" Framework35"); Assert.AreEqual(".NETFramework,Version=v3.5", fx.Name); - Assert.AreEqual("3.5", fx.Version); + Assert.AreEqual("3.5.0.0", fx.Version); + } + + [TestMethod] + public void FrameworkFromStringShouldWorkForShortNames() + { + var fx = Framework.FromString("net451"); + Assert.AreEqual(".NETFramework,Version=v4.5.1", fx.Name); + Assert.AreEqual("4.5.1.0", fx.Version); + + var corefx = Framework.FromString("netcoreapp2.0"); + Assert.AreEqual(".NETCoreApp,Version=v2.0", corefx.Name); + Assert.AreEqual("2.0.0.0", corefx.Version); } [TestMethod] diff --git a/test/vstest.console.UnitTests/Processors/FrameworkArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/FrameworkArgumentProcessorTests.cs index 3be575cb2d..445eaa7e23 100644 --- a/test/vstest.console.UnitTests/Processors/FrameworkArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/FrameworkArgumentProcessorTests.cs @@ -111,8 +111,8 @@ public void InitializeShouldSetCommandLineOptionsFrameworkForOlderFrameworks() public void InitializeShouldSetCommandLineOptionsFrameworkForCaseInsensitiveFramework() { this.executor.Initialize(".netcoreApp,Version=v1.0"); - Assert.AreEqual(".netcoreApp,Version=v1.0", CommandLineOptions.Instance.TargetFrameworkVersion.Name); - Assert.AreEqual(".netcoreApp,Version=v1.0", this.runSettingsProvider.QueryRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath)); + Assert.AreEqual(".NETCoreApp,Version=v1.0", CommandLineOptions.Instance.TargetFrameworkVersion.Name); + Assert.AreEqual(".NETCoreApp,Version=v1.0", this.runSettingsProvider.QueryRunSettingsNode(FrameworkArgumentExecutor.RunSettingsPath)); } [TestMethod]