Quick recap: we've set the operating environment to know where the required Unity libraries are by using a batch file. We now need to create our specialized targets in order to customize our building process.
Before we start though let's divert to see how everything fits together in the project folders.
Notice that I've separated the targets into four parts (it's also possible to stick everything in only one or two files but I rather have it more organized). Each part is named based on its function within the process.
The first file we'll look at is the one for setting our build directories, aptly named "Directories". You'll have to excuse the code being shown in an image rather than text since I've not managed to embed it properly and every time I tried the site ate the text and spat it out. I'll attach a complete zipped version at the end of the next post instead.
Keep your hands inside at all times and let's look at some XML.
As stated, not much is going on beyond setting some basic variables. Note in particular the "unity_home_dir" is set to our previously defined physical location of the Unity libraries, the "obj_dir" is set manually and will be used later to relocate Visual Studio's default object folder. And, in general, our final output is "target_dir" and is set to be within Unity's assets folder, although it'll be redefined a bit later.
With the basic directories out of the way next stop is our target selector.
Alright, unlike the directories targets the target-selector actually does something. It uses the "Choose" element of the MSBuild compiler and then selects the correct branch based on our requested "UnityTarget" (which will be set per project).
The target selector is quite an important piece in our build process since Unity is picky about not mixing the editing components of its engine with its runtime. In fact Unity will spit out errors if we did. Not to mention that all editor-related code must reside under a folder called /Editor/. By defining the "UnityTarget" we can not only automatically reference the correct libraries but also assign the correct target directory.
I could have chosen to separate each into its own targets file but I didn't, why? well, I'm sure I had a good reason at the time... :)
And now that we've defined both our core directories and have selected the correct references/target directory let's get to the [almost] final piece of the puzzle. The output targets.
Most of these properties are MSBuild specific. By definiting the "BaseIntermediateOutputPath" and "IntermediateOutputPath" we can redirect Visual Studio's object folder; even though it'll still generate an empty folder in the project directory - I call that a bug, Microsoft calls it a feature.
The "OutputPath"is self explantory and the last "Import" is needed by MSBuild to correctly process C# files.
That's it. Well sort of. There's still one last targets file and the next post will deal with that and the actual [.csproj] project files. But until then...