In our project we successfully use Google Protobuf for C++. Now there is a need to compile the same *.proto file to use it in C# code. I downloaded the recent Protobuf version 3.0.0-alpha-3. It provides support of proto2 format for C#, which is sufficient for me. I can build my *.proto file successfully and get a *.cs file. However, when I add the resulting *.cs file to my C# project and try to build, I receive compiler errors like these: "The type or namespace name 'Google' could not be found in the global namespace (are you missing an assembly reference?)"
This is the place, where the error happens:
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: DiagramExport.proto
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
using pb = global::Google.ProtocolBuffers;
using pbc = global::Google.ProtocolBuffers.Collections;
using pbd = global::Google.ProtocolBuffers.Descriptors;
Now I do not find any DLL etc. in the release ZIP available on the project page, which I could include as reference in my C# project. Only protoc.exe and some *.proto file are there. My simple question is: Where do I get those assemblies?
(Remark: I tried to build the project protobuf-csharp-3.0.0-alpha-3 from sources following the instructions in the README file, but failed to build it with Visual Studio 2013 Update 4 "out of the box"; I get a number of compiler errors.)
After reading this and this documentation page I discovered that there is a possibility to install the Protocol Buffers NuGet package for my project by executing the following command in the Package Manager Console:
Install-Package Google.ProtocolBuffers
The console is accessible in Visual Studio 2013 via TOOLS --> NuGet Package Manager --> Package Manager Console. The manager downloaded the package and I got two references "Google.ProtocolBuffers" and "Google.ProtocolBuffers.Serialization" in my project which made the compiler happy. It works perfect now!