Skip to content
Closed
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
1 change: 0 additions & 1 deletion scripts/build/TestPlatform.Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<ChutzpahAdapterVersion>4.3.7</ChutzpahAdapterVersion>
<FileSystemGlobbingVersion>1.1.1</FileSystemGlobbingVersion>

<NuGetFrameworksVersion>5.0.0</NuGetFrameworksVersion>
<JsonNetVersion>9.0.1</JsonNetVersion>
<MoqVersion>4.7.63</MoqVersion>
<TestPlatformExternalsVersion>16.8.0-preview-3968212</TestPlatformExternalsVersion>
Expand Down
148 changes: 148 additions & 0 deletions scripts/generate/update-supported-nuget.frameworks-versions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<# Helps updating framework name translation in Framework class by taking values from Nuget.Frameworks package
and generating all common frameworks into the types that vstest console uses. This removes the dependency on Nuget.Frameworks
from which we consume miniscule part and which causes us a lot of trouble because the VS version and local version differ
#>

# download a version from nuget and unpack

$dll = Get-Item "~/Downloads/nuget.frameworks.*\lib\net472\NuGet.Frameworks.dll"

Import-Module ($dll.FullName)

$commonFrameworks = [NuGet.Frameworks.FrameworkConstants+CommonFrameworks].GetFields().Name

# thie generates mapping from the full name to the one that we use internally
@"
// Generated from Nuget.Frameworks $((Get-Module NuGet.Frameworks ).Version) nuget package,
// you can update it by scripts/generate/update-supported-nuget.frameworks-versions.ps1
static Dictionary<string, Framework> mapping = new Dictionary<string, Framework> {
$(foreach ($commonFramework in $commonFrameworks) {

$fmw = [NuGet.Frameworks.FrameworkConstants+CommonFrameworks]::$commonFramework
"[""$($fmw.DotNetFrameworkName)""] = new Framework {
Name = ""$($fmw.DotNetFrameworkName)"",
FrameworkName = ""$($fmw.Framework)"",
Version = ""$($fmw.Version)"",
ShortName = ""$($fmw.GetShortFolderName())"",
},`n"

})
};
"@

# this will help you taking the method TryParseCommonFramework from the main branch and updating it to have the uncommon name mappings
# but not use the frameworkconstants
# Take TryParseCommonFramework from https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Frameworks/NuGetFrameworkFactory.cs#L586
# and put it below, in betwwen the @' '@ to get a version that does not need any built in types
@'
private static bool TryParseCommonFramework(string frameworkString, out NuGetFramework framework)
{
framework = null;

frameworkString = frameworkString.ToLowerInvariant();

switch (frameworkString)
{
case "dotnet":
case "dotnet50":
case "dotnet5.0":
framework = FrameworkConstants.CommonFrameworks.DotNet50;
break;
case "net40":
case "net4":
framework = FrameworkConstants.CommonFrameworks.Net4;
break;
case "net45":
framework = FrameworkConstants.CommonFrameworks.Net45;
break;
case "net451":
framework = FrameworkConstants.CommonFrameworks.Net451;
break;
case "net46":
framework = FrameworkConstants.CommonFrameworks.Net46;
break;
case "net461":
framework = FrameworkConstants.CommonFrameworks.Net461;
break;
case "net462":
framework = FrameworkConstants.CommonFrameworks.Net462;
break;
case "win8":
framework = FrameworkConstants.CommonFrameworks.Win8;
break;
case "win81":
framework = FrameworkConstants.CommonFrameworks.Win81;
break;
case "netstandard":
framework = FrameworkConstants.CommonFrameworks.NetStandard;
break;
case "netstandard1.0":
case "netstandard10":
framework = FrameworkConstants.CommonFrameworks.NetStandard10;
break;
case "netstandard1.1":
case "netstandard11":
framework = FrameworkConstants.CommonFrameworks.NetStandard11;
break;
case "netstandard1.2":
case "netstandard12":
framework = FrameworkConstants.CommonFrameworks.NetStandard12;
break;
case "netstandard1.3":
case "netstandard13":
framework = FrameworkConstants.CommonFrameworks.NetStandard13;
break;
case "netstandard1.4":
case "netstandard14":
framework = FrameworkConstants.CommonFrameworks.NetStandard14;
break;
case "netstandard1.5":
case "netstandard15":
framework = FrameworkConstants.CommonFrameworks.NetStandard15;
break;
case "netstandard1.6":
case "netstandard16":
framework = FrameworkConstants.CommonFrameworks.NetStandard16;
break;
case "netstandard1.7":
case "netstandard17":
framework = FrameworkConstants.CommonFrameworks.NetStandard17;
break;
case "netstandard2.0":
case "netstandard20":
framework = FrameworkConstants.CommonFrameworks.NetStandard20;
break;
case "netstandard2.1":
case "netstandard21":
framework = FrameworkConstants.CommonFrameworks.NetStandard21;
break;
case "netcoreapp2.1":
case "netcoreapp21":
framework = FrameworkConstants.CommonFrameworks.NetCoreApp21;
break;
case "netcoreapp3.1":
case "netcoreapp31":
framework = FrameworkConstants.CommonFrameworks.NetCoreApp31;
break;
case "netcoreapp5.0":
case "netcoreapp50":
case "net5.0":
case "net50":
framework = FrameworkConstants.CommonFrameworks.Net50;
break;
}

return framework != null;
}

'@ -split "`n" | foreach {
$pattern = "FrameworkConstants.CommonFrameworks.(?<framework>.*);"
if ($_ -match $pattern) {
$name = $matches.framework
$fullName = ([Nuget.Frameworks.FrameworkConstants+CommonFrameworks]::$name).DotNetFrameworkName
$_ -replace $pattern, """$fullName"";"
}
else {
$_ -replace "out NuGetFramework framework", "out string framework"
}
}
6 changes: 3 additions & 3 deletions scripts/verify-nupkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ function Verify-Nuget-Packages($packageDirectory)
$expectedNumOfFiles = @{
"Microsoft.CodeCoverage" = 29;
"Microsoft.NET.Test.Sdk" = 13;
"Microsoft.TestPlatform" = 477;
"Microsoft.TestPlatform" = 476;
"Microsoft.TestPlatform.Build" = 19;
"Microsoft.TestPlatform.CLI" = 350;
"Microsoft.TestPlatform.CLI" = 348;
"Microsoft.TestPlatform.Extensions.TrxLogger" = 33;
"Microsoft.TestPlatform.ObjectModel" = 62;
"Microsoft.TestPlatform.Portable" = 566;
"Microsoft.TestPlatform.Portable" = 563;
"Microsoft.TestPlatform.TestHost" = 145;
"Microsoft.TestPlatform.TranslationLayer" = 121}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace Microsoft.TestPlatform.Extensions.BlameDataCollector
using System;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using NuGet.Frameworks;

internal class CrashDumperFactory : ICrashDumperFactory
{
Expand All @@ -19,15 +18,15 @@ public ICrashDumper Create(string targetFramework)

EqtTrace.Info($"CrashDumperFactory: Creating dumper for {RuntimeInformation.OSDescription} with target framework {targetFramework}.");

var tfm = NuGetFramework.Parse(targetFramework);
var tfm = Framework.FromString(targetFramework);

if (tfm == null || tfm.IsUnsupported)
if (tfm == null)
{
EqtTrace.Error($"CrashDumperFactory: Could not parse target framework {targetFramework}, to a supported framework version.");
throw new NotSupportedException($"Could not parse target framework {targetFramework}, to a supported framework version.");
}

var isNet50OrNewer = tfm.Framework == ".NETCoreApp" && tfm.Version >= Version.Parse("5.0.0.0");
var isNet50OrNewer = tfm.FrameworkName == ".NETCoreApp" && Version.Parse(tfm.Version) >= Version.Parse("5.0.0.0");

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace Microsoft.TestPlatform.Extensions.BlameDataCollector
using System;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using NuGet.Frameworks;

internal class HangDumperFactory : IHangDumperFactory
{
Expand All @@ -21,9 +20,9 @@ public IHangDumper Create(string targetFramework)

EqtTrace.Info($"HangDumperFactory: Creating dumper for {RuntimeInformation.OSDescription} with target framework {targetFramework}.");

var tfm = NuGetFramework.Parse(targetFramework);
var tfm = Framework.FromString(targetFramework);

if (tfm == null || tfm.IsUnsupported)
if (tfm == null)
{
EqtTrace.Error($"HangDumperFactory: Could not parse target framework {targetFramework}, to a supported framework version.");
throw new NotSupportedException($"Could not parse target framework {targetFramework}, to a supported framework version.");
Expand All @@ -37,7 +36,7 @@ public IHangDumper Create(string targetFramework)

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
var isLessThan31 = tfm.Framework == ".NETCoreApp" && tfm.Version < Version.Parse("3.1.0.0");
var isLessThan31 = tfm.FrameworkName == ".NETCoreApp" && Version.Parse(tfm.Version) < Version.Parse("3.1.0.0");
if (isLessThan31)
{
EqtTrace.Info($"HangDumperFactory: This is Linux on netcoreapp2.1, returning SigtrapDumper.");
Expand All @@ -51,7 +50,7 @@ public IHangDumper Create(string targetFramework)

if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
var isLessThan50 = tfm.Framework == ".NETCoreApp" && tfm.Version < Version.Parse("5.0.0.0");
var isLessThan50 = tfm.FrameworkName == ".NETCoreApp" && Version.Parse(tfm.Version) < Version.Parse("5.0.0.0");
if (isLessThan50)
{
EqtTrace.Info($"HangDumperFactory: This is OSX on {targetFramework}, This combination of OS and framework is not supported.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger

using HtmlResource = Resources.Resources;
using HtmlLoggerConstants = Constants;
using NuGet.Frameworks;

/// <summary>
/// Logger for generating Html.
Expand Down Expand Up @@ -291,7 +290,7 @@ public void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e)
var framework = this.parametersDictionary[DefaultLoggerParameterNames.TargetFramework];
if (framework != null)
{
framework = NuGetFramework.Parse(framework).GetShortFolderName();
framework = Framework.GetShortFolderName(framework);
logFilePrefixValue = logFilePrefixValue + "_" + framework;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.TestPlatform.Extensions.TrxLogger/TrxLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
using Microsoft.VisualStudio.TestPlatform.Utilities;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;
using NuGet.Frameworks;
using ObjectModel.Logging;
using System;
using System.Collections.Concurrent;
Expand Down Expand Up @@ -509,7 +508,7 @@ private string AcquireTrxFileNamePath(out bool shouldOverwrite)
{
if (parametersDictionary.TryGetValue(DefaultLoggerParameterNames.TargetFramework, out var framework) && framework != null)
{
framework = NuGetFramework.Parse(framework).GetShortFolderName();
framework = Framework.GetShortFolderName(framework);
logFilePrefixValue = logFilePrefixValue + "_" + framework;
}

Expand Down
Loading