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

Crash deserializing BuildEventArgs-derived type in logging node #1675

Open
rainersigwald opened this Issue Feb 7, 2017 · 4 comments

Comments

Projects
3 participants
@rainersigwald
Contributor

rainersigwald commented Feb 7, 2017

[This was reported by an internal user via email]

Microsoft (R) Build Engine version 15.1.523.56541
This is part of VS 26119.0.d15rel

Getting a repro only takes 2 minutes if you have the C++ tools and Windows 8.1 SDK installed:

Open a "Developer Command Prompt for VS 2017 RC"

  1. git clone https://github.com/lz4/lz4.git D:\LZ4\src
  2. cd D:\LZ4
  3. devenv /upgrade .\src\visual\vs2010\lz4.sln
  4. msbuild /p:Configuration=Release;Platform=x64 .\src\visual\VS2010\lz4.sln /t:Rebuild /m /p:BuildInParallel=true

The last command yields a crash in msbuild.exe:

Unhandled Exception: System.ArgumentException: Object of type 'Microsoft.VisualStudio.CodeAnalysis.AnalysisResults.AnalysisMessage' cannot be converted to type 'Microsoft.VisualStudio.CodeAnalysis.AnalysisResults.AnalysisMessage'.
   at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
   at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
   at System.Reflection.RtFieldInfo.UnsafeSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
   at System.Runtime.Serialization.FormatterServices.SerializationSetValue(MemberInfo fi, Object target, Object value)
   at System.Runtime.Serialization.ObjectManager.CompleteObject(ObjectHolder holder, Boolean bObjectFullyComplete)
   at System.Runtime.Serialization.ObjectManager.DoNewlyRegisteredObjectFixups(ObjectHolder holder)
   at System.Runtime.Serialization.ObjectManager.RegisterObject(Object obj, Int64 objectID, SerializationInfo info, Int64 idOfContainingObj, MemberInfo member, Int32[] arrayIndex)
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.RegisterObject(Object obj, ParseRecord pr, ParseRecord objectPr, Boolean bIsString)
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObjectEnd(ParseRecord pr)
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Parse(ParseRecord pr)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   at Microsoft.Build.BackEnd.NodePacketTranslator.NodePacketReadTranslator.TranslateDotNet[T](T& value)
   at Microsoft.Build.Shared.LogMessagePacketBase.ReadFromStream(INodePacketTranslator translator)
   at Microsoft.Build.Shared.LogMessagePacketBase.Translate(INodePacketTranslator translator)
   at Microsoft.Build.BackEnd.LogMessagePacket.FactoryForDeserialization(INodePacketTranslator translator)
   at Microsoft.Build.BackEnd.NodePacketFactory.PacketFactoryRecord.DeserializeAndRoutePacket(Int32 nodeId, INodePacketTranslator translator)
   at Microsoft.Build.BackEnd.NodePacketFactory.DeserializeAndRoutePacket(Int32 nodeId, NodePacketType packetType, INodePacketTranslator translator)
   at Microsoft.Build.BackEnd.NodeManager.DeserializeAndRoutePacket(Int32 nodeId, NodePacketType packetType, INodePacketTranslator translator)
   at Microsoft.Build.BackEnd.NodeProviderOutOfProcBase.NodeContext.ReadAndRoutePacket(NodePacketType packetType, Byte[] packetData, Int32 packetLength)
   at Microsoft.Build.BackEnd.NodeProviderOutOfProcBase.NodeContext.BodyReadComplete(IAsyncResult result)
   at System.IO.Pipes.PipeStream.AsyncPSCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
@rainersigwald

This comment has been minimized.

Show comment
Hide comment
@rainersigwald

rainersigwald Feb 7, 2017

Contributor

I can repro this on MSBuild 15.1.545.13942, including under a debugger. Investigating.

Contributor

rainersigwald commented Feb 7, 2017

I can repro this on MSBuild 15.1.545.13942, including under a debugger. Investigating.

@rainersigwald

This comment has been minimized.

Show comment
Hide comment
@rainersigwald

rainersigwald Feb 7, 2017

Contributor

Actually, my repro is very slightly different. The exception I get is

System.Runtime.Serialization.SerializationException: Unable to find assembly 'Microsoft.VisualStudio.CodeAnalysis, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Which doesn't seem very true--that assembly (well, version 15.0.26205.0 on my machine) is loaded into the process that claims it can't find it.

Contributor

rainersigwald commented Feb 7, 2017

Actually, my repro is very slightly different. The exception I get is

System.Runtime.Serialization.SerializationException: Unable to find assembly 'Microsoft.VisualStudio.CodeAnalysis, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Which doesn't seem very true--that assembly (well, version 15.0.26205.0 on my machine) is loaded into the process that claims it can't find it.

@rainersigwald

This comment has been minimized.

Show comment
Hide comment
@rainersigwald

rainersigwald Feb 8, 2017

Contributor

My current theory is that the original reporter had an incompatible version of Microsoft.VisualStudio.CodeAnalysis in the GAC, while I don't have one. That would explain the cast error and my failure to find the assembly.

This is occurring because the NativeCodeAnalysis task calls

CodeAnalysisWarningEventArgs e = ...;
BuildEngine.LogWarningEvent(e);

where

internal class CodeAnalysisWarningEventArgs : 
        BuildWarningEventArgs,
        ICodeAnalysisEventArgs

The worker node attempts to serialize the BuildWarningEventArgs across the process boundary to the main logging node, where we fail to deserialize it. That wasn't a problem in dev14 because that assembly was in the GAC so its types were available to any MSBuild.exe that wanted them.

Ideally, MSBuild would be robust to this situation, but it doesn't look like there's an easy way to handle the deserialization error gracefully. I'm following up with an internal bug on the NativeCodeAnalysis task to stop using a derived type and instead just log a BuildWarningEventArgs.

Contributor

rainersigwald commented Feb 8, 2017

My current theory is that the original reporter had an incompatible version of Microsoft.VisualStudio.CodeAnalysis in the GAC, while I don't have one. That would explain the cast error and my failure to find the assembly.

This is occurring because the NativeCodeAnalysis task calls

CodeAnalysisWarningEventArgs e = ...;
BuildEngine.LogWarningEvent(e);

where

internal class CodeAnalysisWarningEventArgs : 
        BuildWarningEventArgs,
        ICodeAnalysisEventArgs

The worker node attempts to serialize the BuildWarningEventArgs across the process boundary to the main logging node, where we fail to deserialize it. That wasn't a problem in dev14 because that assembly was in the GAC so its types were available to any MSBuild.exe that wanted them.

Ideally, MSBuild would be robust to this situation, but it doesn't look like there's an easy way to handle the deserialization error gracefully. I'm following up with an internal bug on the NativeCodeAnalysis task to stop using a derived type and instead just log a BuildWarningEventArgs.

rainersigwald added a commit to rainersigwald/msbuild that referenced this issue Feb 14, 2017

Work around Microsoft#1675 for C++ Code Analysis scenarios
This addresses the repro case for Microsoft#1675, but not its root cause. By
providing a `codeBase` for the CA assemblies, we ensure that any running
MSBuild can find them when deserializing a log message.

AndyGerlicher added a commit that referenced this issue Feb 14, 2017

Work around #1675 for C++ Code Analysis scenarios (#1699)
This addresses the repro case for #1675, but not its root cause. By
providing a `codeBase` for the CA assemblies, we ensure that any running
MSBuild can find them when deserializing a log message.
@rainersigwald

This comment has been minimized.

Show comment
Hide comment
@rainersigwald

rainersigwald Feb 17, 2017

Contributor

The larger problem of crashing on deserialization of a BuildEventArgs-derived type is still there, so I'm reopening and generalizing this issue.

Contributor

rainersigwald commented Feb 17, 2017

The larger problem of crashing on deserialization of a BuildEventArgs-derived type is still there, so I'm reopening and generalizing this issue.

@rainersigwald rainersigwald reopened this Feb 17, 2017

@rainersigwald rainersigwald changed the title from Crash deserializing BuildEventArgs in C++ project to Crash deserializing BuildEventArgs-derived type in logging node Feb 17, 2017

@rainersigwald rainersigwald modified the milestones: MSBuild 15 Update, Visual Studio 15 RTW Feb 17, 2017

@AndyGerlicher AndyGerlicher added this to TODO in 114.2 Feb 21, 2017

@Sarabeth-Jaffe-Microsoft Sarabeth-Jaffe-Microsoft modified the milestones: MSBuild 15 Update, MSBuild 15 - "2.0" Mar 3, 2017

@Sarabeth-Jaffe-Microsoft Sarabeth-Jaffe-Microsoft added this to Rainer in 115.2 Mar 10, 2017

@Sarabeth-Jaffe-Microsoft Sarabeth-Jaffe-Microsoft removed this from Rainer in 115.2 Mar 10, 2017

@rainersigwald rainersigwald removed their assignment Mar 14, 2017

@AndyGerlicher AndyGerlicher modified the milestones: MSBuild 15.5, After 15 Sep 28, 2017

jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Sep 21, 2018

[xabuild] we don't need config file in stdout
When we first implemented `xabuild.exe`, we though it was helpful to
see the configuration file that was used if the build failed.

However, it mostly seems unnecessary now, since:
- All variables used are printed in diagnostic or binary log files.
  They show up as properties at the beginning of the build.
- We are all much more accustomed to looking through binary log files
  now anyway. Our build even saves them!

I very much dislike having to scroll *way* up my console window when a
build fails!

Here is an example of what the output *used* to look like:

    > .\bin\Debug\bin\xabuild /asdfsadfsdadf
    Microsoft (R) Build Engine version 15.8.168+ga8fba1ebd7 for .NET Framework
    Copyright (C) Microsoft Corporation. All rights reserved.

    MSBUILD : error MSB1001: Unknown switch.
    Switch: /asdfsadfsdadf

    For switch syntax, type "MSBuild /help"
    MSBuildApp.Main exited with 1, xabuild configuration is:
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <section
          name="msbuildToolsets"
          type="Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      </configSections>
      <startup
        useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime
          version="v4.0"
          sku=".NETFramework,Version=v4.6" />
      </startup>
      <runtime>
        <AppContextSwitchOverrides
          value="Switch.System.IO.UseLegacyPathHandling=false" />
        <DisableFXClosureWalk
          enabled="true" />
        <generatePublisherEvidence
          enabled="false" />
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity
              name="Microsoft.Build.Framework"
              culture="neutral"
              publicKeyToken="b03f5f7f11d50a3a" />
            <bindingRedirect
              oldVersion="0.0.0.0-99.9.9.9"
              newVersion="15.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity
              name="Microsoft.Build"
              culture="neutral"
              publicKeyToken="b03f5f7f11d50a3a" />
            <bindingRedirect
              oldVersion="0.0.0.0-99.9.9.9"
              newVersion="15.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity
              name="Microsoft.Build.Conversion.Core"
              culture="neutral"
              publicKeyToken="b03f5f7f11d50a3a" />
            <bindingRedirect
              oldVersion="0.0.0.0-99.9.9.9"
              newVersion="15.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity
              name="Microsoft.Build.Tasks.Core"
              culture="neutral"
              publicKeyToken="b03f5f7f11d50a3a" />
            <bindingRedirect
              oldVersion="0.0.0.0-99.9.9.9"
              newVersion="15.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity
              name="Microsoft.Build.Utilities.Core"
              culture="neutral"
              publicKeyToken="b03f5f7f11d50a3a" />
            <bindingRedirect
              oldVersion="0.0.0.0-99.9.9.9"
              newVersion="15.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity
              name="Microsoft.Build.Engine"
              culture="neutral"
              publicKeyToken="b03f5f7f11d50a3a" />
            <bindingRedirect
              oldVersion="0.0.0.0-99.9.9.9"
              newVersion="15.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity
              name="Microsoft.Build.Conversion.Core"
              culture="neutral"
              publicKeyToken="b03f5f7f11d50a3a" />
            <bindingRedirect
              oldVersion="0.0.0.0-99.9.9.9"
              newVersion="15.1.0.0" />
          </dependentAssembly>
          <!-- Redirects for facade assemblies -->
          <dependentAssembly>
            <assemblyIdentity
              name="System.IO.Compression"
              culture="neutral"
              publicKeyToken="b77a5c561934e089" />
            <bindingRedirect
              oldVersion="0.0.0.0-4.1.2.0"
              newVersion="4.1.2.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity
              name="System.Runtime.InteropServices.RuntimeInformation"
              publicKeyToken="b03f5f7f11d50a3a"
              culture="neutral" />
            <bindingRedirect
              oldVersion="0.0.0.0-4.0.1.0"
              newVersion="4.0.1.0" />
          </dependentAssembly>
          <!-- Redirects for components dropped by Visual Studio -->
          <dependentAssembly>
            <assemblyIdentity
              name="Microsoft.Activities.Build"
              culture="neutral"
              publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect
              oldVersion="4.0.0.0"
              newVersion="15.0.0.0" />
            <codeBase
              version="15.0.0.0"
              href=".\amd64\Microsoft.Activities.Build.dll" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity
              name="XamlBuildTask"
              culture="neutral"
              publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect
              oldVersion="4.0.0.0"
              newVersion="15.0.0.0" />
            <codeBase
              version="15.0.0.0"
              href=".\amd64\XamlBuildTask.dll" />
          </dependentAssembly>
          <!-- Workaround for crash in C++ CodeAnalysis scenarios due to Microsoft/msbuild#1675 -->
          <dependentAssembly>
            <assemblyIdentity
              name="FxCopTask"
              culture="neutral"
              publicKeyToken="b03f5f7f11d50a3a" />
            <codeBase
              version="15.0.0.0"
              href="..\..\Microsoft\VisualStudio\v15.0\CodeAnalysis\FxCopTask.dll" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity
              name="Microsoft.VisualStudio.CodeAnalysis"
              culture="neutral"
              publicKeyToken="b03f5f7f11d50a3a" />
            <codeBase
              version="15.0.0.0"
              href="..\..\Microsoft\VisualStudio\v15.0\CodeAnalysis\Microsoft.VisualStudio.CodeAnalysis.dll" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity
              name="Microsoft.VisualStudio.CodeAnalysis.Sdk"
              culture="neutral"
              publicKeyToken="b03f5f7f11d50a3a" />
            <codeBase
              version="15.0.0.0"
              href="..\..\Microsoft\VisualStudio\v15.0\CodeAnalysis\Microsoft.VisualStudio.CodeAnalysis.Sdk.dll" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <!-- To define one or more new toolsets, add an 'msbuildToolsets' element in this file. -->
      <msbuildToolsets
        default="15.0">
        <toolset
          toolsVersion="15.0">
          <property
            name="AndroidNdkDirectory"
            value="C:\Users\myuser\android-toolchain\ndk" />
          <property
            name="AndroidSdkDirectory"
            value="C:\Users\myuser\android-toolchain\sdk" />
          <property
            name="TargetFrameworkRootPath"
            value="C:\Users\myuser\Desktop\Git\xamarin-android\bin\Debug\lib\xamarin.android\xbuild-frameworks\" />
          <property
            name="MonoAndroidToolsDirectory"
            value="C:\Users\myuser\Desktop\Git\xamarin-android\bin\Debug\lib\xamarin.android\xbuild\Xamarin\Android" />
          <property
            name="NuGetRestoreTargets"
            value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets" />
          <property
            name="NuGetTargets"
            value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets" />
          <property
            name="NuGetProps"
            value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.props" />
          <property
            name="MSBuildToolsPath"
            value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin" />
          <property
            name="MSBuildToolsPath32"
            value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin" />
          <property
            name="MSBuildToolsPath64"
            value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin" />
          <property
            name="MSBuildSDKsPath"
            value="$([MSBuild]::GetMSBuildSDKsPath())" />
          <property
            name="FrameworkSDKRoot"
            value="$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1@InstallationFolder)" />
          <property
            name="MSBuildRuntimeVersion"
            value="4.0.30319" />
          <property
            name="MSBuildFrameworkToolsPath"
            value="$(SystemRoot)\Microsoft.NET\Framework\v$(MSBuildRuntimeVersion)\" />
          <property
            name="MSBuildFrameworkToolsPath32"
            value="$(SystemRoot)\Microsoft.NET\Framework\v$(MSBuildRuntimeVersion)\" />
          <property
            name="MSBuildFrameworkToolsPath64"
            value="$(SystemRoot)\Microsoft.NET\Framework64\v$(MSBuildRuntimeVersion)\" />
          <property
            name="MSBuildFrameworkToolsRoot"
            value="$(SystemRoot)\Microsoft.NET\Framework\" />
          <property
            name="SDK35ToolsPath"
            value="$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx35Tools-x86', 'InstallationFolder', null, RegistryView.Registry32))" />
          <property
            name="SDK40ToolsPath"
            value="$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1\WinSDK-NetFx40Tools-x86', 'InstallationFolder', null, RegistryView.Registry32))" />
          <property
            name="WindowsSDK80Path"
            value="$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1@InstallationFolder)" />
          <property
            name="VsInstallRoot"
            value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise" />
          <property
            name="MSBuildToolsRoot"
            value="$(VsInstallRoot)\MSBuild" />
          <property
            name="MSBuildExtensionsPath"
            value="C:\Users\myuser\Desktop\Git\xamarin-android\bin\Debug\lib\xamarin.android\xbuild" />
          <property
            name="MSBuildExtensionsPath32"
            value="C:\Users\myuser\Desktop\Git\xamarin-android\bin\Debug\lib\xamarin.android\xbuild" />
          <property
            name="RoslynTargetsPath"
            value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn" />
          <!-- VC Specific Paths -->
          <property
            name="VCTargetsPath"
            value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(VsInstallRoot)\Common7\IDE\VC\VCTargets\'))" />
          <property
            name="VCTargetsPath14"
            value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath14)','$([MSBuild]::GetProgramFiles32())\MSBuild\Microsoft.Cpp\v4.0\V140\'))" />
          <property
            name="VCTargetsPath12"
            value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath12)','$([MSBuild]::GetProgramFiles32())\MSBuild\Microsoft.Cpp\v4.0\V120\'))" />
          <property
            name="VCTargetsPath11"
            value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$([MSBuild]::GetProgramFiles32())\MSBuild\Microsoft.Cpp\v4.0\V110\'))" />
          <property
            name="VCTargetsPath10"
            value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath10)','$([MSBuild]::GetProgramFiles32())\MSBuild\Microsoft.Cpp\v4.0\'))" />
          <property
            name="AndroidTargetsPath"
            value="$(MSBuildExtensionsPath32)\Microsoft\MDD\Android\V150\" />
          <property
            name="iOSTargetsPath"
            value="$(MSBuildExtensionsPath32)\Microsoft\MDD\iOS\V150\" />
          <projectImportSearchPaths>
            <searchPaths
              os="windows">
              <property
                name="MSBuildExtensionsPath"
                value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild;$(MSBuildProgramFiles32)\MSBuild" />
              <property
                name="MSBuildExtensionsPath32"
                value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild;$(MSBuildProgramFiles32)\MSBuild" />
              <property
                name="MSBuildExtensionsPath64"
                value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild;$(MSBuildProgramFiles32)\MSBuild" />
              <property
                name="VSToolsPath"
                value="$(MSBuildProgramFiles32)\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)" />
            </searchPaths>
          </projectImportSearchPaths>
        </toolset>
      </msbuildToolsets>
    </configuration>

Now it's much more pleasant:

    > .\bin\Debug\bin\xabuild /asdfsadfsdadf
    Microsoft (R) Build Engine version 15.8.168+ga8fba1ebd7 for .NET Framework
    Copyright (C) Microsoft Corporation. All rights reserved.

    MSBUILD : error MSB1001: Unknown switch.
    Switch: /asdfsadfsdadf

    For switch syntax, type "MSBuild /help"

And we can review build logs if we need more detail.

jonpryor added a commit to xamarin/xamarin-android that referenced this issue Sep 21, 2018

[xabuild] we don't need config file in stdout (#2210)
When we first implemented `xabuild.exe`, we though it was helpful to
see the configuration file that was used if the build failed.

However, it mostly seems unnecessary now, since:

  - All variables used are printed in diagnostic or binary log files.
    They show up as properties at the beginning of the build.
  - We are all much more accustomed to looking through binary log
    files now anyway.  Our build even saves them!

I very much dislike having to scroll *way* up my console window when
a build fails!

Here is an example of what the output *used* to look like:

	> .\bin\Debug\bin\xabuild /asdfsadfsdadf
	Microsoft (R) Build Engine version 15.8.168+ga8fba1ebd7 for .NET Framework
	Copyright (C) Microsoft Corporation. All rights reserved.

	MSBUILD : error MSB1001: Unknown switch.
	Switch: /asdfsadfsdadf

	For switch syntax, type "MSBuild /help"
	MSBuildApp.Main exited with 1, xabuild configuration is:
	<?xml version="1.0" encoding="utf-8"?>
	<configuration>
	  <configSections>
	    <section
	      name="msbuildToolsets"
	      type="Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
	  </configSections>
	  <startup
	    useLegacyV2RuntimeActivationPolicy="true">
	    <supportedRuntime
	      version="v4.0"
	      sku=".NETFramework,Version=v4.6" />
	  </startup>
	  <runtime>
	    <AppContextSwitchOverrides
	      value="Switch.System.IO.UseLegacyPathHandling=false" />
	    <DisableFXClosureWalk
	      enabled="true" />
	    <generatePublisherEvidence
	      enabled="false" />
	    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
	      <dependentAssembly>
	        <assemblyIdentity
	          name="Microsoft.Build.Framework"
	          culture="neutral"
	          publicKeyToken="b03f5f7f11d50a3a" />
	        <bindingRedirect
	          oldVersion="0.0.0.0-99.9.9.9"
	          newVersion="15.1.0.0" />
	      </dependentAssembly>
	      <dependentAssembly>
	        <assemblyIdentity
	          name="Microsoft.Build"
	          culture="neutral"
	          publicKeyToken="b03f5f7f11d50a3a" />
	        <bindingRedirect
	          oldVersion="0.0.0.0-99.9.9.9"
	          newVersion="15.1.0.0" />
	      </dependentAssembly>
	      <dependentAssembly>
	        <assemblyIdentity
	          name="Microsoft.Build.Conversion.Core"
	          culture="neutral"
	          publicKeyToken="b03f5f7f11d50a3a" />
	        <bindingRedirect
	          oldVersion="0.0.0.0-99.9.9.9"
	          newVersion="15.1.0.0" />
	      </dependentAssembly>
	      <dependentAssembly>
	        <assemblyIdentity
	          name="Microsoft.Build.Tasks.Core"
	          culture="neutral"
	          publicKeyToken="b03f5f7f11d50a3a" />
	        <bindingRedirect
	          oldVersion="0.0.0.0-99.9.9.9"
	          newVersion="15.1.0.0" />
	      </dependentAssembly>
	      <dependentAssembly>
	        <assemblyIdentity
	          name="Microsoft.Build.Utilities.Core"
	          culture="neutral"
	          publicKeyToken="b03f5f7f11d50a3a" />
	        <bindingRedirect
	          oldVersion="0.0.0.0-99.9.9.9"
	          newVersion="15.1.0.0" />
	      </dependentAssembly>
	      <dependentAssembly>
	        <assemblyIdentity
	          name="Microsoft.Build.Engine"
	          culture="neutral"
	          publicKeyToken="b03f5f7f11d50a3a" />
	        <bindingRedirect
	          oldVersion="0.0.0.0-99.9.9.9"
	          newVersion="15.1.0.0" />
	      </dependentAssembly>
	      <dependentAssembly>
	        <assemblyIdentity
	          name="Microsoft.Build.Conversion.Core"
	          culture="neutral"
	          publicKeyToken="b03f5f7f11d50a3a" />
	        <bindingRedirect
	          oldVersion="0.0.0.0-99.9.9.9"
	          newVersion="15.1.0.0" />
	      </dependentAssembly>
	      <!-- Redirects for facade assemblies -->
	      <dependentAssembly>
	        <assemblyIdentity
	          name="System.IO.Compression"
	          culture="neutral"
	          publicKeyToken="b77a5c561934e089" />
	        <bindingRedirect
	          oldVersion="0.0.0.0-4.1.2.0"
	          newVersion="4.1.2.0" />
	      </dependentAssembly>
	      <dependentAssembly>
	        <assemblyIdentity
	          name="System.Runtime.InteropServices.RuntimeInformation"
	          publicKeyToken="b03f5f7f11d50a3a"
	          culture="neutral" />
	        <bindingRedirect
	          oldVersion="0.0.0.0-4.0.1.0"
	          newVersion="4.0.1.0" />
	      </dependentAssembly>
	      <!-- Redirects for components dropped by Visual Studio -->
	      <dependentAssembly>
	        <assemblyIdentity
	          name="Microsoft.Activities.Build"
	          culture="neutral"
	          publicKeyToken="31bf3856ad364e35" />
	        <bindingRedirect
	          oldVersion="4.0.0.0"
	          newVersion="15.0.0.0" />
	        <codeBase
	          version="15.0.0.0"
	          href=".\amd64\Microsoft.Activities.Build.dll" />
	      </dependentAssembly>
	      <dependentAssembly>
	        <assemblyIdentity
	          name="XamlBuildTask"
	          culture="neutral"
	          publicKeyToken="31bf3856ad364e35" />
	        <bindingRedirect
	          oldVersion="4.0.0.0"
	          newVersion="15.0.0.0" />
	        <codeBase
	          version="15.0.0.0"
	          href=".\amd64\XamlBuildTask.dll" />
	      </dependentAssembly>
	      <!-- Workaround for crash in C++ CodeAnalysis scenarios due to Microsoft/msbuild#1675 -->
	      <dependentAssembly>
	        <assemblyIdentity
	          name="FxCopTask"
	          culture="neutral"
	          publicKeyToken="b03f5f7f11d50a3a" />
	        <codeBase
	          version="15.0.0.0"
	          href="..\..\Microsoft\VisualStudio\v15.0\CodeAnalysis\FxCopTask.dll" />
	      </dependentAssembly>
	      <dependentAssembly>
	        <assemblyIdentity
	          name="Microsoft.VisualStudio.CodeAnalysis"
	          culture="neutral"
	          publicKeyToken="b03f5f7f11d50a3a" />
	        <codeBase
	          version="15.0.0.0"
	          href="..\..\Microsoft\VisualStudio\v15.0\CodeAnalysis\Microsoft.VisualStudio.CodeAnalysis.dll" />
	      </dependentAssembly>
	      <dependentAssembly>
	        <assemblyIdentity
	          name="Microsoft.VisualStudio.CodeAnalysis.Sdk"
	          culture="neutral"
	          publicKeyToken="b03f5f7f11d50a3a" />
	        <codeBase
	          version="15.0.0.0"
	          href="..\..\Microsoft\VisualStudio\v15.0\CodeAnalysis\Microsoft.VisualStudio.CodeAnalysis.Sdk.dll" />
	      </dependentAssembly>
	    </assemblyBinding>
	  </runtime>
	  <!-- To define one or more new toolsets, add an 'msbuildToolsets' element in this file. -->
	  <msbuildToolsets
	    default="15.0">
	    <toolset
	      toolsVersion="15.0">
	      <property
	        name="AndroidNdkDirectory"
	        value="C:\Users\myuser\android-toolchain\ndk" />
	      <property
	        name="AndroidSdkDirectory"
	        value="C:\Users\myuser\android-toolchain\sdk" />
	      <property
	        name="TargetFrameworkRootPath"
	        value="C:\Users\myuser\Desktop\Git\xamarin-android\bin\Debug\lib\xamarin.android\xbuild-frameworks\" />
	      <property
	        name="MonoAndroidToolsDirectory"
	        value="C:\Users\myuser\Desktop\Git\xamarin-android\bin\Debug\lib\xamarin.android\xbuild\Xamarin\Android" />
	      <property
	        name="NuGetRestoreTargets"
	        value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets" />
	      <property
	        name="NuGetTargets"
	        value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets" />
	      <property
	        name="NuGetProps"
	        value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.props" />
	      <property
	        name="MSBuildToolsPath"
	        value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin" />
	      <property
	        name="MSBuildToolsPath32"
	        value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin" />
	      <property
	        name="MSBuildToolsPath64"
	        value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin" />
	      <property
	        name="MSBuildSDKsPath"
	        value="$([MSBuild]::GetMSBuildSDKsPath())" />
	      <property
	        name="FrameworkSDKRoot"
	        value="$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1@InstallationFolder)" />
	      <property
	        name="MSBuildRuntimeVersion"
	        value="4.0.30319" />
	      <property
	        name="MSBuildFrameworkToolsPath"
	        value="$(SystemRoot)\Microsoft.NET\Framework\v$(MSBuildRuntimeVersion)\" />
	      <property
	        name="MSBuildFrameworkToolsPath32"
	        value="$(SystemRoot)\Microsoft.NET\Framework\v$(MSBuildRuntimeVersion)\" />
	      <property
	        name="MSBuildFrameworkToolsPath64"
	        value="$(SystemRoot)\Microsoft.NET\Framework64\v$(MSBuildRuntimeVersion)\" />
	      <property
	        name="MSBuildFrameworkToolsRoot"
	        value="$(SystemRoot)\Microsoft.NET\Framework\" />
	      <property
	        name="SDK35ToolsPath"
	        value="$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx35Tools-x86', 'InstallationFolder', null, RegistryView.Registry32))" />
	      <property
	        name="SDK40ToolsPath"
	        value="$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1\WinSDK-NetFx40Tools-x86', 'InstallationFolder', null, RegistryView.Registry32))" />
	      <property
	        name="WindowsSDK80Path"
	        value="$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1@InstallationFolder)" />
	      <property
	        name="VsInstallRoot"
	        value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise" />
	      <property
	        name="MSBuildToolsRoot"
	        value="$(VsInstallRoot)\MSBuild" />
	      <property
	        name="MSBuildExtensionsPath"
	        value="C:\Users\myuser\Desktop\Git\xamarin-android\bin\Debug\lib\xamarin.android\xbuild" />
	      <property
	        name="MSBuildExtensionsPath32"
	        value="C:\Users\myuser\Desktop\Git\xamarin-android\bin\Debug\lib\xamarin.android\xbuild" />
	      <property
	        name="RoslynTargetsPath"
	        value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn" />
	      <!-- VC Specific Paths -->
	      <property
	        name="VCTargetsPath"
	        value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(VsInstallRoot)\Common7\IDE\VC\VCTargets\'))" />
	      <property
	        name="VCTargetsPath14"
	        value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath14)','$([MSBuild]::GetProgramFiles32())\MSBuild\Microsoft.Cpp\v4.0\V140\'))" />
	      <property
	        name="VCTargetsPath12"
	        value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath12)','$([MSBuild]::GetProgramFiles32())\MSBuild\Microsoft.Cpp\v4.0\V120\'))" />
	      <property
	        name="VCTargetsPath11"
	        value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$([MSBuild]::GetProgramFiles32())\MSBuild\Microsoft.Cpp\v4.0\V110\'))" />
	      <property
	        name="VCTargetsPath10"
	        value="$([MSBuild]::ValueOrDefault('$(VCTargetsPath10)','$([MSBuild]::GetProgramFiles32())\MSBuild\Microsoft.Cpp\v4.0\'))" />
	      <property
	        name="AndroidTargetsPath"
	        value="$(MSBuildExtensionsPath32)\Microsoft\MDD\Android\V150\" />
	      <property
	        name="iOSTargetsPath"
	        value="$(MSBuildExtensionsPath32)\Microsoft\MDD\iOS\V150\" />
	      <projectImportSearchPaths>
	        <searchPaths
	          os="windows">
	          <property
	            name="MSBuildExtensionsPath"
	            value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild;$(MSBuildProgramFiles32)\MSBuild" />
	          <property
	            name="MSBuildExtensionsPath32"
	            value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild;$(MSBuildProgramFiles32)\MSBuild" />
	          <property
	            name="MSBuildExtensionsPath64"
	            value="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild;$(MSBuildProgramFiles32)\MSBuild" />
	          <property
	            name="VSToolsPath"
	            value="$(MSBuildProgramFiles32)\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)" />
	        </searchPaths>
	      </projectImportSearchPaths>
	    </toolset>
	  </msbuildToolsets>
	</configuration>

Now it's much more pleasant:

	> .\bin\Debug\bin\xabuild /asdfsadfsdadf
	Microsoft (R) Build Engine version 15.8.168+ga8fba1ebd7 for .NET Framework
	Copyright (C) Microsoft Corporation. All rights reserved.

	MSBUILD : error MSB1001: Unknown switch.
	Switch: /asdfsadfsdadf

	For switch syntax, type "MSBuild /help"

And we can review build logs if we need more detail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment