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

System.MissingMethodException in MSBuild bundled with VS2019 #4286

Closed
Hubert-Rybak opened this issue Apr 4, 2019 · 7 comments
Closed

System.MissingMethodException in MSBuild bundled with VS2019 #4286

Hubert-Rybak opened this issue Apr 4, 2019 · 7 comments
Labels

Comments

@Hubert-Rybak
Copy link

Hubert-Rybak commented Apr 4, 2019

On fresh installation of VS2019, when trying to build project from VS Console, I'm getting following error on every solution:

System.MissingMethodException: Method not found: 'Void Microsoft.Build.Evaluation.ProjectCollection..ctor(System.Collections.Generic.IDictionary`2<System.String,System.String>, System.Collections.Generic.IEnumerable`1<Microsoft.Build.Framework.ILogger>, System.Collections.Generic.IEnumerable`1<Microsoft.Build.Logging.ForwardingLoggerRecord>, Microsoft.Build.Evaluation.ToolsetDefinitionLocations, Int32, Boolean, Boolean)'.
   at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, Dictionary`2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Boolean needToValidateProject, String schemaFile, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, Boolean detailedSummary, ISet`1 warningsAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, Boolean isolateProjects, Boolean graphBuild, String[] inputResultsCaches, String outputResultsCache)
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String commandLine)

Unhandled Exception: System.MissingMethodException: Method not found: 'Void Microsoft.Build.Evaluation.ProjectCollection..ctor(System.Collections.Generic.IDictionary`2<System.String,System.String>, System.Collections.Generic.IEnumerable`1<Microsoft.Build.Framework.ILogger>, System.Collections.Generic.IEnumerable`1<Microsoft.Build.Logging.ForwardingLoggerRecord>, Microsoft.Build.Evaluation.ToolsetDefinitionLocations, Int32, Boolean, Boolean)'.
   at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, Dictionary`2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Boolean needToValidateProject, String schemaFile, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, Boolean detailedSummary, ISet`1 warningsAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, Boolean isolateProjects, Boolean graphBuild, String[] inputResultsCaches, String outputResultsCache)
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String commandLine)
   at Microsoft.Build.CommandLine.MSBuildApp.Main()

When trying to open solution directly from VS, projects are failing to load, and MSBuild just crashes.
There is also ongoing discussion about this here:
https://developercommunity.visualstudio.com/content/problem/500131/0-projects-in-solution-explorer-in-visual-studio-2.html

@Hubert-Rybak Hubert-Rybak changed the title System.MissingMethodException in msbuild bundled with VS2019 System.MissingMethodException in MSBuild bundled with VS2019 Apr 4, 2019
@rainersigwald
Copy link
Member

Can you please download and run https://github.com/Microsoft/msbuild/blob/master/scripts/EnumerateMSBuild.ps1 and post the results? I suspect you have an old version of MSBuild installed in your GAC.

@Hubert-Rybak
Copy link
Author

@rainersigwald
Copy link
Member

Thank you, that shows the problem. You have MSBuild assemblies in your Global Assembly Cache, which they're not designed for.

You can run these commands from an elevated Developer Command Prompt to remove them:

gacutil /u "MSBuild, Version=15.1.0.0"
gacutil /u "Microsoft.Build.Conversion.Core, Version=15.1.0.0"
gacutil /u "Microsoft.Build, Version=15.1.0.0"
gacutil /u "Microsoft.Build.Engine, Version=15.1.0.0"
gacutil /u "Microsoft.Build.Tasks.Core, Version=15.1.0.0"
gacutil /u "Microsoft.Build.Utilities.Core, Version=15.1.0.0"
gacutil /u "Microsoft.Build.Framework, Version=15.1.0.0"

After that, VS 2017 and VS 2019 will be able to each have their own copy of MSBuild and they won't interfere with one another.

@Hubert-Rybak
Copy link
Author

Thanks, it helped! Something must gone wrong during VS2019 install or VS2017 uninstall.

@kerrpeter
Copy link

Fresh install of VS2019 preview 5 and I had same problem.
Fix from @rainersigwald solved it.
I'm not aware of anything I did within VS2017 to place MSBuild assemblies in your Global Assembly Cache.
Would be good if the VS2019 install automatically checked this

@rainersigwald
Copy link
Member

Would be good if the VS2019 install automatically checked this

I agree. Unfortunately, the current VS setup process doesn't make this easy to do. We'll sync with the Setup team again to see if our options have improved there.

@Blizzardo1
Copy link

Blizzardo1 commented Nov 18, 2019

I am using the latest Rider version (2019.3 EAP 4; At the time of this comment) and have not been able to utilize WinForms at all since I removed VS2019 for being too broken on my system months ago. Since then I have had no space to even reconsider VS2019 as the SSD I am working with is far too small (Yes I have been considering a newer SSD, one with more space... sosumi)

Currently I can only do Console Applications, nothing requiring even a spec of GUI libraries. So far, I have had no luck in using the latest version of MSBuild other than through the Dotnet SDK 2.2.202 which I assume now is not the latest version anymore, however it does not build GUIs. I had installed MSBuild separately which installed it into the VS2019 folder on my workstation, however I get the following error: https://gist.github.com/Blizzardo1/55a73801b733d5b7a12dafc0e553a9c7

By googling it had lead me here and thus I ran the EnumerateMSBuild script which got me the following output: https://gist.github.com/Blizzardo1/5d97e68fe7119394d696c90d73b4f8c0

Please let me know what I can do to finally fix this 6 month issue once and for all.

Thank you.

EDIT: Looking at one of the suggestions above to use gacutil (me not having it installed as I do not have VisualStudio 2019 installed), I had taken the Microsoft.NET list portion of my msbuild_version (Which I backed up the entire folder for safety reasons), converted it into a CSV, loaded into a powershell session, and began to remove anything 12 or later from the folder, only to leave anything less than 12, for compatibility I guess or something like such. From there, I restarted Rider, and .... it works! WinForms all the way just like the Double Rainbow.

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

No branches or pull requests

5 participants