File: GettingStarted.html

package info (click to toggle)
gdata-sharp 2.2.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 12,092 kB
  • sloc: cs: 67,781; xml: 38,234; python: 163; makefile: 149; sh: 27
file content (155 lines) | stat: -rw-r--r-- 12,159 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!-- Links to Codesite stylesheet; for help in editing/previewing article only -->
<title>Getting Started with .NET</title>
<!-- Article Begins -->
<h1>Getting Started with the .NET Client Library</h1>
<em>Jeff Fisher, Google data APIs team
<br>July 2007</em>

<ul>
  <li><a href="#introduction">Introduction</a></li>
  <li><a href="#vs2005">Visual Studio 2005</a></li>

  <ul>
  <li><a href="#vssetup">Setting up your environment</a></li>
  <li><a href="#vscompile">Compiling and running samples</a></li>
  <li><a name="#vsdevelop"Developing your own application</a></li>
  <li><a href="#vsnunit">Running the NUnit tests</a></li>
  </ul>
  <li><a href="#mono">Mono</a></li>

  <ul>
  <li><a href="#monosetup">Setting up your environment</a></li>
  <li><a href="#monocompile">Compiling and running samples</a></li>
  <li><a name="#monodevelop"Developing your own application</a></li>
  <li><a href="#mononunit">Running the NUnit tests</a></li>
  </ul>
  <li><a href="#conclusion">Conclusion</a></li>

</ul>

<a name="introduction"><h3>Introduction</h3></a>

<div style="float: right; padding-bottom: 5px; padding-left: 5px;">
<img src="http://code.google.com/articles/support/gs.net/dotnetsolution.jpg" width="276px" height="336px" alt="The Google data API solution" style="border-style: solid; border-color: black; border-width: 1px;">
<br>
<b>Figure 1: The Google data API solution</b>
</div>

  <p class="para">For many developers, the most difficult part of a new project is getting the ball rolling&mdash;installing new software packages, configuring a development environment, and learning new libraries. In this article, I have pulled together some step-by-step instructions for how to begin with the .NET client library using either Visual Studio 2005 for Windows or Mono for Linux and other Unix operating systems. It is my hope that this will save you some time in getting started and let you quickly start working with some code.</p>

<a name="vs2005"><h2>Visual Studio 2005</h2></a>

<a class="para">If you do not already have Visual Studio 2005 installed, you may want to consider using <a href="http://msdn.microsoft.com/vstudio/express/visualcsharp/">Visual C# 2005 Express Edition</a>, a free version of Visual Studio that will allow you to work with the .NET client library.

<a name="vssetup"><h3>Setting up your environment</h3></a>

<ol>
   <li>Download the latest MSI release of the client library from <a href="http://code.google.com/p/google-gdata/downloads/list">http://code.google.com/p/google-gdata/downloads/list</a>.</li>
   <li>Run the downloaded MSI file to install the package. It will install to "C:\Program&nbsp;Files\Google\Google&nbsp;Data&nbsp;API&nbsp;SDK\" by default. Further examples in this article will assume you installed the client library to this location.</li>

   <li>Open the solution file called "Google Data API SDK" in the "Google Data API SDK" folder in the Start Menu.
      You will see the Conversion Wizard since this is a Visual Studio 2003 project file. Either click through the prompts or simply click on the "Finish" button. It should display the conversion log, which can be ignored.</li>
</ol>


<a name="vscompile"><h3>Compiling and running samples</h3></a>

<ol>
   <li>Verify that running "Build &gt; Build Solution" completes without any errors.</li>
   <li>To create a Debug build go to "Build &gt; Configuration Manager" and select "Debug" as the active solution configuration. Then select "Build &gt; Build Solution".</li>

   <li>The binaries and DLL files you have just compiled can be found in "C:\Program&nbsp;Files\Google\Google&nbsp;Data&nbsp;API&nbsp;SDK\clients\cs\src\VS2003\&lt;project&nbsp;name&gt;\bin\Debug\". For example, you can run the sample application for Calendar by executing "C:\Program Files\Google\Google&nbsp;Data&nbsp;API&nbsp;SDK\clients\cs\src\VS2003\Calendar\bin\Debug\Calendar.exe". There are also some Start Menu shortcuts to these samples.</li>
</ol>

<a name="vsdevelop"<h3>Developing your own application</h3></a>

<p class="para">If you want to develop in a project outside of the solution file provided by the MSI file, you need to add the client library DLL files as a reference path.

<ol>
  <li>Create or open a project outside of the Google API SDK solution.</li>
  <li>Select "Add Reference" from the Project menu.</li>
  <li>Click on the Browse tab.</li>
  <li>Navigate to the Redist directory in the SDK: "C:\Program&nbsp;Files\Google\Google&nbsp;Data&nbsp;API&nbsp;SDK\Redist".</li>

  <li>Select the DLL files that will be used by your code. Google.GData.Extensions.dll and Google.GData.Client.dll will be needed for most projects, along with the DLL file specific to the Google service(s) you are using in your application.</li>
</ol>


<p class="para"><strong>Note:</strong> There is also a solution file for client libraries on Mobile devices. It is found in "C:\Program&nbsp;Files\Google\Google&nbsp;Data&nbsp;API&nbsp;SDK\Sources\src\VS2005.mobile" by default. This solution will only compile the DLL files for the client libraries.</p>

<a name="vsnunit"><h3>Running the NUnit tests</h3></a>

<p class="para">Making sure the appropriate NUnit tests pass is an important step if you make any changes to the client libraries or plan to contribute to them. If you plan to use the client libraries without modifications then there is normally no need to run them.</p>

<ol>
   <li>Download the .NET 2.0 MSI file release of NUnit from <a href="http://www.nunit.org/index.php?p=download">http://www.nunit.org/index.php?p=download</a>.</li>
   <li>Install NUnit by running the MSI file. The default install location is similar to "C:\Program Files\NUnit 2.4.1". You may wish to change this to something like "C:\Program Files\NUnit" so you can upgrade NUnit in the future without having to change the path in your Visual Studio project.</li>
   <li>Go to the "C:\Program&nbsp;Files\Google\Google&nbsp;Data&nbsp;API&nbsp;SDK\Sources\src\VS2003" directory and open the solution file named "Google Data APIs with Unittests".
      You will see the Conversion Wizard since this is a Visual Studio 2003 project file. Either click through the prompts or simply click on the "Finish" button. It should display the conversion log, which can be ignored.</li>

  <li>Now NUnit must be added as a reference path. Right click on the "unittests" project in the Solution Explorer on the right and select "Properties". Now click on the "Reference Paths" tab within the window that opens. Enter in the location of the "bin" subdirectory of the NUnit installation as a reference path and click "Add Folder". For example, if NUnit is installed to "C:\Program Files\NUnit\", one would enter "C:\Program Files\NUnit\bin". Be sure to save this change before continuing.</li>
   <li>Follow the steps listed in <a href="#vscompile">Compiling and running samples</a> to rebuild the client library and the unit tests.</li>
   <li>Copy the "unittests.dll.config" file in "C:\Program&nbsp;Files\Google\Google&nbsp;Data&nbsp;API&nbsp;SDK\clients\cs\src\unittests" to your debug build directory "C:\Program&nbsp;Files\Google\Google&nbsp;Data&nbsp;API&nbsp;SDK\clients\cs\src\VS2003\unittests\bin\Debug\". Remember to edit the file to include the appropriate information for the tests you are running. For example, Base requires an API key and Calendar requires a username and password. It is recommended to use a test account without any live data to avoid having information deleted by the unit tests.</li>

   <li>Open NUnit from the Start Menu.</li>
   <li>Go to "File > Open Project" and select the "unittests.dll" file from "C:\Program&nbsp;Files\Google\Google&nbsp;Data&nbsp;API&nbsp;SDK\clients\cs\src\VS2003\unittests\bin\Debug\".</li>
   <li>Run the unit tests you are interested in. Remember that certain tests require parameters be set in unittests.dll.config to work. If you run the stress tests for certain services you may have your test account flagged as generating spam and be unable to programmatically submit content to Google servers without encountering CAPTCHA challenges.</li>
</ol>

<a name="mono"><h2>Mono</h2></a>

<p class="para"> Mono is a an open source project that allows you to run .NET client and server applications on Linux, Solaris, Mac OS X, Windows, and Unix. We offer a separate ZIP file of our client library for developers who want to work on one of these platforms.</p>

<a name="monosetup"><h3>Setting up your environment</h3></a>

<ol>
   <li>Download the latest ZIP file release of the client library from <a
     href="http://code.google.com/p/google-gdata/downloads/list">http://code.google.com/p/google-gdata/downloads/list</a></li>
   <li>Extract to a local directory (e.g. "/scratch/gdata.NET")</li>
   <li>Use your distribution's package management to install Mono.
   Alternatively, you can download it from <a
     href="http://www.mono-project.com">http://www.mono-project.com</a>.</li>

   <li>In some distributions you have to make sure that the nunit.framework.dll file is properly linked into the mono library. If mono was installed to "/usr/lib/mono", then ensure that there are symbolic links in "/usr/lib/mono/1.0" and "/usr/lib/mono/2.0" for nunit.framework.dll (which should be installed in "/usr/lib/mono/gac/nunit.framework/&lt;someversionstring&gt;/nunit.framework.dll").</li>
</ol>

<a name="monocompile"><h3>Compiling and running samples</h3></a>

<ol>
   <li>Assuming you installed the client library to "/scratch/gdata.NET", change to the "/scratch/gdata.NET/clients/cs" directory.</li>
   <li>Edit the Makefile depending on what version of .NET you wish to use. For .NET 1.x, use <code>CSC=mcs</code> and for .NET 2.x, use <code>CSC=gmcs</code>.</li>

   <li>Run <code>make</code> to compile the libraries and sample applications.</li>
   <li>Execute <code>make install</code> if you want to install the client library DLLs into the Mono library.</li>
</ol>

<a name="monodevelop"<h3>Developing your own application</h3></a>

<p class="para">If you executed a <code>make install</code> after compiling the client library, you should be able to include the libraries in your own code by passing <code>-r:Google.GData.Extensions.dll -r:Google.GData.Client.dll</code> to the Mono C# compiler along with references to the DLL files of any specific service extensions you wish to use.</p>

<a name="mononunit"><h3>Running the NUnit tests</h3></a>

<ol>
   <li>Copy the unittests.dll.config file from "/scratch/gdata.NET/clients/cs/src/unittests" to "/scratch/gdata.NET/clients/cs/".</li>
   <li>Edit "/scratch/gdata.NET/clients/cs/unittests.dll.config" to include the appropriate information for the tests you are running. For example, Base requires an API key and Calendar requires a username and password. I recommend using a test account without any live data to avoid having information deleted by the unit tests.</li>

   <li>After compiling the library there will be a unittests.dll file in "/scratch/gdata.NET/clients/cs". Use this DLL with your NUnit test manager of choice (nunit-console, gnunit, etc.).</li>
</ol>

<a name="conclusion"><h3>Conclusion</h3></a>

<p class="para">Now you should be able to compile the libraries and run the sample code. This is only the beginning, however. I encourage you to read through the documentation found in the ".../clients/cs/docs" directory of the client library. You might also want to check out the <a href="http://code.google.com/apis/gdata/client-cs.html">Developer's Guide</a>, the <a href="http://code.google.com/p/google-gdata/w/list">project wiki</a>, and the <a href="http://groups.google.com/group/google-help-dataapi">Google data API Developer Forum</a>.</p>

<p class="para">Tools referenced in this article:</p>
<ul>
  <li><a href="http://www.mono-project.com/Main_Page">Mono Project</a></li>
  <li><a href="http://msdn2.microsoft.com/en-us/vstudio/default.aspx">Visual Studio</a></li>
  <li><a href="http://msdn.microsoft.com/vstudio/express/visualcsharp/">Visual C# 2005 Express Edition</a></li>
  <li><a href="http://www.nunit.org/">NUnit</a></li>
</ul>

<p class="para">Good luck on your next .NET application!</p>


<!-- Article Ends -->