From 0a19218b660d592013a1d75479f013d69a6c5d71 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Thu, 16 Nov 2023 17:52:27 +0900 Subject: [PATCH] chore: Remove `NuGet.Frameworks` dependency from test projects (#9276) * chore: fix NuGet.Frameworks package version * chore: remove NuGet.Frameworks dependency from test projects * chore: update test sdk version * chore: remove NuGet.config file that is used for NuGet.Frameworks --------- Co-authored-by: Yufei Huang --- Directory.Packages.props | 4 +-- NuGet.config | 8 ----- test/Directory.Build.props | 10 ------- test/docfx.Tests/ModuleInitializer.cs | 42 --------------------------- 4 files changed, 1 insertion(+), 63 deletions(-) delete mode 100644 NuGet.config delete mode 100644 test/docfx.Tests/ModuleInitializer.cs diff --git a/Directory.Packages.props b/Directory.Packages.props index a2a71809904..818d23673c1 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -39,9 +39,7 @@ - - - + diff --git a/NuGet.config b/NuGet.config deleted file mode 100644 index a7cb980c956..00000000000 --- a/NuGet.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 06004b8784f..6c34d66e011 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -17,16 +17,6 @@ - - diff --git a/test/docfx.Tests/ModuleInitializer.cs b/test/docfx.Tests/ModuleInitializer.cs deleted file mode 100644 index 08756a200e2..00000000000 --- a/test/docfx.Tests/ModuleInitializer.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.CompilerServices; -using Microsoft.Build.Locator; - -namespace Docfx.Tests; - -public static class ModuleInitializer -{ - [ModuleInitializer] - public static void Initialize() - { - // Workaround code to avoid `NuGet.Frameworks` package related errror. - RegisterNonPreviewSdkInstance(); - } - - /// - /// Try to register non-preview version .NET SDK to avoid `NuGet.Frameworks` package related problems. - /// - private static void RegisterNonPreviewSdkInstance() - { - if (MSBuildLocator.IsRegistered) - { - // `DotnetApiCatalog.Exec` is called before ModuleInitializer execution. - MSBuildLocator.Unregister(); - Console.WriteLine($"Execute: MSBuildLocator.Unregister()"); - } - - // Gets non-preview .NET SDKs. - var vsInstances = MSBuildLocator.QueryVisualStudioInstances(VisualStudioInstanceQueryOptions.Default) - .Where(x => !x.MSBuildPath.Contains("-preview.")) - .Where(x => !x.MSBuildPath.Contains("-rc.")); - - var vs = vsInstances.FirstOrDefault(); - if (vs == null) - return; - - MSBuildLocator.RegisterInstance(vs); - Console.WriteLine($"Using {vs.Name} {vs.Version}"); - } -}