Variables used by Visual Studio environment -
This section will give you some idea on how some of the Variables are used by Visual Studio .NET while creating your project. Lets consider Web Application project template. When a project is created you get a WebForm1.aspx page. If you look at the properties page, and check the codebehind property and the inherits property, you will notice that Visual Studio has already assigned the property WebForm1.aspx.vb to Codebehind and <rootnamespace>.WebForm1 for Inherits. So, how does Visual Studio determine what property value needs to be assigned. Here are some keywords/variables I found when researching the templates. I have not seen any document pointing me to all Variables yet.
1. $FILENAME$ - This is used for the Codebehind property. If you open WebForm.aspx in notepad under templates folder for WebApplication, you will see the following code -
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="$FILENAME$.vb" Inherits="$INHERITS$"%>
When adding the WebForm.aspx to the project, Visual Studio.NET replaces the $FILENAME$ to the respective filename given. In Web Application case, the Webform.aspx is being added as WebForm1.aspx. So, codebehind will change to WebForm1.aspx.vb.
2. $INHERITS$: Referring back to the above code. You can see Visual Studio is using the $INHERITS$ keyword over here. So, when Visual Studio.NET creates the file it will get the rootnamespace and concate it with the filename without the extension. The reason it gets the filename without the extension because by default Visual Studio has the same filename as the classname. So, if you are creating project XYZ as Web application by default you will have XYZ.Webform1 as value for INHERITS property.
3. $CLASSNAME$: This is the one I found useful in one of my application template. Let us consider you are building private assembly or module for a bigger application. You want the class to be included in the same namespace as the application. Say the application name is XYZApp. So, instead of using the $INHERITS$ in your page template for property INHERITS, you can use something like this -
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="$FILENAME$.vb" Inherits="XYZAPP.$CLASSNAME$"%>
So, in case you are building Private Assembly and has a form called XYZPA then the inherits will have the value XYZAPP.XYZPA.
4. SAFE_ITEM_NAME: Lets assume that you are building private assembly and it has a class file with the same name as application. So, if you are creating application XYZ then you would like to have class called XYZDB. So, you can create a template file for your class called may be templatedb.vb. As explained in previous section, the onfinish function in default.js can copy the file and rename it. You can add the following code in your default.js file -
strTemplateFile = strTemplatePath + "\\templateDB.vb";
newfilename = strProjectName + "DB.vb";
item = AddFileToVSProject(newfilename, project, project.ProjectItems, strTemplateFile, false);
The above code will get the project name and combine it with string db.vb and create a new file, in our case XYZDB.vb. Visual studio.NET will use the XYZDB to replace the following code in your XYZDB.VB file -
Public Class [!output SAFE_ITEM_NAME]
Public Class XYZDB
5. PROJECT_NAME: This basically has the project Name assigned by the user. When we create Web Application project with the name XYZ this variable is populated.
6. PROJECT_PATH: This stores where the project is being created.
7. TEMPLATES_PATH: Stores the template folder information for the project type.
These are some of the variables Visual Studio .NET uses while creating your project.