title: Building vSphere DLLs fails with CS8078: An expression is too long or complex to compile
body: <p>I am following the documentation here <a href="http://pubs.vmware.com/vsphere-65/index.jsp#com.vmware.wssdk.dsg.doc/sdk_c_sharp_development.5.1.html" rel="nofollow noreferrer" title="Setting Up for Microsoft C# Development">Setting Up for Microsoft C# Development</a> and at this step <a href="http://pubs.vmware.com/vsphere-65/index.jsp#com.vmware.wssdk.dsg.doc/sdk_c_sharp_development.5.5.html?path=4_2_0_0_2_3_0#998866" rel="nofollow noreferrer" title="Building the C# vSphere DLLs">Building the C# vSphere DLLs</a> I get the following in Developer Command Prompt:</p>
  
  <pre><code>C:\Users\user\Downloads\VMware-vSphereSDK-6.5.0-4571253\SDK\vsphere-ws\dotnet\bin&gt;build.bat
          1 file(s) copied.
  Fixing HttpNfcLeaseInfo type, adding missing leaseState property
  Generating VimService.cs
  Microsoft (R) Service Model Metadata Tool
  [Microsoft (R) Windows (R) Communication Foundation, Version 4.6.1055.0]
  Copyright (c) Microsoft Corporation.  All rights reserved.
  
  Generating files...
  C:\Users\user\Downloads\VMware-vSphereSDK-6.5.0-4571253\SDK\vsphere-ws\dotnet\bin\VimService.cs
  Compiling original VimService.dll
  Microsoft (R) Service Model Metadata Tool
  [Microsoft (R) Windows (R) Communication Foundation, Version 4.6.1055.0]
  Copyright (c) Microsoft Corporation.  All rights reserved.
  
  Generating XML serializers...
  C:\Users\user\Downloads\VMware-vSphereSDK-6.5.0-4571253\SDK\vsphere-ws\dotnet\bin\VimServiceSerializers.cs
          1 file(s) copied.
  Optimizing VimService.cs by stripping serializer hint attributes.
  Compiling optimized VimService.dll
  FAILED
  </code></pre>
  
  <p>Looking at <code>build.bat</code> it looks like it is failing on this line:</p>
  
  <pre><code>echo Compiling optimized VimService.dll
  csc /t:library /out:Vim25Service.dll VimService.cs VimServiceSerializers.cs &gt;nul || goto ERROR
  </code></pre>
  
  <p>If I run <code>csc /t:library /out:Vim25Service.dll VimService.cs VimServiceSerializers.cs</code> manually i get the following:</p>
  
  <pre><code>C:\Users\user\Downloads\VMware-vSphereSDK-6.5.0-4571253\SDK\vsphere-ws\dotnet\bin&gt;csc /t:library /out:Vim25Service.dll VimService.cs VimServiceSerializers.cs
  Microsoft (R) Visual C# Compiler version 1.3.1.60616
  Copyright (C) Microsoft Corporation. All rights reserved.
  
  VimServiceSerializers.cs(32548,98): error CS8078: An expression is too long or complex to compile
  </code></pre>
  
  <p>I also tried with VS2017:</p>
  
  <pre><code>C:\Users\user\Downloads\VMware-vSphereSDK-6.5.0-4571253\SDK\vsphere-ws\dotnet\bin&gt;csc /t:library /out:Vim25Service.dll VimService.cs VimServiceSerializers.cs
  Microsoft (R) Visual C# Compiler version 2.0.0.61213
  Copyright (C) Microsoft Corporation. All rights reserved.
  
  VimServiceSerializers.cs(31372,109): error CS8078: An expression is too long or complex to compile
  </code></pre>
  
  <p>A behavior to note, on <code>VimServiceSerializers.cs(#####,##)</code> the line and column are different every time.</p>
  
  <p>Googling error CS8078, found it is an issue with the compiler running out of stack space. <a href="https://stackoverflow.com/a/8160109/6656422">https://stackoverflow.com/a/8160109/6656422</a></p>
  
  <p>How do I successfully compile VmWare's code?</p>