Skip to content

Commit

Permalink
fix: Add Names to MsBuild Tasks (#136)
Browse files Browse the repository at this point in the history
In #131 names were introduced in form of an alias.
The names parameter was already supported before
but ignored by the MsBuild tasks.

This will add the names to the MsBuild tasks

Co-authored-by: Carsten Igel <[email protected]>
  • Loading branch information
carstencodes and Carsten Igel authored Feb 14, 2023
1 parent a33c253 commit af0b602
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ The build task consumes the following [items](https://learn.microsoft.com/en-us/
| DsComTlbExportTlbReferences | Referenced type library files. |
| DsComTlbExportReferencePaths | Directories containing type libraries to use for export. |
| DsComTlbExportAssemblyPaths | Assemblies to add for the export. |
| DsComTlbAliasNames | Names to use as aliases for types with aliases. |

### Example

Expand Down
7 changes: 7 additions & 0 deletions src/dscom.build/TlbExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ public TlbExport() : this(new DefaultBuildContext())
/// </summary>
public ITaskItem[] AssemblyPaths { get; set; } = Array.Empty<ITaskItem>();

/// <summary>
/// Gets or sets the names to map to a new resolved name.
/// </summary>
public string[] Names { get; set; } = Array.Empty<string>();

/// <inheritdoc cref="Task.Execute()" />
public override bool Execute()
{
Expand Down Expand Up @@ -171,6 +176,8 @@ private bool ExecuteTask()
checks.VerifyDirectoriesPresent(settings.TLBRefpath, false, ref result);
checks.VerifyFilesPresent(settings.ASMPath, false, ref result);

settings.Names = Names ?? Array.Empty<string>();

// run conversion, if result has been successful.
result = result && _context.ConvertAssemblyToTypeLib(settings, Log);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
SourceAssemblyFile="$(_DsComExportTypeLibraryAssemblyFile)"
TypeLibraryReferences="@(DsComTlbExportTlbReferences)"
TypeLibraryReferencePaths="@(DsComTlbExportReferencePaths)"
AssemblyPaths="@(DsComTlbExportAssemblyPaths)" />
AssemblyPaths="@(DsComTlbExportAssemblyPaths)"
Names="@(DsComTlbAliasNames)" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@
<_DsComTypeLibraryReferencePaths Condition="@(DsComTlbExportReferencePaths->Count()) &gt; 0">--tlbrefpath "@(DsComTlbExportReferencePaths, '"--tlbrefpath "')"</_DsComTypeLibraryReferencePaths>
<_DsComAssemblyReferences Condition="@(_DsComTlbExportAssemblyPathsWithoutHintPath->Count()) &gt; 0">--asmpath "@(_DsComTlbExportAssemblyPathsWithoutHintPath, '"--asmpath "')"</_DsComAssemblyReferences>
<_DsComAssemblyReferences Condition="@(_DsComTlbExportAssemblyPathsWithHintPath->Count()) &gt; 0">--asmpath "@(_DsComTlbExportAssemblyPathsWithHintPath->GetMetadata('HintPath'), '"--asmpath "')"</_DsComAssemblyReferences>
<_DsComAliasNames Condition="@(DsComTlbAliasNames->Count() &gt; 0)">--names @(DsComTlbAliasNames, --names)</_DsComAliasNames>
<_DsComArguments>tlbexport</_DsComArguments>
<_DsComArguments Condition="'$(DsComTypeLibraryUniqueId)' != '' AND '$(DsComTypeLibraryUniqueId)' != '$([System.Guid]::Empty.ToString())'">$(_DsComArguments) --overridetlbid "$(DsComTypeLibraryUniqueId)"</_DsComArguments>
<_DsComArguments Condition="'$(DsComToolVerbose)' == 'true'"> $(_DsComArguments) --verbose</_DsComArguments>
<_DsComArguments> $(_DsComArguments) $(_DsComAssemblyReferences)</_DsComArguments>
<_DsComArguments> $(_DsComArguments) $(_DsComTypeLibraryReferences)</_DsComArguments>
<_DsComArguments> $(_DsComArguments) $(_DsComTypeLibraryReferencePaths)</_DsComArguments>
<_DsComArguments> $(_DsComArguments) $(_DsComExportTypeLibraryAssemblyFile)</_DsComArguments>
<_DsComArguments> $(_DsComArguments) $(_DsComAliasNames)</_DsComArguments>
<_DsComArguments> $(_DsComArguments) --out $(_DsComExportTypeLibraryTargetFile)</_DsComArguments>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
<DsComTlbExportTlbReferences Remove="*" />
<DsComTlbExportReferencePaths Remove="*" />
<DsComTlbExportAssemblyPaths Remove="*" />
<DsComTlbAliasNames Remove="*" />
</ItemGroup>
</Project>

0 comments on commit af0b602

Please sign in to comment.