This documentation is archived and is not being maintained.

Using MSBuild with SDM Tools [SDM] 

Visual Studio 2005
 
Using the System Definition Model (SDM) SDK

Using MSBuild with SDM Tools

The SDM command line tools often require a large number of parameters that are tedious to type. To simplify the command-line typing, the SDM tools are enabled to use the new Microsoft build engine: MSBuild. MSBuild allows you to bypass the long command lines by abstracting the command-line parameters into an XML file.

Creating MSBuild Project Files

The command-line parameters of the tools each correspond to an element in the MSBuild project file.

To simplify the commands needed to use the SDM tools, follow the steps below.

  1. Create one project (.sdmproj file) for each .sdm file. Call the SDM Prototype Generator (ProtoGen.exe), SDM Manager Generator (SdmG.exe), SDM Command Line Compiler (SdmC.exe), or the C# compiler (CsC.exe) to build everything that corresponds to the .sdm file.
  2. If more than one endpoint or system definition is in a .sdm file, create one project for each additional prototype that needs to be generated.

MSBuild Project File Format

Project files (.sdmproj files) contain XML code that provides information needed to use the SDM command-line tools. This information corresponds to command-line parameters for the SDM tools. Project files start out with a Project element that specifies the SDM tool you want to use, for example, the SdmC tool:

<Project DefaultTargets='SdmC' xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

General properties should then be defined in a PropertyGroup element. General properties used by all the SDM tools are listed below.

  • OutputPath (string): The directory where all output files will be saved by the tools. If not specified, files are output to the current directory. In the tables below for Properties, the ‘*’ indicates that the property will be appended to the OutputPath.
  • SdmToolsPath (string): Must be specified if sdmc.exe is not a system Path environment variable (if you are not running from the SDM SDK Command Prompt).

The following example shows how to define the general properties.

<Project DefaultTargets='SdmC' xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <!-- General properties -->
    <PropertyGroup>
        <OutputPath>bin\</OutputPath>
    </PropertyGroup>

Using MSBuild with SdmC.exe

The following table lists the SdmC.exe command-line parameters and the corresponding elements used in a .sdmproj project file to specify the values of the command-line parameters.

Element in the .sdmproj File Corresponding SdmC Command-Line Parameter
SdmSourceFile (string) <filename>
SdmTargetFile* (string) /Output <filename>
SdmKeyFile (string) /KeyFile <filename>
SdmKeyContainer (string) /KeyContainer <name>
ConfigurationReport* (string) /ConfigReport <filename>
InstanceSpaceReport* (string) /InstanceOutput <filename>
SdmWarningLevelAsErrors (int) /WarningAsError <level>
SdmWarningLevelReported (int) /WarningReported <level>
SdmErrorLimit (int) /ErrorLimit <limit>
SdmMaxComplexity (int) /MaxComplexity <max>
SdmNoLogo (bool) /NoLogo
SdmReference (string) /Reference <filename>
SdmReferenceSearchPath (string) /SearchPath <path>

Note  Elements with a '*' after the name indicates that the property will be appended to the OutputPath.

The following example shows the XML used to create a .sdmproj project file that specifies parameters and information used in the SdmC.exe tool.

<Project DefaultTargets='SdmC' xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <!-- General properties -->
    <PropertyGroup>
        <OutputPath>bin\</OutputPath>
    </PropertyGroup>

    <!-- sdmc.exe properties -->
    <PropertyGroup>
        <SdmSourceFile>Microsoft.Samples.SimpleFtp.sdm</SdmSourceFile>
        <SdmTargetFile>$(SdmSourceFile)Document</SdmTargetFile>
    </PropertyGroup>
    
    <!-- SdmC.exe items -->
    <ItemGroup>
        <SdmReference Include="Microsoft.Datacenter.sdmDocument"/>
        <SdmReference Include="Microsoft.DistributedApplication.sdmDocument"/>
        <SdmReference Include="Microsoft.WindowsApplication.sdmDocument"/>
        <SdmReference Include="Microsoft.WindowsHost.sdmDocument"/>
        <SdmReference Include="Microsoft.Web.sdmDocument"/>
        <SdmReference Include="Microsoft.WebHost.sdmDocument"/>
        <SdmReference Include="Microsoft.WebApplication.sdmDocument"/>
        <SdmReference Include="System.Flow.sdmDocument"/>

        <SdmReferenceSearchPath Include="$(SdmModelsDir)"/>
    </ItemGroup>
    
    <Import Project="$(SdmToolsDir)\Microsoft.SystemDefinitionModel.Targets" />

</Project>

Using MSBuild with Protogen.exe

The following table lists the Protogen.exe command-line parameters and the corresponding elements used in a .sdmproj project file to specify the values of the command-line parameters.

Element in the .sdmproj File Corresponding Protogen Command-Line Parameter
PrototypeType (enum) /Type <System | Endpoint>
PrototypeLayer (enum) /Layer <Application | Host>
PrototypeDocument (string) /Document <name>
PrototypeTypeName (string) /TypeName <sdmTypeName>
PrototypeOutput* (string) /Output <filename>

Note  If specified, will not be appended to the OutputPath property. If not specified, the default output will append the type name to the output path with the file extension .adPrototype or .lddPrototype, depending on if the type is System or Endpoint, respectively.

PrototypeName (string) /Name <name>
PrototypeBitmap (string) /Bitmap <filename>
PrototypeCaption (string) /Caption <caption>
PrototypePosition (int) /Position <position>
PrototypeSdmFile (string) /File <filename>

Note  Elements with a '*' after the name indicates that the property will be appended to the OutputPath.

The following example shows the XML used to create a .sdmproj project file that specifies parameters and information used in the Protogen.exe tool.

<Project DefaultTargets='SdmProtoGen' xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <!-- General properties -->
    <PropertyGroup>
        <OutputPath>bin\</OutputPath>
    </PropertyGroup>

    <!-- Prototype generator properties -->
    <PropertyGroup>
        <PrototypeTypeName>FtpClient</PrototypeTypeName>
        <PrototypeOutput>$(OutputPath)$(PrototypeTypeName).lddPrototype</PrototypeOutput>
        <PrototypeType>Endpoint</PrototypeType>
        <PrototypeLayer>Host</PrototypeLayer>
        <PrototypeDocument>Microsoft.Samples.SimpleFtp</PrototypeDocument>
        <PrototypeName>FtpClientEndpoint</PrototypeName>
        <PrototypeBitmap></PrototypeBitmap>
        <PrototypePosition></PrototypePosition>
        <PrototypeCaption></PrototypeCaption>
    </PropertyGroup>

    <Import Project="$(SdmToolsDir)\Microsoft.SystemDefinitionModel.Targets" />

</Project>

Using MSBuild with SdmG.exe

The following table lists the SdmG.exe command-line parameters and the corresponding elements used in a .sdmproj project file to specify the values of the command-line parameters.

Element in the .sdmproj File Corresponding SdmG Command-Line Parameter
SdmSourceFile (string) <filename>
SdmWarningLevelAsErrors (int) /WarningAsError <level>
SdmWarningLevelReported (int) /WarningReported <level>
SdmErrorLimit (int) /ErrorLimit <limit>
GenerateClassses (bool) /Classes+ or /Classes-
GenerateResources (bool) /Resources+ or /Resources-
GeneratedClassFile* (string) /Classes <filename>
GeneratedResourceFile* (string) /Resources <filename>
GenerateSettingClasses (bool) /Settings+ or /Settings-
GenerateConstraintClasses (bool) /Constraints+ or /Constraints-
GenerateFlowClasses (bool) /Flows+ or /Flows
SdmNoLogo (bool) /NoLogo
SdmReference (string) /Reference <filename>
SdmReferenceSearchPath (string) /SearchPath <path>

Note  Elements with a '*' after the name indicates that the property will be appended to the OutputPath.

The following example shows the XML used to create a .sdmproj project file that specifies parameters and information used in the SdmG.exe tool, the SdmC.exe tool, and the Csc.exe compiler.

<Project DefaultTargets='SdmG;Compile;SdmC' xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <!-- General properties -->
    <PropertyGroup>
        <OutputPath>bin\</OutputPath>
    </PropertyGroup>

    <!-- SdmC.exe properties -->
    <PropertyGroup>
        <SdmSourceFile>Microsoft.Samples.Certificates.sdm</SdmSourceFile>
        <SdmTargetFile>$(SdmSourceFile)Document</SdmTargetFile>
    </PropertyGroup>
    
    <!-- SdmC.exe items -->
    <ItemGroup>
        <SdmReference Include="Microsoft.Configuration.sdmDocument"/>
        <SdmReference Include="Microsoft.Data.sdmDocument"/>
        <SdmReference Include="Microsoft.DistributedApplication.sdmDocument"/>
        <SdmReference Include="Microsoft.FileSystem.sdmDocument"/>
        <SdmReference Include="Microsoft.InternetInformationServices.sdmDocument"/>
        <SdmReference Include="Microsoft.OperatingSystem.sdmDocument"/>
        <SdmReference Include="Microsoft.WindowsApplication.sdmDocument"/>
        <SdmReference Include="Microsoft.WindowsHost.sdmDocument"/>
        <SdmReference Include="Microsoft.Web.sdmDocument"/>
        <SdmReference Include="Microsoft.WebHost.sdmDocument"/>
        <SdmReference Include="Microsoft.WebApplication.sdmDocument"/>
        <SdmReference Include="System.Constraints.sdmDocument"/>
        <SdmReference Include="System.Flow.sdmDocument"/>

        <SdmReferenceSearchPath Include="$(SdmModelsDir)"/>
    </ItemGroup>
    
    <!-- SdmG.exe properties -->
    <PropertyGroup>
        <ManagerAssemblyName>Microsoft.Sdm.Samples.Certs</ManagerAssemblyName>
        <ManagerFileName>$(ManagerAssemblyName).dll</ManagerFileName>
        <GeneratedClassFile>Certificates.cs</GeneratedClassFile>
        <GenerateClasses>true</GenerateClasses>
        <GenerateResources>true</GenerateResources>
        <GeneratedResourceFile>$(ManagerAssemblyName).resources</GeneratedResourceFile>
        <SdmNoLogo>true</SdmNoLogo>
        <ResourceTextFile>MyResources.txt</ResourceTextFile>
    </PropertyGroup>
    
    <!-- Csc properties for the manager -->
    <PropertyGroup>
        <AssemblyName>$(ManagerAssemblyName)</AssemblyName>
        <OutputType>Library</OutputType>
        <NoLogo>true</NoLogo>
        <Configuration>Retail</Configuration>
        <Platform>AnyCPU</Platform>
        <IntermediateOutputPath>$(OutputPath)</IntermediateOutputPath>
    </PropertyGroup>
    <ItemGroup>
        <Compile Include="$(OutputPath)Certificates.cs"/>
        <ManifestResourceWithNoCulture Include='$(OutputPath)$(GeneratedResourceFile)'/>
        <Reference Include="System.Xml" />
    </ItemGroup>


    <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />

    <!-- Have to import the SDM targets after the CSharp targets -->
    <Import Project="$(SdmToolsDir)\Microsoft.SystemDefinitionModel.Targets" />

</Project>

Using MSBuild with Csc.exe

Refer to the MSBuild documentation for information on using MSBuild with Csc.exe. For an example of how Csc.exe is used, refer to the sample XML in the section above.

See Also

SDM command line tools, SDM Prototype Generator (ProtoGen.exe), SDM Manager Generator (SdmG.exe), SDM Command Line Compiler (SdmC.exe)

  
  Last updated: November 2005  |  What did you think of this topic?  |  Order a Platform SDK CD
  © Microsoft Corporation. All rights reserved. Terms of use.

 

Show: