One of the new features for DSL in VS2010 is DSL libraries, in this post I will explain how to use the new feature.
Prerequisites: VS SDK 2010 Beta2 and higher + DSL SDK 2010 Beta2 and higher.
DslLibrary is a DSL that is used as a library – you can extended it or just use it with you DslLibrary/DSL.
In order to start creating DslLibraries:
1. Start VS and then File->New->Project
2. Find the Domain-Specific Language Designer (under Other Project Type->Extensibility)
3. In the wizard choose DslLibrary and click Finish (or proceed with the wizard)
4. The wizard will unfold a single project solution with an empty model.
5. In DSL Explorer window right click on the root node and then add a Domain Class
6. Switch to Solution Explore Window and regenerate all (the command with the red rectangles surrounding it)
Note: For the current example you want be needing the generated code so, just the .dsl file itself.
7. Create another DslLibrary or a DSL.
8. When the second language is unfolded switch to the DSL Explorer Window
9. Right click on the root of the tree and choose Add DSL Library Import
10. Select the import and set the file path to the library (relative or absolute), when you hit ENTER, if the path is valid the library will appear in the DSL Explorer Window
11. At this point you can use the library in your language.
Note: as soon as you will consume it in your DSL you will create a dependency that will require the library to be present on the specified path.