Visual Studio Unity Assembly Template

Large Unity projects can suffer from very long compilation times. Moving C# scripts to DLL files prevents Unity from having to recompile every script on a project every time a change is made to any of them.

This template file for Visual Studio creates a Code Library project, which automatically deploys itself to /Assets/Assemblies after building. This allows Unity to import the DLL file as a project asset, so scripts in the Unity project have access to all classes defined in the Dll.



Deployment
Self-Deployment and Debugging integration is accomplished by post-build steps defined in the deployUnityAssembly.targets file, included in the template. The post-build steps, in order:


 * Call Unity's pdb -> mdb conversion tool, to create .mdb debugging linkage files from VS's pdb output.
 * Move the output .dll and .mdb files to /Assets/Assembly

Please note that the template assumes your Visual Studio solution file is located in the Unity project's root folder. This is the default for Unity-generated VS files, so it should work unless the solution was moved. (In which case the output path will need to be retargeted)

Installation and Usage
Download and save this file to Documents/Visual Studio/My Exported Templates/ (restart Visual Studio if open).

To create a project from the template, Right-click the solution in Solution Explorer, select Add/New Item... There should be an item type called 'Unity Assembly' listed. Give it a name (this will be the dll filename as well) and select a project path.

Mind that the dll project path should not be located inside the /Assets folder, otherwise Unity will still import and compile the source scripts.

Credits
Project Template: Felipe "HarvesteR" Falanghe

Targets file: fjhamming_CleVR

Project config: yoyo

Reference
How to build and debug external DLLs (Forum Thread)

Using Visual Studio Tools for Unity