Skip to content

make the workload resolver only light up for the specific entrypoint SDKs we control #41268

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

baronfel
Copy link
Member

@baronfel baronfel commented May 30, 2024

This is part of #26009

This makes NuGet/Home#13471 easier to diagnose because it removes the workload resolver from the list of resolvers - you can see the before and after here:

before:

D:\temp\test01\test01.csproj : error : Could not resolve SDK "MSTest.Sdk". Exactly one of the probing messages below indicates why we could not resolve the SDK. Investigate and resolve that message to correctly specify the SDK.
D:\temp\test01\test01.csproj : error :   SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" returned null.
D:\temp\test01\test01.csproj : error :   Unable to resolve 'MSTest.Sdk (= 3.3.1)' for '.NETStandard,Version=v0.0'. PackageSourceMapping is enabled, the following source(s) were not considered: Microsoft Visual Studio Offline Packages, NuGet official package source.
D:\temp\test01\test01.csproj : error MSB4236: The SDK 'MSTest.Sdk' specified could not be found.

after:

E:\Code\Scratch\test-app\test-app.csproj : error : Could not resolve SDK "MSTest.Sdk". Exactly one of the probing messages below indicates why we could not resolve the SDK. Investigate and resolve that message to correctly specify the SDK.
E:\Code\Scratch\test-app\test-app.csproj : error :   Unable to resolve 'MSTest.Sdk (= 3.3.1)' for '.NETStandard,Version=v0.0'. PackageSourceMapping is enabled, the following source(s) were not considered: nuget.
E:\Code\Scratch\test-app\test-app.csproj : error MSB4236: The SDK 'MSTest.Sdk/3.3.1' specified could not be found.

We save one line here, and with additional work on the MSBuild side we may be able to reduce the MSBuild resolver wrapper noise in this message.

@baronfel baronfel force-pushed the ResolvableSdkPattern-for-workloadresolver branch from afed12e to aeb2680 Compare March 7, 2025 00:13
<_VSMSBuildExtensionsContentDestinations Include="@(VSMSBuildExtensionsContent->'%(DestinationPath)')" />
</ItemGroup>

<Copy SourceFiles="@(VSMSBuildExtensionsContent)" DestinationFiles="@(_VSMSBuildExtensionsContentDestinations)" />
Copy link
Member Author

Choose a reason for hiding this comment

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

This reduces the number of Copy task calls from num_content_files to 1.

@baronfel
Copy link
Member Author

baronfel commented Mar 7, 2025

Here's the content from the generated SWR after this change:

folder "InstallDir:\MSBuild\Current\Bin\SdkResolvers\Microsoft.DotNet.MSBuildSdkResolver\"
  file source="$(PkgVS_Redist_Common_Net_Core_SDK_MSBuildExtensions)\MSBuildSdkResolver\Microsoft.Deployment.DotNet.Releases.dll" vs.file.ngenApplications="[installDir]\Common7\IDE\vsn.exe"
  file source="$(PkgVS_Redist_Common_Net_Core_SDK_MSBuildExtensions)\MSBuildSdkResolver\Microsoft.DotNet.MSBuildSdkResolver.dll" vs.file.ngenApplications="[installDir]\Common7\IDE\vsn.exe"
  file source="$(PkgVS_Redist_Common_Net_Core_SDK_MSBuildExtensions)\MSBuildSdkResolver\Microsoft.DotNet.MSBuildSdkResolver.xml"

and the relevant nuget package layout:
image

The layout matches the expected file paths for both the dll and the xml, so the resolver xml config should be consumed by MSBuild.exe/VS when injected. The next step would be to somehow inject this into a VS instance to test.

@rainersigwald
Copy link
Member

The next step would be to somehow inject this into a VS instance to test.

Worst-case is "unzip the .vsix and copy-with-overwrite the content folder over the VS install root, I think.

@joeloff
Copy link
Member

joeloff commented Mar 7, 2025

Compared to the previous .swr, are we running NGEN on anything new? Just asking in case it sets off a DDRIT tripwire.

@joeloff
Copy link
Member

joeloff commented Mar 7, 2025

The next step would be to somehow inject this into a VS instance to test.

Worst-case is "unzip the .vsix and copy-with-overwrite the content folder over the VS install root, I think.

That's easy to do and if we don't test with a proper insertion, we may miss some of the NGEN actions and perf impacts. I can help Chet to do this.

@baronfel
Copy link
Member Author

baronfel commented Mar 7, 2025

notes:

  • probably need to change the content of the

Compared to the previous .swr, are we running NGEN on anything new? Just asking in case it sets off a DDRIT tripwire.

no - the net change here should just be a XML file in the VS insertion next to an already-existing dll. That xml file is read by MSBuild itself, after assembly loading has occurred.

@baronfel baronfel marked this pull request as ready for review March 7, 2025 22:06
@baronfel
Copy link
Member Author

baronfel commented Mar 7, 2025

Ok, this is looking good in my local testing (laying the xml file down in a VS install root and then using MSbuild.exe):

❯ msbuild.exe /restore /bl /tl
E:\code\scratch\resolver-test\resolver-test.csproj : error :
  Could not resolve SDK "MSTest.Sdk". Exactly one of the probing messages below indicates why we could not resolve the SDK. Investigate and resolve that message to correctly specify the S
  DK.
    The NuGetSdkResolver did not resolve this SDK because there was no version specified in the project or global.json.
    MSB4276: The default SDK resolver failed to resolve SDK "MSTest.Sdk" because directory "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Sdks\MSTest.Sdk\Sdk" did not ex
  ist.
    E:\code\scratch\resolver-test\resolver-test.csproj : error MSB4236: The SDK 'MSTest.Sdk' specified could not be found.

Restore failed with 2 error(s) in 0.3s

Things to follow up on:

  • MSBuild's Default SDK Resolver is coming into play here, is there a way to make it not? The .NET SDK resolver does the same thing here? cc @rainersigwald
  • MSBuild could make an enhancement to its' overall SDK resolution error reporting to remove this wrapper line if there was only 1 SDK resolver error reported.
  • @joeloff happy to work with you async to try an actual VS test run

@rainersigwald
Copy link
Member

  • MSBuild's Default SDK Resolver is coming into play here, is there a way to make it not?

I don't think so today.

@nagilson
Copy link
Member

Should we be merging this @baronfel?

@baronfel
Copy link
Member Author

It would be great to work on this, but we need to schedule some time with @joeloff to do a full-VS run to make sure I didn't break anything. Would be great to partner with an SDK engineer to help push this forward - SDK resolver perf and error message cleanups are a pain point for users.

@joeloff
Copy link
Member

joeloff commented Apr 15, 2025

It would be great to work on this, but we need to schedule some time with @joeloff to do a full-VS run to make sure I didn't break anything. Would be great to partner with an SDK engineer to help push this forward - SDK resolver perf and error message cleanups are a pain point for users.

You mean an insertion to trigger the tests VS runs? You'll need to stage in insertion, or that the very least push your branch to internal, then manually upload the packages to the feed. The latter part may not be possible any longer.

</ItemGroup>

<Copy SourceFiles="@(VSMSBuildExtensionsContent)" DestinationFiles="%(VSMSBuildExtensionsContent.DestinationPath)" />
<Copy SourceFiles="@(VSMSBuildExtensionsContent)" DestinationFiles="@(VSMSBuildExtensionsContent->'%(DestinationPath)')" />
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

This coalesces the N Copy Task calls into a single call - this is way faster and the task internally handles up to date checking and such.

So many people unintentionally batch over this Task, we should probably have a build check for it!

Copy link
Member

Choose a reason for hiding this comment

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

Hmm...batching was my first thought, but I thought it would batch in either case. Batching is confusing.

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

Successfully merging this pull request may close these issues.

6 participants