다음을 통해 공유


ResolveComReference task

Takes a list of one or more type library names or .tlb files and resolves those type libraries to locations on disk.

Parameters

The following table describes the parameters of the ResolveCOMReference task.

Parameter Description
DelaySign Optional Boolean parameter.

If true, places the public key in the assembly. If false, fully signs the assembly.
EnvironmentVariables Optional String[] parameter.

Array of pairs of environment variables, separated by equal signs. These variables are passed to the spawned tlbimp.exe and aximp.exe in addition to, or selectively overriding, the regular environment block..
ExecuteAsTool Optional Boolean parameter.

If true, runs tlbimp.exe and aximp.exe from the appropriate target framework out-of-proc to generate the necessary wrapper assemblies. This parameter enables multi-targeting.
IncludeVersionInInteropName Optional Boolean parameter.

If true, the typelib version will be included in the wrapper name. The default is false.
KeyContainer Optional String parameter.

Specifies a container that holds a public/private key pair.
KeyFile Optional String parameter.

Specifies an item that contains a public/private key pair.
NoClassMembers Optional Booleanparameter.
ResolvedAssemblyReferences Optional ITaskItem[] output parameter.

Specifies the resolved assembly references.
ResolvedFiles Optional ITaskItem[] output parameter.

Specifies the fully qualified files on disk that correspond to the physical locations of the type libraries that were provided as input to this task.
ResolvedModules Optional ITaskItem[]parameter.
SdkToolsPath Optional System.String parameter.

If ExecuteAsTool is true, this parameter must be set to the SDK tools path for the framework version being targeted.
StateFile Optional String parameter.

Specifies the cache file for COM component timestamps. If not present, every run will regenerate all the wrappers.
TargetFrameworkVersion Optional String parameter.

Specifies the project target framework version.

The default is String.Empty. which means there is no filtering for a reference based on the target framework.
TargetProcessorArchitecture Optional String parameter.

Specifies the preferred target processor architecture. Passed to the tlbimp.exe/machine flag after translation.

The parameter value should be a member of ProcessorArchitecture.
TypeLibFiles Optional ITaskItem[] parameter.

Specifies the type library file path to COM references. Items included in this parameter may contain item metadata. For more information, see the section TypeLibFiles item metadata below.
TypeLibNames Optional ITaskItem[] parameter.

Specifies the type library names to resolve. Items included in this parameter must contain some item metadata. For more information, see the section TypeLibNames item metadata below.
WrapperOutputDirectory Optional String parameter.

The location on disk where the generated interop assembly is placed. If this item metadata is not specified, the task uses the absolute path of the directory where the project file is located.

TypeLibNames item metadata

The following table describes the item metadata available for items passed to the TypeLibNames parameter.

Metadata Description
GUID Required item metadata.

The GUID for the type library. If this item metadata is not specified, the task fails.
VersionMajor Required item metadata.

The major version of the type library. If this item metadata is not specified, the task fails.
VersionMinor Required item metadata.

The minor version of the type library. If this item metadata is not specified, the task fails.
EmbedInteropTypes Optional Boolean metadata.

If true, embed the interop types from this reference directly into your assembly rather than generating an interop DLL.
LocaleIdentifier Optional item metadata.

The Locale Identifier (or LCID) for the type library. This is specified as a 32-bit value that identifies the human language preferred by a user, region, or application. If this item metadata is not specified, the task uses a default locale identifier of "0".
WrapperTool Optional item metadata.

Specifies the wrapper tool that is used to generate the assembly wrapper for this type library. If this item metadata is not specified, the task uses a default wrapper tool of "tlbimp". The available, case insensitive choices of typelibs are:

- Primary: Use this wrapper tool when you want to use an already generated primary interop assembly for the COM component. When you use this wrapper tool, do not specify a wrapper output directory because that will cause the task to fail.
- TLBImp: Use this wrapper tool when you want to generate an interop assembly for the COM component.
- PrimaryOrTLBImp: Use this wrapper tool when you are unsure whether Primary or TLBImp is appropriate. The Primary logic is applied first, then TLBImp.
- AXImp:Use this wrapper tool when you want to generate an interop assembly for an ActiveX Control.

TypeLibFiles item metadata

The following table describes the item metadata available for items passed to the TypeLibFiles parameter.

Metadata Description
EmbedInteropTypes Optional Booleanparameter.

If true, embed the interop types from this reference directly into your assembly rather than generating an interop DLL.
WrapperTool Optional item metadata.

Specifies the wrapper tool that is used to generate the assembly wrapper for this type library. If this item metadata is not specified, the task uses a default wrapper tool of "tlbimp". The available, case insensitive choices of typelibs are:

- Primary: Use this wrapper tool when you want to use an already generated primary interop assembly for the COM component. When you use this wrapper tool, do not specify a wrapper output directory because that will cause the task to fail.
- TLBImp: Use this wrapper tool when you want to generate an interop assembly for the COM component.
- AXImp: Use this wrapper tool when you want to generate an interop assembly for an ActiveX Control.

Note

The more information that you provide to uniquely identify a type library, the greater the possibility that the task will resolve to the correct file on disk.

Remarks

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

The COM DLL doesn't need to be registered on the machine for this task to work.

MSB4803 Error

If you try to run a project that uses the ResolveCOMReference task from the dotnet CLI commands, you get the error:

MSB4803: The task "ResolveComReference" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild.

This task is not supported on the .NET Core version of MSBuild, which is what's used when you run the dotnet build command from the command line. Try building the project by invoking MSBuild.exe from the Visual Studio Developer Command Prompt, since this uses the .NET Framework version of MSBuild.

See also