Skip to content

Remove dependency on Nuget.Frameworks#4693

Merged
nohwnd merged 15 commits into
microsoft:mainfrom
nohwnd:remove-nuget.frameworks-try-2
Sep 26, 2023
Merged

Remove dependency on Nuget.Frameworks#4693
nohwnd merged 15 commits into
microsoft:mainfrom
nohwnd:remove-nuget.frameworks-try-2

Conversation

@nohwnd

@nohwnd nohwnd commented Sep 22, 2023

Copy link
Copy Markdown
Member

Remove dependency on Nuget.Frameworks by copying the relevant code into the repository and changing namespace. The Nuget.Frameworks types were not exposed in our public API directly, but we are relying on the functionality, to parse things like net5.0, net472, or any of similar framework shorthands. We also rely on all the frameworks not being explicitly stated, e.g. net11.0 or any such verison of .NET that does not exist yet.

Replace #2544

Fix #3154

The risk here is that someone is relying on us shipping Nuget.Frameworks into the bin, and not providing it themselves.

The newly added public api should not cause issues for the existing loggers because they ship together with vstest.console.

Version = "4.7.1.0",
ShortName = "net471",
},
[".NETFramework,Version=v4.7.2"] = new Framework

@nohwnd nohwnd Sep 22, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

4.8? 4.8.1, 4.8.2?

@nohwnd nohwnd marked this pull request as draft September 22, 2023 13:36
Comment thread eng/verify-nupkgs.ps1
"Microsoft.CodeCoverage" = 59;
"Microsoft.NET.Test.Sdk" = 16;
"Microsoft.TestPlatform" = 607;
"Microsoft.TestPlatform" = 605;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

$path = "S:\p\vstest3\artifacts\packages\Debug\Shipping"; (ls $path -re -fo | where { $_.FullName -notlike "*Symbols*" -and $_.Name -eq "Nuget.Frameworks.dll" }  | % fullName) -replace [regex]::escape($path)

\Microsoft.TestPlatform.17.8.0-dev\tools\net462\Common7\IDE\Extensions\TestPlatform\NuGet.Frameworks.dll
\Microsoft.TestPlatform.17.8.0-dev\tools\net462\Common7\IDE\Extensions\TestPlatform\TestHostNet\NuGet.Frameworks.dll

\Microsoft.TestPlatform.CLI.17.8.0-dev\contentFiles\any\netcoreapp3.1\NuGet.Frameworks.dll
\Microsoft.TestPlatform.CLI.17.8.0-dev\contentFiles\any\netcoreapp3.1\TestHostNetFramework\NuGet.Frameworks.dll

\Microsoft.TestPlatform.Portable.17.8.0-dev\tools\net462\NuGet.Frameworks.dll
\Microsoft.TestPlatform.Portable.17.8.0-dev\tools\netcoreapp3.1\NuGet.Frameworks.dll
\Microsoft.TestPlatform.Portable.17.8.0-dev\tools\netcoreapp3.1\TestHostNetFramework\NuGet.Frameworks.dll

which is count reduction by 2, 2 and 3 just like here.

@nohwnd nohwnd changed the title remove nuget frameworks Remove dependency on Nuget.Frameworks Sep 25, 2023
~static Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources.CommonResources.SourceIncompatible.get -> string
Microsoft.VisualStudio.TestPlatform.ObjectModel.DirectoryBasedTestDiscovererAttribute
Microsoft.VisualStudio.TestPlatform.ObjectModel.DirectoryBasedTestDiscovererAttribute.DirectoryBasedTestDiscovererAttribute() -> void
Microsoft.VisualStudio.TestPlatform.ObjectModel.Framework.FrameworkName.get -> string!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

New public api.


parameters.TryGetValue(DefaultLoggerParameterNames.TargetFramework, out _targetFramework);
_targetFramework = !_targetFramework.IsNullOrEmpty() ? NuGetFramework.Parse(_targetFramework).GetShortFolderName() : _targetFramework;
_targetFramework = Framework.FromString(_targetFramework)?.ShortName ?? _targetFramework;

@nohwnd nohwnd Sep 25, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This returns null when it gets null or whitespace. The original check was unnecessary.

@nohwnd nohwnd marked this pull request as ready for review September 25, 2023 18:37
{
// .NETPortable4.5 for example, is not a valid framework
// and this will throw.
shortName = nugetFramework.GetShortFolderName();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This throws in some cases when the framework is invalid, parsing will return it as Unsupported, but for example if we construct Portable 4.5 and don't specify Profile, it will construct it as supported, but throw when we ask for short name. We use short name as folder for logs, which we figure out when we have a "valid" runtime identifier, so keeping this null should be okay, we check for it in all the places where we use it, and supply the original value.

@nohwnd nohwnd merged commit ec9a138 into microsoft:main Sep 26, 2023
@nohwnd nohwnd deleted the remove-nuget.frameworks-try-2 branch September 26, 2023 07:44
This was referenced Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NuGet.Frameworks dependency is causing weird test failures when trying to load MSBuild

2 participants