Try fix the dll file copy error - #22
Conversation
WPF NuGet Build
|
|
Correction to my earlier analysis — the root cause is not a DLL copy error, but a CLR assembly resolution issue.
Root causeThe As a result, the CLR keeps resolving the same-named assembly from the The repo-built This also explains:
FixUpdated the
This makes it land in Added regression tests in Verification
|
…ps.json The generated buildTransitive targets previously copied DirectWriteForwarder.dll into the output directory only after Build/Publish completed. This placed the file on disk but did not register it in the application's .deps.json, so the CLR continued to resolve the same-named assembly from the Microsoft.WindowsDesktop.App shared framework. The resulting private ABI mismatch with the repo-built PresentationCore.dll caused MissingMethodException when calling TextAnalyzer.Itemize. Update the generated targets to register the RID-specific DirectWriteForwarder.dll as a real runtime dependency: - Add it to ReferenceDependencyPaths. - Set IncludeRuntimeDependency="true". - Add it to ReferenceCopyLocalPaths. - Remove any existing same-named asset before registering it. This ensures the assembly is written to .deps.json and the CLR resolves the repo version from the app directory instead of the shared framework version. Add regression tests covering this behavior.
…ences The generated buildTransitive targets previously copied DirectWriteForwarder.dll into the output directory only after ResolveReferences completed. The file existed on disk but was never part of the app's dependency graph, so framework-dependent apps still resolved the same-named assembly from the Microsoft.WindowsDesktop.App shared framework. The resulting internal ABI mismatch with the repo-built PresentationCore.dll caused MissingMethodException at TextAnalyzer.Itemize. Register the assembly before reference resolution instead: - Add <Reference Include="DirectWriteForwarder"> with a RID-specific <HintPath>. - Set <Private>true</Private> so it is treated as a real runtime dependency and written to .deps.json. - Remove the previous ineffective logic that injected ReferenceDependencyPaths and ReferenceCopyLocalPaths after ResolveReferences.
This reverts commit b146214.
This reverts commit 703b230.
This reverts commit cd9859a.
This reverts commit 3e998a6.
Fixes #21
Description
Fixes a
MissingMethodExceptionthrown at runtime in ordinary AnyCPU WPF projects.The repository-built
PresentationCore.dllcallsTextAnalyzer.Itemize, and its signature exactly matches theDirectWriteForwarder.dllimplementation in the repo — the exception is not a bug in the text rendering code. The real cause is runtime assembly mixing:PresentationCore.dll;DirectWriteForwarder.dllis not deployed;MissingMethodException.This PR updates the transitive targets generated by the NuGet package so that ordinary AnyCPU projects also select and deploy the runtime assets matched with
PresentationCore.Customer Impact
Without this fix, ordinary AnyCPU WPF projects that do not explicitly set
RuntimeIdentifier,PlatformTarget, orPlatform(not limited to HandyControlDemo) throw aMissingMethodExceptionat runtime due to assembly mixing, causing text-rendering-related functionality to fail outright and potentially crashing or breaking the app.Regression
No. This is not a regression introduced in a recent release; it is a long-standing gap in the package's runtime asset selection logic. The repository runtime was only selected when a project explicitly set an
RuntimeIdentifieror an x64/x86 platform, causing common AnyCPU projects to miss the app-localDirectWriteForwarder.dll.Testing
NuGetPackageServiceTests: all 17 tests pass.Builder.csprojbuilds successfully.Prefer32Bitscenarios covering the transitive targets' runtime asset selection logic.Risk
Low risk. The fix is focused on the architecture inference logic in the NuGet package's transitive targets:
win-x86/win-x64is selected based onPrefer32BitandNETCoreSdkRuntimeIdentifier; the logic is clear and covered by new regression tests;