Building and Compiling Your Projects

At first glance, the differences between building and compiling are not immediately obvious. A build forces compilation regardless of whether a file or group of files has changed, but a compile only compiles files that have changed since the last compile.

When you're using either the Project menu or context menu for the project in the Project Manager window, selecting Build will apply to the active project (bold title in the Project Manager window). Selecting Project, Build All will perform a build on every project in the project group. Each project will build from the top of the list down. As each project is built, the font of its name in the Project Manager window will turn to bold. On the context menu for each project is an entry called Build All from Here, which will only build projects starting with the one selected and moving down the list. All projects above the one selected will not be built. Similar to the Build All and Build All from Here commands, the Compile All and Compile All from Here commands will behave the same, respectively. The difference is that commands with "Compile" or "Make" in their titles will have compile option behavior, rather than build behavior.

Another set of options on the context menu help control build order. The Build Sooner option (Ctrl+up arrow) moves a project up in the project list and the Build Later option (Ctrl+down arrow) moves the project down in the project list. Because projects are built from top to bottom or from current project down, using these options controls when a project is built. Because you must maintain build order manually, it is important to make sure that projects are in the right order.

COMPILER OPTIONS

For controlling compiler options for a project, activate the project and choose Project, Options or press Ctrl+Shift+F11. A shortcut is to right-click on the individual project in the Project Manager and select Options. These are per-project settings only, and there is no way to set options for the entire project group at one time. When you're first starting a project, these options are set for development purposes. For a custom configuration, make the changes you need, click the Save As button, and give the new configuration a name. If you save your settings under the Debug configuration, you wipe out the default settings.

One of the things that help to maintain build order is adding references to other projects. Adding a few Class Library projects to your practice project group will show how this works. Class Libraries are created by right-clicking the project group and choosing Add New Project and then selecting C# Projects in Item Categories and double-clicking Class Library. For each of the Class Library projects, open the Add References dialog and, after the dialog has initialized, click the Project References tab. What you'll see is a list of references to the other class library projects in the list. If you also have an executable project, the Project References tab of the Add References dialog will show every class library project in the project group. While The Add References dialog is open, if you need to reference a library that isn't part of the current project group, click the Browse button, which will open the Select a Reference dialog, which helps you find the library.

Regardless of whether a library is added from the Project References tab or added through the Browse button, C#Builder will copy the latest version of the referenced library to the project output directory whenever the referencing project is compiled. The only way to avoid this is by adding the referenced library to the Global Assembly Cache (GAC). If you add the project to the GAC, be aware that if you change the library, the new version will also need to be added to the GAC. After a while, this will mean that you have multiple versions of the same library in the GAC that you have to clean up, unless you do it every time the library is rebuilt. Adding assemblies to the GAC also brings up questions of deployment issues that you should address. A full explanation of adding assemblies to the GAC and deployment is discussed in Chapter 18.

The benefit of C#Builder copying referenced libraries to the referencing project's output directory is that changes to the referenced library are always up-to-date and there isn't a hassle with maintaining shared assemblies in the GAC.



C# Builder KickStart
C# Builder KickStart
ISBN: 672325896
EAN: N/A
Year: 2003
Pages: 165

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net