I am following the documentation here Setting Up for Microsoft C# Development and at this step Building the C# vSphere DLLs I get the following in Developer Command Prompt:
C:\Users\user\Downloads\VMware-vSphereSDK-6.5.0-4571253\SDK\vsphere-ws\dotnet\bin>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
Looking at build.bat it looks like it is failing on this line:
echo Compiling optimized VimService.dll
csc /t:library /out:Vim25Service.dll VimService.cs VimServiceSerializers.cs >nul || goto ERROR
If I run csc /t:library /out:Vim25Service.dll VimService.cs VimServiceSerializers.cs manually i get the following:
C:\Users\user\Downloads\VMware-vSphereSDK-6.5.0-4571253\SDK\vsphere-ws\dotnet\bin>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
I also tried with VS2017:
C:\Users\user\Downloads\VMware-vSphereSDK-6.5.0-4571253\SDK\vsphere-ws\dotnet\bin>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
A behavior to note, on VimServiceSerializers.cs(#####,##) the line and column are different every time.
Googling error CS8078, found it is an issue with the compiler running out of stack space. https://stackoverflow.com/a/8160109/6656422
How do I successfully compile VmWare's code?
I figured it out. The serializer CS file has long uninterrupted stretches of
if ... else if ... else if ...clauses. The compiler has to deal with the whole if/else expression at once, which causes it to run out of stack space.Fortunately, each branch in these
else ifs terminates with areturnstatement. This makes all theelse ifs functionally equivalent to just independentifstatements, which are parsed independently.After making this substitution in a number of places, the file compiles. Here's my modified VimServiceSerializers.cs: https://1drv.ms/u/s!Al6mzY0CpY7EnHqBRDyg-z0ctrjk