UWP and Xamarin Builds Failing with no output

2019-07-07 17:04发布

I have tried creating Android projects and cross platform projects that utilize Xamarin in Visual studio. When I build, even an empty project, it fails instantly without seeming to perform any work.

There are no errors or warnings listed.

The output window has the project name and: Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped

When I start the project I get message boxes warning me about unexpected logger failures and sometimes the dialogs reference the MuxLogger. This is inconsistent, the messages vary slightly and sometimes don't appear at all. Here is an example: MuxLogger failure

Incidentally I tried manually building to get more output and I get this:

Unhandled Exception: System.TypeLoadException: Could not load type 'Microsoft.Build.Logging.ProfilerLogger' from assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
  at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
  at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
  at System.Reflection.RuntimeMethodInfo.GetParameters()
  at System.Diagnostics.StackTrace.ToString(TraceFormat traceFormat)
  at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
  at System.Exception.GetStackTrace(Boolean needFileInfo)
  at System.Exception.ToString(Boolean needFileLineInfo, Boolean needMessage)
  at System.Exception.ToString()
  at Microsoft.Build.CommandLine.MSBuildApp.Execute(String commandLine)
  at Microsoft.Build.CommandLine.MSBuildApp.Main()

Note that I can build many other project types such as web projects and MonoGame projects just fine.

1条回答
Juvenile、少年°
2楼-- · 2019-07-07 17:50

Ultimately this turned out to be a problem with an old version of MSBuild installed in the Global Assembly Cache (GAC). To check for this, first open an instance of Developer Command Prompt for VS2017. Then output the assemblies in your GAC to a file for easy review:

gacutil -l >> someFile.txt

Look for anything that starts with Microsoft.Build, specifically lines that include Version=15.X (hint, these don't output in order so sort the lines alphabetically).

Uninstall all things that start with Microsoft.Build which may include Microsoft.Build.Framework, Microsoft.Build and more. This should not install versions of Microsoft.Build with a version < 15. Command:

gacutil -u Microsoft.Build

and

gacutil -u Microsoft.Build.Framework

This should allow your project to utilize the correct version of MSBuild and compile successfully.

查看更多
登录 后发表回答