Sei sulla pagina 1di 29

New Possibilities

for Expanding

Your Skills with

Visual Studio

®
contents
New Possibilities for Expanding Your Skills with Visual Studio

2 Letter from the Editor

3 Visual Studio 2008: It’s Not Just for C# Anymore

3 11 11 Introducing Source Control

16 Picking Up Visual Studio From Eclipse

16 21 21 MSBuild Overview

25 Working with Subversion from Visual Studio


25
New Possibilities for Expanding Your Skills with Visual Studio

Letter from the Editor…


By Michael Pastore

A
wave of interoperability is sweeping over the IT as Python or PHP. It’s also not hard to imagine that a Java
industry, and it’s been building for some time. developer familiar with the Eclipse IDE needs to pick up
Those of us who write about and talk to soft- Microsoft’s Visual Studio to help develop .NET applications.
ware developers, systems administrators, and
hardware and software vendors know that many This eBook is going to explore some of interoperability and
of the silos that kept IT organiza- extensibility features available
tions dedicated to one vendor, to developers who use Visual
one operating system, or one Studio. First we’re going to
software development environ- examine how tools based on
ment are coming down. the extensible Visual Studio
Shell can provide a produc-
Given the state of the economy tive environment for dynamic
at the start of 2009, learning new languages such as Python and
skills and development environ- PHP. Then we’re going to help
ments can only help software de- those developers who have ex-
velopers. Consolidation at many perience building applications
organizations means developers on the Eclipse platform make an
might be asked to take on new easy transition to Visual Studio
projects that require familiar- so they can build on the .NET
ity with different languages and platform. We’re also going to
environments. And an expanded explore how developers can
set of skills is always a plus in work with a popular source
a tight job market, when flexibil- control system from the open-
ity and adaptability can make a source world, like Subversion,
developer stand out. in Visual Studio.

It’s not hard to imagine a scenario Read on to see how you can
where a software developer who ride the wave of interoperability
has dedicated his or her career to writing applications for the by expanding your skills and becoming a more well-rounded
.NET platform needs to work in a dynamic language such software developer.

… an expanded set of skills is always a plus in a tight job market,


when flexibility and adaptability can make a developer stand out.

2 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Visual Studio 2008:


It’s Not Just for C# Anymore
If you think Visual Studio is just for writing C#, think again. Visual Studio and tools
based on the extensible Visual Studio Shell can provide a productive environment
for dynamic languages such as Python and PHP.
By Steve Apiki

T
he universe of .NET development options has grown in recent years, expanding beyond C# and Visual Basic to
include dynamic languages such as Python, Ruby, and PHP. But where language choices have multiplied, tools
have lagged, so working with .NET dynamic languages has often meant dropping out of Visual Studio and into a
console or external editor.

That picture is starting to change, driven in part by third-party language support built on Visual Studio 2008 Shell. Visual
Studio Shell is a platform for building development tools based on the Visual Studio IDE. Visual Studio Shell runs in two
modes, isolated and integrated.

In isolated mode, the Video Studio Shell provides a stand-alone application environment based on Visual Studio but without
built-in languages. Developers can download the freely available shell along with a language package and work in the Visual
Studio IDE, even without access to Visual Studio itself.

When run in integrated mode, applications built on Visual Studio Shell drop in next to C# in an existing Visual Studio 2008
installation, Standard edition and above. Developers have access to new project types and can edit and debug dynamic
language projects alongside C# projects.

By installing language support packages, you can bring full support for several dynamic languages into Visual Studio 2008.
In this article, we’ll take a look at building applications in IronPython and PHP (Phalanger) using two Visual Studio Shell-
based packages, Iron Python Studio and the Visual Studio Integration package for Phalanger. Both IronPython Studio
and Phalanger’s integration package are available as free software, and both can be installed in either integrated or
isolated modes.

Visual Python: IronPython Studio


IronPython is the original .NET dynamic language, a Python implementation built on top of the .NET Common Language
Runtime (CLR). IronPython 2.0.x, the current version, is a refactoring of IronPython into a Python-specific language
component and a supporting Dynamic Language Runtime (DLR), which can be used as a common platform for IronRuby
and other dynamic languages.

3 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

IronPython Studio is an IDE for IronPython built on the Visual Studio Shell. It brings syntax highlighting, some intellisense, and
support for console, Windows Forms, and WPF project types to IronPython development. For .NET developers already work-
ing in Visual Studio, IronPython Studio is a bridge, a way to learn to work with dynamic languages on .NET without having to
learn a new set of development tools at the same time.

Installing IronPython Studio is a matter of downloading and running two installers, one for the Visual Studio shell, and one for
IronPython Studio itself. IronPython studio can be installed either in isolated mode (a stand-alone IDE) or in integrated mode
(where it integrates with Visual Studio 2008 standard and above). The IronPython Studio page on CodePlex includes links to
installers for both modes. The current release of IronPython Studio supports IronPython 1.1.1 only, so it is one major revision
behind IronPython itself (in addition to the DLR changes, IronPython 2.0 targets CPython 2.5 compatibility, while IronPython
1.x targets CPython 2.4).

Figure 1. IronPython Studio includes support for console, Windows Forms


and WPF project types.
Figure 1 shows the New Project dialog for IronPython Studio
running in integrated mode. To get started, let’s take a look
at building a simple console application with IronPython Stu-
dio. Choosing Console Application from the dialog creates
a new project with a starter Python file that prints a “Hello
World” string to the console. The code looks like this:

hello = “Hello VSX!!!”


print hello

Let’s make a couple of changes. We’ll add IronPython version information to the hello string, and a call to time.sleep()
after the print statement so that the console window hangs around long enough for us to see what’s going on. The new ver-
sion looks like this:

import sys
import time
hello _ string = “Hello from %s!” % sys.version
print hello _ string
time.sleep(10)

4 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Figure 2 shows the Visual Studio editor as we make these changes The screenshot nicely illustrates both syntax highlighting
and intellisense in IronPython Studio.

Figure 2. Intellisense and syntax highlighting in IronPython Studio.


Intellisense works for some Python library modules, but
not for all. As the screenshot shows, it works for sys.
It also works for time, the other module used in this
console example, but I found that intellisense didn’t work
for datetime in the editor.

Working with WPF


One of the coolest things about IronPython Studio is its solid support for WPF development. An IronPython Studio project
built from a WPF project template starts out with three files, the Python program file (Program.py), a XAML file (Window1.
xaml), and a second Python file (Window1.py) that links the two.

You can edit the XAML using the regular Visual Studio WPF Designer. Window1.py defines a Python class that loads the
XAML into a WPF window object accessible through Python. At startup, the application instantiates that window class to
create the program’s main window.

Program.py is the main application file. The template code is shown in listing 1.
Listing 1: WPF application main file, as generated by the IronPython Studio WPF template.

from System import *


from System.IO import *
from System.Windows import *
from Window1 import *

class WpfApplication2App: # namespace


@staticmethod
def RealEntryPoint():
a = Application()
window1 = WpfApplication2.Window1()
a.Run(window1.Root)

if _ _ name _ _ == "Program":
WpfApplication2App.RealEntryPoint(); continued

5 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

In listing 1, WpfApplication2.Window1 is the class imported from Window1. The Root object is the WPF window that is
passed as the main window to the WPF application.

Starting from the generated project, you can add controls to the XAML using the WPF Designer and set up the program logic
in your Python file. As an example of how you can customize the starter files, listing 2 shows a modified Program.py for an
example application that counts button clicks.
Listing 2: The WPF main application file with a modified application class.

from System import *


from System.IO import *
from System.Windows import *
from Window1 import *

class MyApp(Application):

def _ _ init _ _ (self):


self.click _ count = 0
Application. _ _ init _ _ (self)

def Run(self, w):


""" set up event handlers and then
run the application.
"""
self.btnCounter = w.Content.FindName("btnCounter")
self.txtMessage = w.Content.FindName("txtMessage")

self.btnCounter.Click += self.buttonClick

Application.Run(self,w)

def buttonClick(self, f,i):


self.click _ count += 1
self.txtMessage.Text = \
"You clicked the button %d times."%self.click _ count

class WpfApplication2App: # namespace

@staticmethod
def RealEntryPoint():
a = MyApp()
window1 = WpfApplication2.Window1()
a.Run(window1.Root)

if _ _ name _ _ == "Program":
WpfApplication2App.RealEntryPoint();

6 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

In Listing 2, we derive our own application class (MyApp) which stores references to controls and sets up an event handler
before calling the base class. Each time the button is clicked, the code uses the reference to the text box to set a new
message that shows the updated click count.

IronPython Studio provides debugging support for IronPython applications. Figure 3 shows the click counting application
running in the debugger.

Figure 3. Examining local variables in an IronPython program in the


Visual Studio debugger.
In the debugger, you have all the expected functions: you
can set breakpoints, step through code, and inspect vari-
ables. However, only static variables are visible; dynamically
created Python objects are not. For example, while you can
view f and self (the button and the MyApp object), you can’t
view self.click_count.

PHP, Phalanger and Visual Studio Integration


Phalanger is a PHP compiler for the .NET virtual machine. With Phalanger, you can use PHP to write console and Windows
Forms applications as well as .NET-based web sites.

You can download Phalanger from its Codeplex page. For Visual Studio integration, you must download and install the Visual
Studio integration package for Phalanger as well as the compiler proper. As with IronPython Studio, you have the choice of
installing Phalanger in integrated or in isolated mode.

With Phalanger installed in integrated mode, the Visual Studio New Project dialog acquires some additional project types
(figure 4). You can use these templates as starting points for building console applications, Windows Forms applications, and
class libraries in PHP.

You can use Phalanger both to build client applications and for web development, so there are web project templates as well.

7 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Figure 4. Phalanger integration project templates in Visual Studio.

Figure 5 shows the web project options available with Phalanger.


Figure 5. PHP web site templates installed with Phalanger.

Phalanger supports web development through one of several


methods. First, you can build a traditional server-side PHP
site. (It’s only the server-side model that’s “traditional”-- run-
ning on the CLR and having access to the .NET framework
from PHP is definitely pretty radical.) You can also write
Silverlight client-side applications with Phalanger. Finally,
you can use PHP as the code-behind language for ASP.NET
projects. We’ll focus on server-side PHP as we explore
Phalanger’s Visual Studio integration, below.

The Phalanger PHP Web project generates two files, a web.config and a default.php.
The PHP file contains just:

<?
echo “Hello World!”;
?>

Start this up and you can see “Hello World” in a browser. Let’s add a little bit to that. With Phalanger, you have access to
classes in the .NET framework. That makes it possible to write code like that in listing 3, which uses the .NET WebClient to
fetch some data from an XML web service, and then uses PHP to parse it and display it in an HTML table.

8 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Listing 3. A PHP page that uses the .NET framework to access a web service.

<?php
import namespace System;
import namespace System:::Net;

$uri=new Uri("http://services.devx.com/outgoing/dotnet.xml");

$client = new WebClient;


$xml _ string = $client->DownloadString($uri);

$xml = simplexml _ load _ string($xml _ string);

// display the list of articles.


echo $xml->channel->title;
echo "<table>";
foreach ($xml->channel->item as $item) {
echo "<tr>";
echo "<td>".$item->title."</td>";
echo "<td>".$item->description."</td>";
echo "</tr>";
}
echo "</table>";
?>

Phalanger’s Visual Studio integration provides syntax highlighting, but no intellisense. The code in listing 3 is shown as
colored by Visual Studio.

There are two ways to refer to .NET framework classes in Phalanger. You can say:

System:::Uri

or import the namespace as shown in the listing:

import namespace System;

and then just refer to the class without qualification (e.g., Uri). Note that to use the import method you need to edit the default
web.config generated by Phalanger to include “PhpClr” in the “LanguageFeatures” section.

Phalanger works with the Visual Studio debugger, supporting interactive debugging of PHP programs. Figure 6 shows the
example PHP program stopped at a breakpoint. From this point you could step through the program, inspect variables, or set
additional breakpoints as usual. From the locals window, you can see the value of all of the current script variables through the
GlobalVariables array.

9 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Figure 6. A Phalanger program running in the Visual Studio debugger. New Languages, Familiar Tools
Every programming language has its strengths, and a
domain in which it’s the right tool. Every programming
language that’s been around long enough also has an
installed base. In a perfect world, you could choose the
language based on the task and deploy your program on
every platform.

We’re not there yet, but having support for a variety of


languages, including dynamic languages, on the .NET
platform is a step in the right direction. Part of that support
is having robust tools, such as the Visual Studio IDE, for
every .NET language. IronPython Studio and Phalanger are
good examples of what’s possible for dynamic languages
in Visual Studio.

* This article was commissioned by and prepared for Microsoft Corporation.


This document is for informational purposes only. MICROSOFT MAKES NO
WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.
Steve Apiki is senior developer at Appropriate Solutions, Inc., a Peterborough, NH
consulting firm that builds software solutions at every layer in the stack using a variety
of tools. Steve has been writing about software and technology for over 15 years.
steve.apiki@gmail.com

10 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Introducing
Source Control
Visual Studio supports source control using the Visual Studio Integration Protocol (VSIP)
layer in its Integrated Development Environment (IDE). VSIP can host a variety of source
control packages, usually implemented as plug-ins written to the appropriate protocols.
An example of a source control plug-in is the SourceSafe LAN plug-in supported by
Visual SourceSafe. For details of this plug-in, see the Visual SourceSafe Help.

V
isual Studio source control is simply an envi- Basics of Source Control Support
ronment for third party source control plug-ins. in Visual Studio
Therefore its functionality is only activated by
installation of a plug-in. To use a third-party source Basic source control support in Visual Studio includes
control plug-in, you must usual- setting of source control plug-in and en-
ly install the third party application and/or the vironment options, plug-in switching, da-
source control plug-in(s) on the client and tabase access, and versioning for and
server machines for your site. Once they have
Note: manipulation of Visual Studio projects,
been installed as indicated by the third party Visual Studio refers solutions, and files and associated meta-
instructions, their functionality will be avail- to source control data. Source control in Visual Studio also
able through Visual Studio. The operations packages as plug-ins, enforces protocols for the control of database
that are enabled are variable, depending on although they can be accesses, for example, the Lock-Modify-Un-
the source control plug-in. You must see your implemented as other lock work style, in which a user who wants to
third party documentation for package-spe- types of software modify a file must check it out exclusively.
cific operational details. modules.
It is important to remember that you should
See “Overview (Source Control)” in the Visual use source control in Visual Studio mecha-
Studio Help for design details of source control in Visual Studio. nisms to interact with a source control plug-in. Do not use other
This section of the Help also provides all the information you will client applications presented by the third party furnishing the
need for developing a third-party source control package that is plug-in, for example, Visual SourceSafe Explorer. Proper use
compatible with Visual Studio. of the source control mechanisms in Visual Studio ensures
that only correct files are added to source control and that your
Visual Studio project and solution files are updated with the
correct plug-in-specific details.
* This article originally appeared on MSDN at
http://msdn.microsoft.com/en-us/library/ms171339.aspx

11 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Source Control Plug-in Configuration • Solution files (*.sln).


and Switching • Project files, for example, *.csproj, *.vbproj files.
Visual Studio source control supports configuration and plug-
in switching through the Source Control entry in the Options • Application configuration files, based on XML, used to
dialog box. This entry is accessible by selecting Options on the control run-time behavior of a Visual Studio project.
Tools menu of Visual Studio. You will use the Options dialog
box to select the plug-in that you want to use for source control, Files that you cannot add to source control
and set up environment options for that plug-in. include the following:

Before you and your team can take advantage of source control • Solution user option files (*.suo).
features in the Visual Studio IDE, you must:
• Project user option files, for example, *.csproj.user,
• Determine if any source control plug-ins are available. *.vbproj.user files.

• If the source control plug-in that you want to use is not • Web information files, for example, *.csproj.webinfo,
installed on your computer, install the third-party product *.vbproj.webinfo, that control the virtual root location
that supports the plug-in and restart Visual Studio to of a Web project.
register it.
• Build output files, for example, *.dll and *.exe files.
• Create a source control database according to the
functionality of the particular plug-in. Namespace Change Propagation
• Send a link to the database location to all team members. Visual Studio source control supports namespace change
propagation in source control plug-ins. Change propagation
applies to delete, rename, and move operations. When you
Database Access
request an operation for which change propagation is enabled,
Basic database access commands, for example, Check Out the source control plug-in changes your working copy of the
and Add to Source Control, are available in the File menu of source-controlled item, the master copy in the database, and
Visual Studio. However, these commands are only activated the copies of other users when you check in the item and the
after you have chosen the source control plug-in that you other users retrieve it.
want to use. When you use one of the basic database access
commands, the plug-in that you have chosen invokes the
How Source Control Handles Solutions and
corresponding third-party functionality and/or environment to
complete the associated operation. Projects
When you add a solution or project to source control, the first
Some access operations are active with only the plug-in thing a source control plug-in must do is identify a unified root
selected, while other operations are only available when you for the item being added. This root is a path to the parent di-
have also selected a Visual Studio project, solution, or file in rectory for all working folders and files making up the solution
Visual Studio’s Solution Explorer. For example, you can use or project.
an Add to Source Control command once you have chosen a
plug-in. However, to use a Check In command, you must have A unified root generally maps to a physical path on disk. How-
an item selected in Solution Explorer. ever, if a solution contains files or projects that reside on more
than one disk drive, there is no physical folder to which a uni-
File Handling by Source Control fied root can map. A solution can span drives but a source
You can add the following files to Visual Studio control unified root cannot. To support this situation, Visual
source control: Studio source control supports the concept of a super-unified
root. This type of root is a virtual container beneath which all

12 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

projects and files in a source-controlled solution are located. Views of a Solution or Project
When you add a solution using a source control plug-in with
Visual Studio provides three distinct views of a source-con-
advanced capabilities, the plug-in creates an empty solution
trolled solution or project: design, source control, and physi-
root folder in the database. This folder will contain all items
cal. Many source control tasks are easier to perform when
in a source-controlled solution. By default, this folder is
there is a one-to-one mapping between the individual ele-
<solutionname>.root.
ments of these views. However, if you create your solutions
and projects and add them to source control using the default
settings in Visual Studio, your solutions and projects will not
necessarily be organized in the same way on disk as they are
Note: in Solution Explorer and in the database.
When you add a single project to source
control, a .root folder is not created. The design view of a solution or project, which you see in
Solution Explorer, is a logical depiction of the contents of
a solution or project. Generally, the design view is tidy and
meaningful. Unnecessary files are hidden and files from many
Use of the solution root provides the following benefits: different physical locations are pressed into a single project
container.
• Fewer Prompts. The solution root minimizes the potential
number of source control bindings for a solution and thus The source control view of a solution or project, which you
minimizes user prompts when you add a solution to
see in a standalone application, such as Visual Source-
source control and perform other tasks.
Safe Explorer, is also a logical view of a solution or project.
• Project Encapsulation. The solution root ensures that all However, the source control view is not necessarily a
projects in a solution can be readily identified as belonging reflection of the logical view.
together, even when one or more of the projects reside
on different partitions or computers. The physical view of a solution or project, which you see in
Windows File Explorer, is unlikely to reflect the hierarchical
You can disable the creation of the <solutionname>.root folder, structure of either the logical or the source control view.
but doing so is not recommended. For more information, see
How to: Disable Creation of the <solutionname>.root Folder. The following guidelines can help you achieve organization-
al fidelity between the design, physical, and source control
Solutions in Visual Studio are either well-formed or not. A well- views of your source-controlled solutions and projects:
formed solution is one for which the hierarchical structure on
disk matches its structure in Solution Explorer. All projects in • Create a blank solution first, and then add projects
a well-formed solution are stored in subfolders of the solution to it. This helps you maintain the logical parent-child
relationship between a solution and its projects in
folder on disk. If the solution is well-formed when you add it to
storage. When you then add the solution to source
source control, the source control plug-in creates a folder be-
control, the source control view and design view
neath *.root folder to contain the master copies of the solution will both mirror the solution hierarchy on disk.
file (*.sln) and solution user option files (*.suo) for the solution.
Finally, the source control plug-in creates a folder beneath • Give each solution a unique and descriptive name that
the .sln folder for each additional project in the source control differs from the name of each of the contained projects.
database. • Avoid adding link files to a source-controlled solution
or project.
If a solution is not well-formed, the source control plug-in cre-
ates a folder for the solution and its initial project. Then fold- • If possible, store all files in a solution or project on one
ers for each additional project are created in parallel to the disk drive.
solution folder.

13 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Source Control Connections and Bindings You can create a multi-project solution with a single binding
by creating a blank solution before adding its projects. You
Visual Studio defines a connection as a live data link between
can also do this by selecting the Create Directory for Solution
Visual Studio and a database server. When you add a solution
option in the New Project dialog box when creating a solution-
or project to source control, your source control plug-in cop-
project pair.
ies the item and all of its contents from disk into the database.
One source control folder is created for each folder contain- If you create a solution-project pair in one step and do not
ing a solution or project file. After adding the item, the source select the Create Directory for Solution option in the New
control plug-in binds your local working copy of a solution or Project dialog box (off by default), a second binding will be
project to its version in the database. created when you add a second project to the solution. One
binding is created for the initial project and the solution. Ad-
Every source-controlled solution has at least one source con-
ditional bindings are created for each additional project.
trol binding. However, an item can have multiple bindings and
require multiple connections to the database. The number of
bindings and connections depends on how you create the so- Source Control Terminology
lution initially and whether or not its projects and files are all The Visual Studio documentation uses a number of terms to
saved on the same partition. describe source control features and concepts. The following
table defines some of the common terms.
As an example of bindings and connections, think of a well-
formed source-controlled solution, with multiple projects, as Basis version
a house with several rooms. When you build the house, you The server version of a file from which a local version
can install a single high-speed data line from one room to the is derived.
street. You install a router behind a firewall to distribute the
data feed to other rooms and you pay an Internet service pro- Binding
vider to connect your house to the Internet. Information that correlates a working folder for a solution
or project on disk to its folder in the database.
You might think of a source control binding as representing
the single data line created for the house. When you open Branching
a source-controlled solution, a connection is created across Process of creating a new version, or branch, of a shared
that binding. The connection establishes a handshake be- file or project under source control. Once a branch has
tween your working copy of the solution on disk and the mas- been created, the two versions under source control will
ter copy of the solution in the database. have a shared history up to a certain point and divergent
histories after that point.
If a source-controlled solution is not well-formed, you can look
at it like a house in which every room is connected to the Inter- Conflict
net directly. Internet charges are more expensive than in the Two or more different changes to the same line of code in
single-connection house, maintenance costs are higher, and situations where two or more developers have checked
switching to a different Internet service provider is much more out and edited the same file.
difficult and time-consuming.
Connection
Ideally, a solution and its projects share a single source con- A live data link between a source control client
trol binding. Single-binding solutions are more manageable (for example, Visual Studio) and a source control
than multiple-binding solutions. They are easier to: database server.
• Disconnect from source control in order to work offline. Database
• Connect to the database after reconnecting to
Location where all master copies, history, project
the network. structures, and user information are stored. A project
is always contained within one database. Multiple
• Branch in one step.

14 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

projects can be stored in one database, and multiple Unified root


databases can be used. Other terms commonly used A path to the parent directory for all working folders and
for a database are repository and store. files in a source-controlled solution or project. For example,
C:\Solution is the unified root of a source-controlled
History solution containing files that are located in
Record of changes to a file since it was initially added C:\Solution, C:\Solution\ProjOne and
to source control. With version control, you can return C:\Solution\ProjTwo.
to any point in the file history and recover the file as it
existed at that point. Working folder
Location where your local copies of source-controlled
Label items are stored, usually on your own computer. Another
User-defined name attached to a specific version of term for a working folder is workspace.
a source-controlled item.

Local copy
File in a user’s working folder to which changes are
saved until a check-in occurs. A local copy is sometimes
referred to as a working copy,

Master copy
The most recently checked-in version of a source-
controlled file, as opposed to the local copy of
a file in your working folder. Other terms for master
copy are server version and database version.

Merging
Process of combining differences in two or more modified
versions of a file into a new file version. Merging can
affect different versions of the same file or changes made
to the same file version.

Shared file
A file having versions that reside in more than one source
control location. Other terms for a shared file are copy
and shortcut.

Solution root
An empty folder in a database that contains all items in
a source-controlled solution. By default, this folder is
<solutionname>.root.

Super-unified root
A virtual container beneath which all projects and files
in a source-controlled solution are located. For example
[SUR]:\ is the super-unified root of a source-controlled
solution containing projects that are located in
[SUR]:\C:\Solution\ProjOne and
[SUR]:\D:\ProjTwo.

15 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Picking Up Visual Studio


From Eclipse
For Java developers, building on the .NET platform may mean new tools as
well as a new language. If you’re familiar with Eclipse, but just getting started on .NET
with Visual Studio, we’ve got a few pointers to ease the transition.
By Steve Apiki

M
icrosoft® Visual Studio® 2008 is the premier targets a single .NET assembly. As in Eclipse, you’ll generally
development environment for .NET®, supporting keep files in a Visual Studio project within a corresponding
.NET application development with deep folder in the file system, although you can instead choose to
platform integration and specialized .NET tools. add linked files that reside elsewhere.
Eclipse is a flexible, modular IDE that sup-
ports development in a variety of languages on a number In Visual Studio, projects are always further contained within
of platforms through plug-ins, Visual C#® on .NET among solutions. Solutions are at the same logical level as Eclipse
them. As a seasoned Eclipse developer targeting the .NET workspaces (that is, they both contain projects) but they re-
platform, you can choose to stick with Eclipse or opt to leap in ally represent differing approaches to project organization. An
and learn Visual Studio to take advantage of its platform focus. Eclipse workspace captures a single developer’s entire work-
In this article we’ll explore the second option, both pointing out ing environment, containing both projects and user-specific
some of the ways in which Visual Studio differs from Eclipse settings. Switching between workspaces is a fairly heavy op-
and introducing some of its .NET-specific capabilities. eration, and developers may keep unrelated projects together
in a single workspace. In Eclipse, you can copy user prefer-
If you’ve not tried Visual Studio, you can find evaluation ences from one workspace to the next if you want to maintain,
versions here. From a day-to-day development point of view, for example, the same view layout between workspaces.
Visual Studio and Eclipse are more alike than different. There
are differences in key bindings and default window layouts, In contrast, Visual Studio solutions serve to group related
of course, but we won’t get down to that level of detail in this projects. For example, a solution may include a main applica-
overview. For most common operations in the editor and de- tion assembly and a library upon which it depends. Through
bugger, Eclipse skills transfer pretty readily to Visual Studio. the solution’s properties you can specify project dependen-
cies and build order, which specify how projects are related.
Project Organization Visual Studio solutions are independent of the filesystem and
may relate projects from different directories.
For both Visual Studio and Eclipse, the fundamental unit of
organization is the project. In an Eclipse Java project, this may One thing that Eclipse developers may find very different in
contain a number of related Java classes which can be export- Visual Studio is that you always work at the solution level. In
ed as a JAR for deployment. In Visual Studio, each project file Eclipse, if you work on four unrelated projects, they may all be

16 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

in the same workspace and you may simply switch between Figure 1. The Visual Studio Solution Explorer showing a solution with two
them. In Visual Studio, you would have four separate solution related projects.
files, each containing a single project, and you would open
and close solutions, not projects. As you work with a single
project, none of the other (unrelated) projects would appear
in the environment at the same time.

In Visual Studio, you set up run and debug configurations


at the solution level as well. If you click build or start the
debugger, you’ll just use the current active solution configura-
tion. The solution configuration in turn references individual
project configurations, which are where you set individual build
properties.

Because Visual Studio solutions don’t contain developer-


specific settings, they can be easily managed through source
control. Solutions are actually stored in two types of files, .sln
files and .suo files. .sln files contain the project information
and can be shared between developers, while .suo files con-
tain user-specific information related to the solution.

Environment settings and preferences are handled separately,


through the Import and Export Settings Wizard, accessible
through the Tools menu. Through the settings wizard, you can
import or export selected settings, or completely reset your
environment to a default configuration (like opening a new
workspace).

There are a number of environment options you can set that


determine the way Visual Studio works with and displays
projects and solutions. These are found in the Options dialog,
also under the Tools menu. To best see the solution and proj-
ect structure, be sure that the “Always Show Solution” setting The Solution Explorer roughly corresponds to the Package
is checked, so that the solution is shown explicitly even for Explorer in Eclipse. Both show entries for each file in each
single-project files. project, plus framework classes referenced by each project.
However, the Solution Explorer is strictly file-oriented, where
Figure 1 shows the Visual Studio Solution Explorer, which in Package Explorer you can click down to the level of individ-
shows a hierarchical view of a solution and the projects ual classes and class members. To see the equivalent class
it contains. In the screenshot, WpfProject1 is the startup information in Visual Studio, you can open the Class View,
project (in bold). It depends on the control library which opens by default on a tab next to Solution Explorer.
WpfControlLibrary1, so Visual Studio will ensure that the
library is always up to date before building the application.

17 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Background Compilation
Eclipse can compile Java code in the background, allowing it to immediately flag both syntactic and semantic errors as you
are working in the editor. Eclipse also generally does not require an explicit build step, as the project is automatically kept
up-to-date.

Visual Studio has always had background compilation for Visual Basic, but until recently (Visual Studio 2008 SP 1) you
couldn’t see semantic errors in C# without first compiling the source. With the latest service pack, Visual Studio includes sup-
port for Live Semantic Errors in C#, giving you semantic error highlighting capabilities in the editor. This isn’t full background
compilation for C#, but it will detect semantic errors such as undeclared types or incorrect parameter types. If you’re an
Eclipse developer and accustomed to background error checking, be sure you’re working with the latest service pack release
of Visual Studio 2008.

Figure 2 shows semantic error detection in Visual Studio. The error is shown in the editor, highlighted by a red squiggly line.
It shows up immediately as you type the expression. The error here is that the argument “e” handed to XDocument.Parse is
of the wrong type (I should have typed, “e.Result”). This is a class of error that would only have been detected after explicit
compilation in previous releases.

Figure 2. Detecting semantic errors as you type in the latest Visual Studio 2008.

.NET-Specific Tools
Visual Studio includes two .NET-specific tools that will be new to Eclipse developers coming from other platforms. It’s important
to be aware of these tools as they are a significant benefit of using an IDE tuned for .NET development.

There are as many styles of working with Eclipse as there are plug-ins. Some Eclipse developers may use window designer
plug-ins when building SWT or Swing GUI applications, while others prefer to create windows in code. In Visual Studio, the
window designers both for Windows forms and WPF applications are fully integrated with code editors, and you’ll generally use
the designer when creating GUI applications.

18 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Visual Studio’s WPF Designer (figure 3) is a specialized tool that really helps to simplify WPF and Silverlight development.
The WPF designer lets you either work in XAML code, in a text editor, or graphically add and edit controls in the designer
window. Changes you make in one editor automatically synchronize with both the other view and with the properties window.
You can also create event handlers in the designer or the properties view and switch over to the C# editor to fill in the event
handler stub.

Figure 3. Visual Studio’s WPF Designer lets you build screens through the GUI designer or edit XAML directly.

19 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Visual Studio 2008 also includes a graphical tool for setting up LINQ to SQL classes called the Object Relational Designer (O/R
Designer). To use the O/R designer, you drag database objects from the server onto an O/R “design surface.” Visual Studio
then generates the mapping between those database objects and LINQ to SQL classes. You can then refer to those classes in
LINQ queries in your C# code. LINQ is also supported by the Visual Studio debugger, allowing you to see both generated SQL
and results for LINQ queries in the watch window.

Differing Approaches
It can be tough to get comfortable in a new IDE. There are new Visual Studio features to learn that aren’t in Eclipse, and some
Eclipse features for which there are no Visual Studio equivalents. There are also clearly some differences in the ways in which
Visual Studio and Eclipse approach project organization. All the same, Eclipse developers should face a fairly shallow learning
curve in picking up Visual Studio because of similarities in core editing and debugging operations.

* This article was commissioned by and prepared for Microsoft Corporation. This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES,
EXPRESS OR IMPLIED, IN THIS SUMMARY.
Steve Apiki is senior developer at Appropriate Solutions, Inc., a Peterborough, NH consulting firm that builds software solutions at every layer in the stack using a variety of
tools. Steve has been writing about software and technology for over 15 years. steve.apiki@gmail.com

20 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

MSBuild Overview
The Microsoft Build Engine (MSBuild) is the new build platform for Microsoft and
Visual Studio. MSBuild is completely transparent with regards to how it processes
and builds software, enabling developers to orchestrate and build products
in build lab environments where Visual Studio is not installed.

This topic provides brief overviews of:


• The basic elements of an MSBuild project file.

• How MSBuild is used to build projects.

• The advanced features of MSBuild.

• How Visual Studio uses MSBuild to build projects.

Project File
MSBuild introduces a new XML-based project file format that is simple to understand, easy to extend, and fully supported by
Microsoft. The MSBuild project file format enables developers to fully describe what items need to be built as well as how they
need to be built with different platforms and configurations. In addition, the project file format enables developers to author
re-usable build rules that can be factored into separate files so that builds can be performed consistently across different
projects within their product. The following sections describe some of the basic elements of the MSBuild project file format.

Items
Items represent inputs into the build system and are grouped into item collections based on their user-defined collection
names. These item collections can be used as parameters for tasks, which use the individual items contained in the collection
to perform the steps of the build process.

This article originally appeared on MSDN at


http://msdn.microsoft.com/en-us/library/ms171452.aspx

21 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Items are declared in the project file by creating an element with the name of the item collection as a child of an ItemGroup
element. For example, the following code creates an item collection named Compile, which includes two files.

<ItemGroup>
<Compile Include = “file1.cs”/>
<Compile Include = “file2.cs”/>
</ItemGroup>

You reference item collections throughout the project file with the syntax @(ItemCollectionName). For example, you reference
the item collection in the example above with @(Compile).

Items can be declared using wildcards and may contain additional metadata for more advanced build scenarios. For more
information on items, see MSBuild Items.

Properties
Properties represent key/value pairs that can be used to configure builds. Items and properties differ in the following ways:

• Items are stored in collections, while properties contain a single scalar value.

• Items cannot be removed from item collections, while properties can have their values changed after they are defined.

• Items can contain metadata and can use the %(ItemMetadata) notation, while properties cannot.

Properties are declared by creating an element with the name of the property as a child of a PropertyGroup element. For
example, the following code creates a property named BuildDir with a value of Build.

<PropertyGroup>
<BuildDir>Build</BuildDir>
</PropertyGroup>

You reference properties throughout the project file with the syntax $(PropertyName). For example, you reference the property
in the example above with $(BuildDir). For more information on properties, see MSBuild Properties.

Tasks
Tasks are reusable units of executable code used by MSBuild projects to perform build operations. For example, a task might
compile input files or run an external tool. Once created, tasks can be shared and reused by different developers in different
projects.

The execution logic of a task is written in managed code and mapped to MSBuild with the UsingTask element. You can write
your own task by authoring a managed type that implements the ITask interface. For more information on writing tasks, see
How to: Write a Task.

MSBuild ships with many common tasks such as Copy, which copies files, MakeDir, which creates directories, and Csc,
which compiles Visual C# source code files. For a complete list of available tasks and usage information, see MSBuild
Task Reference.

22 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

You execute a task in an MSBuild project file by creating an element with the name of the task as a child of a Target element.
Tasks usually accept parameters, which are passed as attributes of the element. MSBuild item collections and properties
can be used as parameters. For example, the following code calls the MakeDir task and passes it the value of the BuildDir
property declared in the previous example.

<Target Name=”MakeBuildDirectory”>
<MakeDir
Directories=”$(BuildDir)” />
</Target>

For more information on tasks, see MSBuild Tasks.

Targets
Targets group tasks together in a particular order and expose sections of the project file as entry points into the build process.
Targets are often grouped into logical sections to allow for expansion and increase readability. Breaking the build steps into
many targets allows you to call one piece of the build process from other targets without having to copy that section of code
into each target. For example, if several entry points into the build process require references to be built, you can create a
target that builds references and run that target from every necessary entry point.

Targets are declared in the project file with the Target element. For example, the following code creates a target named
Compile, which then calls the Csc task with the item collection declared in the previous example.

<Target Name=”Compile”>
<Csc Sources=”@(Compile)” />
</Target>

In more advanced scenarios targets can describe relationships between each other and perform dependency analysis, which
allows whole sections of the build process to be skipped if that target is up-to-date. For more information on targets, see
MSBuild Targets.

Building with MSBuild


You run MSBuild from the command line by passing a project file to MSBuild.exe with the appropriate command line options.
Command line options allow you to set properties, execute specific targets, and specify loggers. For example, you would use
the following command line syntax to build the file MyProj.proj with the Configuration property set to Debug.

MSBuild.exe MyProj.proj /property:Configuration=Debug

For more information on MSBuild command line options, see MSBuild Command Line Reference.

Security Note:
Before you build a downloaded project, determine the trustworthiness of the code.
MSBuild project files have the ability to execute tasks that can damage your system.

23 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Advanced concepts
MSBuild can be used for more advanced operations during builds, such as logging errors, warnings, and messages to the
console or other loggers, performing dependency analysis on targets, and batching tasks and targets on item metadata. For
more information on these advanced concepts, see MSBuild Advanced Concepts.

Visual Studio Integration


Visual Studio uses the MSBuild project file format to store build information about managed projects. Project settings added
and changed through Visual Studio are reflected in the .*proj file that is generated for each project. Visual Studio uses a
hosted instance of MSBuild to build managed projects, meaning that a managed project can be built in Visual Studio and from
the command line (even without Visual Studio installed), with identical results. For more information on how Visual Studio uses
MSBuild, see MSBuild Advanced Concepts.

24 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Working with Subversion


in Visual Studio
Subversion is not only among the most popular source control systems for
open-source development, it’s also an attractive option for any project maintained
by a distributed team. Subversion clients built on Visual Studio’s source control
package model, such as open-source AnkhSVN, offer deep integration
between Subversion and the Visual Studio IDE.
By Steve Apiki

S
ubversion may be most familiar as the preferred Subversion
version control system of the open-source com-
Subversion is a centralized version-control system (VCS)
munity, but it’s more than just a way to check out
designed as the successor to Concurrent Versions System
the latest develop-
(CVS). It works on the “copy
ment sources from
modify merge” model, so devel-
your favorite open-source proj-
opers generally edit files without
ect. For projects that span multi-
obtaining exclusive locks and
ple platforms and cross develop-
then merge changes back into
ment environments, Subversion
the file in the central repository.
is an excellent version control
Subversion tracks changes to
option. It’s free software that’s
directories as well as changes
well-supported and well-tested
to files, so if you delete a file on
by a huge user base, has the es-
the client and then commit that
sential features (such as atomic
change, that file will be removed
commit), and integrates well with
from other client systems at the
tools on a variety of clients.
next update.
There are a number of Subver-
Changes in Subversion are
sion plug-ins for Microsoft®
tracked by revisions. Every com-
Visual Studio®. CollabNet, the
mit, which may contain changes
company that started the Subver-
to one or more files or directo-
sion project, supports an open-
ries, creates a new revision.
source plug-in for Visual Studio
When you commit a change,
called AnkhSVN. The latest ver-
you enter a single comment that
sion of AnkhSVN, AnkhSVN
is applied to the revision, not to
2.0, works with Visual Studio
an individual file. Subversion’s commit operation is atomic--
2005 and Visual Studio 2008, bringing Subversion client
that either all changes are applied or that none are applied (if
tools directly into the Visual Studio IDE.
the operation fails).

25 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

By default, Subversion doesn’t modify line endings in the re-


pository. This makes it possible to include binary files in source
control (Subversion also supports optional locking, which CollabNet Desktop for Visual Studio
you’ll also want for binary files since they can’t be merged). vs. AnkhSVN
You can change line-ending behavior on a per-file basis by
setting a Subversion property on a text file that tells the server CollabNet Desktop for Visual Studio is a collection of cli-
that line endings should be converted on check-out. ent tools that provide access to CollabNet’s full development
platform from within the Visual Studio IDE. In addition to
Subversion supports both branching and tagging through a Subversion for source code control, CollabNet’s platform
copy operation, effectively creating a snapshot of the trunk. includes SourceForge Enterprise Edition and CollabNet
Tags are snapshots that shouldn’t be modified; branches are
Enterprise Edition for issue tracking and application
snapshots used as the starting point for further changes.
lifecycle management, and CollabNet Cubit for management
Although creating a tag “effectively” creates a snapshot it
and provisioning of cloud-based hardware pools for
doesn’t actually copy the files, so branching and tagging are
fast operations. development and testing.

The Subversion sever can communicate with the client over CollabNet Desktop for Visual Studio doesn’t actually
several transports. Generally, when you check items out include a Subversion client. Instead, CollabNet bun-
from a public repository, it’s through a URL with an http:// or dles AnkhSVN alongside CollabNet Desktop to provide
https:// scheme. Subversion also supports direct filesystem Subversion client functionality. If all you are looking for is
access to the repository through file://, unencrypted access CollabNet’s Subversion client for Visual Studio, then stand
through svn://, and encrypted access through svn+ssh:// (the aloneAnkhSVN is the ticket. On the other hand, if you want
svn protocol tunneled through SSH). IDE access to any of CollabNet’s other platform servers,
then you’ll need CollabNet Desktop for Visual Studio.
On the client side, you can work with the Subversion reposito-
ry in several ways. You can use command-line tools included Inside Visual Studio, you can work with three types of sites
with Subversion itself:
(CollabNet Enterprise Edition, Source Forge, and Cubit)
through the IDE. You navigate through all three types of sites
svn co http://svn.collab.net/repos/svn/trunk
through a common explorer view, called the CollabNet Site
subversion
Browser. Through the Site Browser, you have access to
At a deeper level of integration, you can work with a program appropriate functions within each site type. For example,
such as TortoiseSVN, which provides a Subversion client a CollabNet Enterprise Edition site would contain an Issue
through a shell extension. Or, deeper still, as we’ll discuss Tracker node through which you could navigate to issues that
in the rest of this article, you can work with a Subversion cli- are assigned to you.
ent that’s fully integrated into the Visual Studio IDE, such as
AnkhSVN. CollabNet Enterprise Edition and Source Forge sites may
contain source repositories as well as other types of nodes.
Plugging in with AnkhSVN When you navigate to a source repository, CollabNet
AnkhSVN allows you to see the status of files, to commit Desktop browses the repository using an installed Subver-
changes, and to conduct other common Subversion opera- sion client, if one is available. If you’ve installed AnkhSVN,
tions right in the Visual Studio Solution Explorer. It also adds it will open the repository in the Repository Explorer. In this
several custom views for working with Subversion from inside way, CollabNet Desktop for Visual Studio is enhanced if you
the IDE. install AnkhSVN along with it.

26 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

AnkhSVN 2.0 is implemented as a Visual Studio Source Con- Figure 2. Solution Explorer, showing source control status.
trol VSPackage, giving it extensive control of the source-con-
trol features of the IDE. The source control package integra-
tion option was introduced in Visual Studio 2005 and allows
external providers, such as AnkhSVN, to hook into the source
control IDE at a low level.

We’ll start exploring AnkhSVN by loading a project from a


public repository. AnkhSVN provides an “Open from Subver-
sion” menu entry. You provide a URL, and AnkhSVN shows
you a view of the repository, allowing you to browse for solu-
tion or project files (figure 1). Once you select a file, AnkhSVN
retrieves the entire solution from the repository and installs a
copy in a local directory.

Figure 1. Opening a solution file directly from a public


Subversion repository.

In-House Projects
As you make changes to the source, AnkhSVN immediately
updates file status in the Solution Explorer. In figure 2, the The easiest way to set up a secure Subversion server for your
solution has one modified file (AutoSize.cpp, marked with the team’s projects is to use the svn+ssh:// protocol. Setting up a
red box) and one edited file (Accordion.cs, marked with the Visual Studio client for svn+ssh:// access takes some configu-
red checkmark). ration work outside of Visual Studio and AnkhSVN, however.

If you don’t have commit access to the public repository, you Briefly, you’ll need to install an external SSH client (some op-
won’t be able to commit these changes. AnkhSVN makes it tions are TortoiseSVN and Putty), and then configure the cli-
easy to create a patch file to submit to the project maintainer, ent so that you don’t need to provide a password for each
through a “create patch” entry in the context menu for the file connection. Subversion requires several SSH connections
in the Solution Explorer. for every operation, so it becomes very difficult to work with
Subversion inside the IDE if you use password authentication.
The best way to avoid the password dialog is to configure the
SSH connection for public-key authentication and to store the
key file on the client.

27 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.
New Possibilities for Expanding Your Skills with Visual Studio

Back in the IDE, you can use AnkhSVN to initialize a new re- AnkhSVN supports branching and tagging, with the ability to
pository with sources from the client. As with most AnkhSVN create branches or tags of solutions within the IDE. AnkhSVN
tasks, you right-click in the Solution Explorer to bring up a also supports merging through a Merge Wizard (figure 4).
context menu. To start tracking a solution in Subversion, you The Merge Wizard walks you step-by-step through different
click the solution and choose “Add to Subversion.” This brings merge scenarios.
up a dialog where you can specify the URL of the repository in
which to store the solution and its associated projects. Figure 4. The Merge Wizard differentiates between different branch
merge types.

Other tasks you can take care of with a right-click in Solution


Explorer include file locking and setting of Subversion prop-
erties. AnkhSVN allows you to set Subversion properties for
individual files (such as svn:eol-style, controlling line endings
as discussed earlier). It also allows you to set folder-oriented
settings, such as svn:ignore, on project and solution files.

You can always check the version control status of each item
in the Solution Explorer, but when you’re ready to commit
you’ll want a more focused view of the changes. AnkhSVN’s
Pending Changes window (figure 3) shows the status of each
file that would be affected by a commit. You can use Pending
Changes to commit all of these changes at once, optionally
adding a message to attach to the revision.

The Pending Changes window is probably where you’ll spend


most of your time interacting with Subversion. In addition to
committing, you can also update files on your local machine
with changes from the repository, and compare local files with
other versions.
Some other interesting views that AnkhSVN brings to Visual
Figure 3. The AnkhSVN Pending Changes window. You can see Subversion Studio are a Repository Explorer, for browsing Subversion
status, commit, or update from this view. repositories by URL, and a Working Copy Explorer, for brows-
ing items in the current working copy, even if they aren’t as-
sociated with a Visual Studio project.

Whether you’re interested in Subversion primarily as a way


to access open-source projects, or as your core develop-
ment VCS, it’s important to have good client tools to make
source control effective. The combination of Visual Studio
and AnkhSVN gives you access to most Subversion functions
without requiring that you leave the IDE. That’s definitely a
productivity boost.
You can set external tools for AnkhSVN to use to diff and * This article was commissioned by and prepared for Microsoft Corporation. This
document is for informational purposes only. MICROSOFT MAKES NO WARRAN-
merge files in the options menu. AnkhSVN helpfully suggests TIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.
some diff tool options in the list, noting which ones are in- Steve Apiki is senior developer at Appropriate Solutions, Inc., a Peterborough, NH
stalled on the client system. consulting firm that builds software solutions at every layer in the stack using a variety
of tools. Steve has been writing about software and technology for over 15 years.
steve.apiki@gmail.com

28 New Possibilities for Expanding Your Skills with Visual Studio. © 2009, WebMediaBrands Inc.

Potrebbero piacerti anche