This section presents a Windows Script Host script that uses VBScript and the Visual Studio 6.0 COM Automation model to create a project based on an XML definition. The script automates the process of creating Visual Studio projects for testing and debug purposes. It assumes that the application uses a batch build environment.
In this example, control script creates and populates a Visual Studio 6.0 project by using a project definition contained in an XML file. XML was chosen as a portable, self-describing data format that can be used in the command-line interface of any integrated development environment. As a result, the XML definition need not change even if the Automation interfaces for Visual Studio change.
<?xml version="1.0"?> <! File Name: VSAutomation.wsf Purpose : This file contains jobs to process the scripts. It needs VSAutoLib.vbs and VSProjectData.xml files. Author : Microsoft Consulting Services Date : March 18, 2002 > <package> <job id="CREATE"> <script language="VBScript" src="VSAutoLib.vbs" /> <script language="VBScript"> <![CDATA[ createVSProjects "E:\VSProjectData.xml" ]]> </script> </job> <job id="BUILD"> <script language="VBScript" src="VSAutoLib.vbs" /> <script language="VBScript"> <![CDATA[ buildVSProjects "E:\VSProjectData.xml" ]]> </script> </job> </package> XML Project Data Definition <?xml version="1.0"?> <! File Name: VSProjectData.xml Purpose : Visual Studio Project Data Author : Microsoft Consulting Services Date : March 18, 2002 > <Workspace> <Projects> <Project> <Name>myProject</Name> <Type>Console Application</Type> <Path>E:\MigrationSource\myProjects\myProject\</Path> <Files> <File> <Name>mySrcFile1.cpp</Name> <Path>E:\MigrationSource\source\</Path> </File> <File> <Name>mySrcFile2.cpp</Name> <Path>E:\MigrationSource\source\</Path> </File> <File> <Name>myHdrFile1.h</Name> <Path>E:\MigrationSource\source\</Path> </File> </Files> <Configurations> <Configuration> <Name>Win32 Debug</Name> <BuildFlag>No</BuildFlag> </Configuration> <Configuration> <Name>Win32 Release</Name> <BuildFlag>yes</BuildFlag> </Configuration> </Configurations> </Project> <Project> <Name>myProject2</Name> <Type>Console Application</Type> <Path>E:\MigrationSource\myProjects\myProject2\</Path> <Files> <File> <Name>mySrcFile1.cpp</Name> <Path>E:\MigrationSource\source\</Path> </File> <File> <Name>mySrcFile2.cpp</Name> <Path>E:\MigrationSource\source\</Path> </File> <File> <Name>myHdrFile1.h</Name> <Path>E:\MigrationSource\source\</Path> </File> </Files> <Configurations> <Configuration> <Name>Win32 Debug</Name> <BuildFlag>yes</BuildFlag> </Configuration> <Configuration> <Name>Win32 Release</Name> <BuildFlag>no</BuildFlag> </Configuration> </Configurations> </Project> </Projects> </Workspace> <! End of Data >
Option Explicit