Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest Visual Studio 2022 update v17.5.1 breaks docfx #8465

Closed
ghost opened this issue Mar 2, 2023 · 6 comments
Closed

Latest Visual Studio 2022 update v17.5.1 breaks docfx #8465

ghost opened this issue Mar 2, 2023 · 6 comments
Labels
bug A bug to fix dotnet Generate .NET API reference docs

Comments

@ghost
Copy link

ghost commented Mar 2, 2023

Describe the bug
The latest Visual Studio update to v17.5.1 bumps the .NET SDK to version 7.0.201 and this appears to have caused dependency issues when running the docfx docfx_project/docfx.json --serve command.

I recieve the following failures against multiple .csproj files

[Failure] Msbuild failed when processing the file 'C:\SourceCode\Manatee\Version2\Caboodal.Manatee.Logic.Widget\Caboodal.Manatee.Logic.Widget.csproj' with message: C:\Program Files\dotnet\sdk\7.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets: (90, 5): The "ProcessFrameworkReferences" task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly 'NuGet.Frameworks, Version=6.5.0.136, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621)

I subsequently receive lots of build errors for example

C:\SourceCode\Manatee\Version2\Caboodal.Manatee.DataTransferObjects\Authentication\DtoLoginResult.cs(1,7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
C:\SourceCode\Manatee\Version2\Caboodal.Manatee.DataTransferObjects\Authentication\DtoPasswordReset.cs(1,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
C:\SourceCode\Manatee\Version2\Caboodal.Manatee.DataTransferObjects\Authentication\DtoPasswordReset.cs(2,7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
C:\SourceCode\Manatee\Version2\Caboodal.Manatee.DataTransferObjects\Checklists\DtoActivityHistory.cs(1,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
C:\SourceCode\Manatee\Version2\Caboodal.Manatee.DataTransferObjects\Checklists\DtoActivityHistory.cs(2,7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

To Reproduce
Update Visual Studio 2022 to v17.5.1 and run a docfx project that targets .NET6.0 class library project.

Context (please complete the following information):

  • OS: Windows 11 Professional
  • Docfx version: v.2.62.1
@ghost ghost added the bug A bug to fix label Mar 2, 2023
@ghost ghost changed the title Latest Visual Studio 2022 update v15.5.1 breaks docfx Latest Visual Studio 2022 update v17.5.1 breaks docfx Mar 2, 2023
@ghost
Copy link
Author

ghost commented Mar 3, 2023

After spending a couple of days looking at this with the a copy of the repo I have also noticed that the static class DotnetApiCatalog has a constructor that calls...

MSBuildLocator.RegisterDefaults()

This throws the following error:

System.TypeInitializationException: The type initializer for 'Microsoft.DocAsCode.Dotnet.DotnetApiCatalog' threw an exception.
 ---> System.InvalidOperationException: No instances of MSBuild could be detected.
Try calling RegisterInstance or RegisterMSBuildPath to manually register one.
   at Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults()

I thought this odd so I created a .NET Framework 4.8 console app that calls this method and it works however, I created .NET 6.0 console app and I get the same error message as above.

I have subsequently found this issue #197 on the Microsoft.Build.Locator repo.

Whether there is any link I don't know, and why the error message is different I'm also unsure but I thought I would mention it.

@yufeih yufeih added the dotnet Generate .NET API reference docs label Mar 4, 2023
@yufeih
Copy link
Contributor

yufeih commented Mar 4, 2023

What did you get from dotnet --list-sdks command? Microsoft.Build.Locator in a .NET Core app requires .NET Core SDK installed on the system.

@ghost
Copy link
Author

ghost commented Mar 4, 2023

λ dotnet --list-sdks
7.0.201 [C:\Program Files\dotnet\sdk]

@ghost
Copy link
Author

ghost commented Mar 4, 2023

My colleague had his development environment still configured to SDK 7.0.103 and his worked we then upgraded his dev environment to SDK 7.0.201 and his also failed with the same error.

@mawosoft
Copy link

mawosoft commented Mar 4, 2023

The problem most likely is that the docfx package already comes with NuGet.*/6.4.0 assemblies included. That version matches the NuGet.* assemblies included in the dotnet SDK prior to 7.0.200. From there on, the SDK uses NuGet.*/6.5.0, which the msbuild tasks then cannot load into the docfx process.

At least that would be my guess.

@ghost
Copy link
Author

ghost commented Mar 7, 2023

Thank you @yufeih everything is now working!

@ghost ghost closed this as completed Mar 7, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug to fix dotnet Generate .NET API reference docs
Projects
None yet
Development

No branches or pull requests

2 participants