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

[Bug]: Type load exception for BuildRequestDataBase thrown upon getting cache result #10349

Closed
mruxmohan4 opened this issue Jul 9, 2024 · 2 comments · Fixed by #10394
Closed
Assignees

Comments

@mruxmohan4
Copy link
Contributor

mruxmohan4 commented Jul 9, 2024

Issue Description

When MSBuild is executed with the quickbuild project cache plugin enabled, a System.TypeLoadException is thrown nearly immediately after the QuickBuildProjectCachePlugin is loaded. Upon further inspection, this occurs when attempting to get the cache result. Instead of getting a proper cache hit where it normally would, the build results in cache misses and demonstrates that the build has completed successfully with the following warning.

c:\src\CloudBuild\private\BuildEngine\Updater\src\QuickBuildUpdater.csproj : warning : Exception querying the QuickBuild project cache plugin. Treating as a cache miss. Exception: System.TypeLoadException: Could not load type 'Microsoft.Build.Execution.BuildRequestDataBase' from assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

This issue began occurring only after the MSBuild package version was updated from 17.12.0-preview-24328-03 to 17.12.0-preview-24354-03.

Steps to Reproduce

Command-line invocation:

  • set EnableQuickBuildCachePlugin=true
  • msbuild

Expected Behavior

c:\src\CloudBuild\private\BuildEngine\Updater\src>msbuild
MSBuild version 17.11.0-preview-24279-02+b963c24ef for .NET Framework


  Determining projects to restore...
  All projects are up-to-date for restore.
Static graph loaded in 0.121 seconds: 1 nodes, 0 edges
Loading the following project cache plugin: QuickbuildProjectCachePlugin
QuickBuildUpdater -> Cache Hit
Build completed, but files may be still materializing and may take some time to finish.

Project cache statistics:
  Cache Hit Count: 1
  Cache Miss Count: 0
  Cache Hit Ratio: 100.0%


Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:29.32

Actual Behavior

c:\src\CloudBuild\private\BuildEngine\Updater\src>msbuild
MSBuild version 17.11.0-preview-24279-02+b963c24ef for .NET Framework


  Determining projects to restore...
  All projects are up-to-date for restore.
Static graph loaded in 0.094 seconds: 1 nodes, 0 edges
Loading the following project cache plugin: QuickbuildProjectCachePlugin
c:\src\CloudBuild\private\BuildEngine\Updater\src\QuickBuildUpdater.csproj : warning : Exception querying the QuickBuild project cache plugin. Treating as a cache miss. Exception: System.TypeLoadException: Could not load type 'Microsoft.Build.Execution.BuildRequestDataBase' from assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
c:\src\CloudBuild\private\BuildEngine\Updater\src\QuickBuildUpdater.csproj : warning :    at Microsoft.Build.QuickbuildProjectCache.QuickbuildProjectCachePlugin.<>c__DisplayClass17_0.<<GetCacheResultAsync>g__GetCacheResultImpl|0>d.MoveNext()
c:\src\CloudBuild\private\BuildEngine\Updater\src\QuickBuildUpdater.csproj : warning :    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
c:\src\CloudBuild\private\BuildEngine\Updater\src\QuickBuildUpdater.csproj : warning :    at Microsoft.Build.QuickbuildProjectCache.QuickbuildProjectCachePlugin.<>c__DisplayClass17_0.<GetCacheResultAsync>g__GetCacheResultImpl|0()
c:\src\CloudBuild\private\BuildEngine\Updater\src\QuickBuildUpdater.csproj : warning :    at Microsoft.Build.QuickbuildProjectCache.QuickbuildProjectCachePlugin.<GetCacheResultAsync>d__17.MoveNext() in c:\src\CloudBuild\private\BuildEngine\ProjectCachePlugin\src\Plugin\QuickbuildProjectCachePlugin.cs:line 286
  QuickBuildUpdater -> c:\src\CloudBuild\private\BuildEngine\Updater\src\bin\x64\Debug\QuickBuildUpdater.exe
  The package QuickBuildUpdater.1.0.19 is missing a readme. Go to https://aka.ms/nuget/authoring-best-practices/readme to learn why package readmes are important.
  Successfully created package 'c:\src\CloudBuild\target\distrib\debug\amd64\nuget\QuickBuildUpdater.1.0.19.nupkg'.
Build completed, but files may be still materializing and may take some time to finish.

Project cache statistics:
  Cache Hit Count: 0
  Cache Miss Count: 0
  Cache Hit Ratio: NaN


Build succeeded.

c:\src\CloudBuild\private\BuildEngine\Updater\src\QuickBuildUpdater.csproj : warning : Exception querying the QuickBuild project cache plugin. Treating as a cache miss. Exception: System.TypeLoadException: Could not load type 'Microsoft.Build.Execution.BuildRequestDataBase' from assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
c:\src\CloudBuild\private\BuildEngine\Updater\src\QuickBuildUpdater.csproj : warning :    at Microsoft.Build.QuickbuildProjectCache.QuickbuildProjectCachePlugin.<>c__DisplayClass17_0.<<GetCacheResultAsync>g__GetCacheResultImpl|0>d.MoveNext()
c:\src\CloudBuild\private\BuildEngine\Updater\src\QuickBuildUpdater.csproj : warning :    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
c:\src\CloudBuild\private\BuildEngine\Updater\src\QuickBuildUpdater.csproj : warning :    at Microsoft.Build.QuickbuildProjectCache.QuickbuildProjectCachePlugin.<>c__DisplayClass17_0.<GetCacheResultAsync>g__GetCacheResultImpl|0()
c:\src\CloudBuild\private\BuildEngine\Updater\src\QuickBuildUpdater.csproj : warning :    at Microsoft.Build.QuickbuildProjectCache.QuickbuildProjectCachePlugin.<GetCacheResultAsync>d__17.MoveNext() in c:\src\CloudBuild\private\BuildEngine\ProjectCachePlugin\src\Plugin\QuickbuildProjectCachePlugin.cs:line 286
    1 Warning(s)
    0 Error(s)

Time Elapsed 00:00:37.23

Analysis

This appears directly related to #10172, which adds the Microsoft.Build.Execution.BuildRequestDataBase class and is the latest MSBuild change which has impacted that class.

Versions & Configurations

MSBuild version 17.11.0-preview-24279-02+b963c24ef for .NET Framework
17.11.0.27902

Version of CLI tool:
Visual Studio 2022 Developer Command Prompt v17.11.0-pre.2.1

@JanKrivanek
Copy link
Member

@dfederm Can you advise here? It looks like possibly clash of multiple versions of MSBuild references - but I'd expect QuickBuild to use just single version of MSBuild.
A dump of a repro would be helpful here

@dfederm
Copy link
Contributor

dfederm commented Jul 16, 2024

QuickBuild uses pre-release builds, updated weekly, for parsing. This is what we compile against. It uses the user-configured MSBuild for actually building projects.

For this specific scenario though, this is the project cache plugin for QuickBuild. So we're compiled against the prerelease version of MSBuild, but we're obviously in the MSBuild process of whatever the user is using.

So the problem here is that we must choose some version of MSBuild to compile against, but we have no control over the version of MSBuild being used at runtime. So the change with BuildRequestDataBase causes a breaking change when the compile vs runtime are on different sides of the line.

Currently we are unable to update the MSBuild used in QuickBuild indefinitely until this issue is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants