RegisterAssembly Task

Reads the metadata within the specified assembly and adds the necessary entries to the registry, which allows COM clients to create .NET Framework classes transparently. The behavior of this task is similar, but not identical, to that of the Regasm.exe (Assembly Registration Tool).

Parameters

The following table describes the parameters of the RegisterAssembly task.

Parameter

Description

Assemblies

Required ITaskItem[] parameter.

Specifies the assemblies to be registered with COM.

AssemblyListFile

Optional ITaskItem parameter.

Contains information about the state between the RegisterAssembly task and the UnregisterAssembly task. This prevents the UnregisterAssembly task from attempting to unregister an assembly that failed to register in the RegisterAssembly task.

CreateCodeBase

Optional Boolean parameter.

If true, creates a codebase entry in the registry, which specifies the file path for an assembly that is not installed in the global assembly cache. You should not specify this option if you will subsequently install the assembly that you are registering into the global assembly cache.

TypeLibFiles

Optional ITaskItem[] output parameter.

Specifies the type library to generate from the specified assembly. The generated type library contains definitions of the accessible types defined within the assembly. The type library is only generated if one of the following is true:

  • A type library of that name does not exist at that location.

  • A type library exists but it is older than the assembly being passed in.

If the type library is newer than the assembly being passed, a new one will not be created, but the assembly will still be registered.

If this parameter is specified, it must have the same number of items as the Assemblies parameter or the task will fail. If no inputs are specified, the task will default to the name of the assembly and change the extension of the item to .tlb.

Remarks

In addition to the parameters listed above, this task inherits parameters from the TaskExtension class, which itself inherits from the Task class. For a list of these additional parameters and their descriptions, see TaskExtension Base Class.

Example

The following example uses the RegisterAssembly task to register the assembly specified by the MyAssemblies item collection.

<Project xmlns="https://schemas.microsoft.com/developer/msbuild/2003">

    <ItemGroup>
        <MyAssemblies Include="MyAssembly.dll" />
    <ItemGroup>

    <Target Name="RegisterAssemblies">
        <RegisterAssembly
            Assemblies="@(MyAssemblies)" >
    </Target>

</Project>

See Also

Concepts

MSBuild Tasks

Other Resources

MSBuild Task Reference