Search code examples
c#visual-studio-2010compilationthrift

C# Compilation error in Visual Studio 2010 (Thrift 0.9.1 compilation)


I have downloaded Apache Thrift 0.9.1 from here: http://wiki.apache.org/thrift/ThriftUsageCSharp. In Visual Studio 2010, I opened the .sln file in thrift/lib/csharp/src.

However, I am unable to build the solution. I'm getting this error:

Error   3   The command "rmdir /s /q "C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\gen-csharp"
del /f /q "C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\ThriftImpl.dll"
SET OUTPUT_DIR=C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\
SET THRIFT_FILE=C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\\..\..\..\..\test\ThriftTest.thrift
for %%I in ("%OUTPUT_DIR%") do set SHORT_DIR=%%~fsI
for %%I in ("%THRIFT_FILE%") do set THRIFT_SHORT=%%~fs
"C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\\..\..\..\..\compiler\cpp\thrift.exe" --gen csharp -o %SHORT_DIR% %THRIFT_SHORT%
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /t:library /out:"C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\ThriftImpl.dll" /recurse:"C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\gen-csharp"\* /reference:"C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\..\..\src\bin\Debug\Thrift.dll"" exited with code 1.

I've looked in a number of places and am not sure what to do.


Solution

  • That's the pre-build step of the ThriftTest project. If you have troubles with it, which can be difficult to debug, proceed as follows:

    1. Remove the prebuild step stuff entirely from the C# project (Project Properties dialog, Build Events tab)

    2. Compile the \lib\csharp\src\Thrift.csproj to produce the Thrift runtime assembly. Alternatively, consider including the Thrift.csproj project into the solution, which makes it easier to handle.

    3. Open a command line, navigate to the appropriate folder and call thrift.exe --gen csharp ThriftTest.thrift to generate the code from the IDL. This will produce a new folder gen-csharp with a bunch of files in it. The ThriftTest.thrift IDL file is located in the \test folder.

    4. Make sure the generated files from step 3 are included in the ThriftTest project

    5. Build everything

    Note that for step 3 you need the Thrift compiler (thrift.exe) in your path. This file is available as precompiled download on the Apache Thrift web site, you don't need to build it on your own.