Skip to content

fix: BuildTasks assembly reference resolution and add DsComExportTypeLibraryDependsOn hook - #442

Merged
carstencodes merged 6 commits into
mainfrom
bugfixes/carstencodes/gh-440
Jul 16, 2026
Merged

fix: BuildTasks assembly reference resolution and add DsComExportTypeLibraryDependsOn hook#442
carstencodes merged 6 commits into
mainfrom
bugfixes/carstencodes/gh-440

Conversation

@carstencodes

Copy link
Copy Markdown
Member
  • Adds a new MSBuild property: DsComExportTypeLibraryDependsOn
    • Allows configuring targets that must run before dscom execution
    • Default value is DsComAddAssemblyReferencesAutomatically
  • Introduces DsComAddAssemblyReferencesAutomatically
    • Runs after ResolveReferences
    • Collects reference assembly paths from ReferencePath
    • Supports both references with HintPath and references without hint path
  • Fixes --asmpath argument generation in BuildTasks.Tools.targets
    • Uses normalized assembly directories instead of raw file paths
    • Removes trailing slashes from resolved assembly paths
  • Updates DsComExportTypeLibraryAfterBuild to depend on $(DsComExportTypeLibraryDependsOn)
    • Changes the export command behavior
      • Exec now ignores the raw exit code
      • Emits DSCOM005 warning when dscom fails while the TLB file exists
      • Keeps existing DSCOM001 warning when the TLB file is missing
  • Documents the new property in [README.md]

Fixes bug #440 by improving build task dependency handling, reference discovery, and export result reporting.

In order to find the correct assemblies from the references, the references must be filled.
The assemblies hence should be consumed via ReferencePath item group.
This also introduces a new pre-export dependency.
In order to do this, a new DependsOn Property is introduced.
The DsComAsmPath MetaData is introduced from the directory of the reference.

CAVEAT: dscom tlbexport --asmpath has a bug: The directory is marked as not found, if it ends with a trailing backslash
Include only the directories from the references. Only include the directories, skip all other metadata. This will make all items unique in the list.
If TLB Export succeeds (file is created), ignore the exit code and issue this as a warning.
Add documentation for dependency group DsComExportTypeLibraryDependsOn
@carstencodes carstencodes added bug Something isn't working documentation Improvements or additions to documentation labels Jul 15, 2026
@marklechtermann

Copy link
Copy Markdown
Member

Thanks, Carsten. The reported problem appears to be fixed: the NuGet dependency is resolved correctly and the affected type is included in the generated type library.

However, could changing IgnoreExitCode from false to true be an unintended side effect? A failing dscom invocation can now result in a successful MSBuild exit code. This change does not seem necessary for fixing #440.

I suggest keeping IgnoreExitCode="false" and limiting this PR to collecting the resolved NuGet references after ResolveReferences. If special exit-code handling is required, it should be addressed separately with the intended failure semantics clearly defined.

@matthiasnissen, could you please confirm this assessment?

@matthiasnissen

Copy link
Copy Markdown
Member

Agree with @marklechtermann's assessment. The reference-resolution fix (ResolveReferences/ReferencePath, --asmpath normalization) is clean and correctly scoped to #440.

However, IgnoreExitCode=true is an unrelated, potentially breaking behavior change: a failing dscom invocation would no longer fail the build (only emits a DSCOM005 warning). CI pipelines relying on the exit code wouldn't catch that anymore.

Suggestion: split this out into a separate PR/discussion (maybe as an opt-in property) so the actual bugfix can be merged independently.

This reverts commit 866e5e6.

After Code review comments by @marklechtermann and @matthiasnissen
in PR #442
@carstencodes

Copy link
Copy Markdown
Member Author

@marklechtermann @matthiasnissen I agree with your opinion on the ExitCode. But dscom always created the TLB file, even error state.
Nevertheless, I reverted the commit.

@carstencodes
carstencodes merged commit 2840b17 into main Jul 16, 2026
5 checks passed
@carstencodes
carstencodes deleted the bugfixes/carstencodes/gh-440 branch July 16, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Target DsComExportTypeLibraryAfterBuild runs sometimes before target _CopyFilesMarkedCopyLocal

3 participants