Using PoshBuild in MSBuild

PoshBuild was mainly designed to be using in a build process. It ships with 2 MSBuild tasks:
  • GenerateCmdletHelp
  • GenerateDisplayFormat

In order to use those tasks, PoshBuild ships with a .targets file that you can import in your MSBuild project. For instance:

<Import Project="..\Dependencies\PoshBuild\PoshBuild.Tasks.targets" />


Then you can run those tasks in any MSBuild project. For example, you can run them in the "AfterBuild" target of your Visual Studio project (this means you'll edit your .csproj).

Generating the Cmdlet help file

The GenerateCmdletHelp task can be used like so:

    <GenerateCmdletHelp
        Assemblies="@(MyCmdletAssemblies)"
        DescriptorAssemblies="@(MyDescriptorAssemblies)">
      <Output TaskParameter="HelpFiles" ItemName="HelpFiles" />
    </GenerateCmdletHelp>


The DescriptorAssemblies parameter is optional, so you can start by only giving your Cmdlet assembly (you can use $(TargetPath) if you're adding this to your Visual Studio project).
The output file will always be a file named "$(TargetName).dll-Help.xml", created just next to the assembly you specified, where $(TargetName) is the name (without extension) of your assembly.
For more information on Cmdlet help descriptors, which are expected to be found in the DescriptorAssemblies, go read the documentation regarding how to describe Cmdlet types.

Generating the display format file

The GenerateDisplayFormat task can be used like so:

    <GenerateDisplayFormat
        Assemblies="$(TargetDir)IronCow.dll"
	DescriptorAssemblies="$(TargetPath)"
        FormatFilePath="$(TargetDir)$(TargetName).format.ps1xml">
      <Output TaskParameter="FormatFilePath" ItemName="DisplayFormatFiles" />
    </GenerateDisplayFormat>


The DescriptorAssemblies parameter is optional, but there's a good chance you will need it. For more information on display format descriptors, which are expected to be found in the DescriptorAssemblies, go read the documentation regarding how to describe .NET types.
The FormatFilePath parameter defines the location of the generated display format file, which you can trap also as an output parameter for the task if you need. Typically, display format files have the ".format.ps1xml" extension. For more information on this, read the MSDN section about them.

Last edited Jul 17, 2008 at 3:25 AM by ludovic_chabant, version 2

Comments

No comments yet.