sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Add optional logging to MSBuild SDK Resolver

Open dsplaisted opened this issue 1 year ago • 1 comments

dsplaisted avatar Jul 31 '22 20:07 dsplaisted

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@jeffkl Could you look at this again. I've switched it so that it logs to the SdkLogger, but only for resolution failures. It uses FormattableString now so it shouldn't be formatting the log strings unless they are actually going to be emitted.

dsplaisted avatar Oct 25 '22 18:10 dsplaisted

This is a huge improvement. Will these be on by default? How will this look in a binlog or a text log?

KirillOsenkov avatar Oct 31 '22 19:10 KirillOsenkov

Is my analysis correct that the SdkLogger was not used for anything prior to this change? https://github.com/dotnet/msbuild/issues/7988#issuecomment-1251782434

KirillOsenkov avatar Oct 31 '22 19:10 KirillOsenkov

This is a huge improvement. Will these be on by default? How will this look in a binlog or a text log?

The current version of this PR will log the messages by default any time there is a resolver failure. When I tested it out, the logs showed up in the console output and in the binlog. I'm not sure if anything else previously used the SdkLogger.

dsplaisted avatar Oct 31 '22 21:10 dsplaisted

/azp run

dsplaisted avatar Nov 08 '22 19:11 dsplaisted

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Nov 08 '22 19:11 azure-pipelines[bot]

@dotnet/msbuild Is it expected that SdkResolverContext.Logger would be null on Mac and Linux? That seems to be the case based on some of the test failures.

EDIT: Never mind, it was actually an issue with how the mocks were set up.

dsplaisted avatar Nov 17 '22 21:11 dsplaisted

@dsplaisted I have some comments waiting for a reply.

jeffkl avatar Nov 30 '22 22:11 jeffkl

@jeffkl Sorry, I missed those comments, I think I thought they applied to a previous version of the code and were now outdated.

dsplaisted avatar Dec 01 '22 17:12 dsplaisted

The description of this PR still mentions "logs to the temporary directory", which is not what the implementation does.

In https://github.com/NuGet/Home/issues/10669#issuecomment-804619192, I suggested logging the referenced MSBuild project SDKs to a file, which a separate tool could then read in order to check the licenses of these dependencies. If I understand correctly, this PR does not fulfil that request, in two respects:

  • it doesn't log the SDKs if resolution succeeds
  • MSBuild project SDKs from NuGet packages are resolved by NuGetSdkResolver; not by DotNetMSBuildSdkResolver, which this PR modifies

KalleOlaviNiemitalo avatar Apr 15 '23 05:04 KalleOlaviNiemitalo

@KalleOlaviNiemitalo I've updated the description to match what the PR now does.

It's true this PR doesn't really help with your scenario of auditing which NuGet project SDKs are used.

dsplaisted avatar Apr 17 '23 14:04 dsplaisted