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

[VCPKG] Visual Studio Preview 5 v17.12 caused SDK Resolver Failure on Microsoft.Build.Vcpkg #44664

Closed
RobsonPontin opened this issue Nov 5, 2024 · 3 comments
Labels
Area-SdkResolvers untriaged Request triage from a team member

Comments

@RobsonPontin
Copy link

Describe the bug

Updating from Visual Studio Preview 3 to Preview 5 caused the VCPKG targets to no longer load C++ projects due to the following error:

D:\repos\MyRepo\src\MyLib\MyLib.vcxproj : error  : SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildSdkResolver" failed while attempting to resolve the SDK "Microsoft.Build.Vcpkg". Exception: "System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at Microsoft.NET.Sdk.WorkloadManifestReader.SdkDirectoryWorkloadManifestProvider.GlobalJsonReader.GetWorkloadVersionFromGlobalJson(String globalJsonPath)
   at Microsoft.NET.Sdk.WorkloadManifestReader.SdkDirectoryWorkloadManifestProvider.RefreshWorkloadManifests()
   at Microsoft.NET.Sdk.WorkloadManifestReader.SdkDirectoryWorkloadManifestProvider..ctor(String sdkRootPath, String sdkVersion, Func`2 getEnvironmentVariable, String userProfileDir, String globalJsonPath, String workloadSetVersion)
   at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, String dotnetRootPath, String sdkVersion, String userProfileDir, String globalJsonPath)
   at Microsoft.DotNet.MSBuildSdkResolver.DotNetMSBuildSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext context, SdkResultFactory factory)
   at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.TryResolveSdkUsingSpecifiedResolvers(IReadOnlyList`1 resolvers, Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio, SdkResult& sdkResult, IEnumerable`1& errors, IEnumerable`1& warnings)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
""  D:\repos\MyRepo\Directory.Build.targets

The issues is related to the file Directory.Build.Targets which has the SDK entry for Microsoft.Build.Vcpkg:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Sdk Name="Microsoft.Build.Vcpkg" />
</Project>

This works fine with latest VS 2022 17.11.5 and I did test it with VS 2022 Preview 3.

Also note that the project I'm working on is a WinUI 3 apps.

To Reproduce

Having C++ projects on a WinUI 3 solution, add Directory.Build.Targets file with the SDK entry for Microsoft.Build.Vcpkg.

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Sdk Name="Microsoft.Build.Vcpkg" />
</Project>

Exceptions (if any)

error  : SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildSdkResolver" failed while attempting to resolve the SDK "Microsoft.Build.Vcpkg". Exception: "System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

Further technical details

  • dotnet --info
.NET SDK:
 Version:           9.0.100-rc.2.24474.11
 Commit:            315e1305db
 Workload version:  9.0.100-manifests.3424025a
 MSBuild version:   17.12.0-preview-24473-03+fea15fbd1
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-SdkResolvers untriaged Request triage from a team member labels Nov 5, 2024
@kilasuelika
Copy link

kilasuelika commented Nov 7, 2024

I have the same error with you. But the scenery is a little different. First, create a CLR project A. Then add a C# project. Close VS and open the sln again. The project A shows unloaded. The error in output windows shows:

G:\Sync\C++\ClassLibrary1\ClassLibrary1\ClassLibrary1.vcxproj : error  : SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.Sdk". Exception: "System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

@marcpopMSFT
Copy link
Member

I believe this should be fixed in 17.12.0 which released today. Please try that and report back if it's not resolved.

@RobsonPontin
Copy link
Author

Just tried VS v17.12 and no longer see the issue.
all good, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-SdkResolvers untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

3 participants