Skip to content

Commit 56d0b07

Browse files
Package ijwhost.dll as native asset for self-contained publish (#11664)
* Package ijwhost.dll as native asset for self-contained publish After the /clr:pure to /clr:NetCore migration (#11575), DirectWriteForwarder and System.Printing became mixed-mode C++/CLI assemblies that require ijwhost.dll at runtime. The DLL was being placed in the managed lib/ folder where it is not recognized by RuntimeList.xml, causing it to be missing from self-contained publish output. Exclude ijwhost.dll from the lib/ packaging and add it as a native asset under runtimes/win-{arch}/native/ so it is properly included in the runtime pack manifest. Fixes #11651 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Move ijwhost.dll packaging logic to Packaging.targets Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1117832 commit 56d0b07

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

eng/WpfArcadeSdk/tools/Packaging.targets

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ $(PreparePackageAssetsDependsOn):
8989
<DestinationSubFolder Condition="'$(Platform)'=='arm64'">runtimes\win-arm64\native\</DestinationSubFolder>
9090
</PropertyGroup>
9191

92+
<!--
93+
For managed C++/CLI projects (vcxproj with UseDestinationLibFolder), ijwhost.dll is automatically
94+
produced in the output directory but must be packaged as a native assembly under runtimes\<rid>\native\
95+
rather than alongside managed assemblies under lib\<tfm>\.
96+
-->
97+
<PropertyGroup Condition="'$(MSBuildProjectExtension)'=='.vcxproj' and '$(UseDestinationLibFolder)' != ''">
98+
<NativeRuntimeSubFolder Condition="'$(Platform)'=='AnyCPU' or '$(Platform)'=='x86' or '$(Platform)'=='Win32'">runtimes\win-x86\native\</NativeRuntimeSubFolder>
99+
<NativeRuntimeSubFolder Condition="'$(Platform)'=='x64'">runtimes\win-x64\native\</NativeRuntimeSubFolder>
100+
<NativeRuntimeSubFolder Condition="'$(Platform)'=='arm64'">runtimes\win-arm64\native\</NativeRuntimeSubFolder>
101+
</PropertyGroup>
102+
103+
<ItemGroup Condition="'$(MSBuildProjectExtension)'=='.vcxproj' and '$(UseDestinationLibFolder)' != ''">
104+
<FileNamesExcludedFromPackaging Include="ijwhost.dll" />
105+
</ItemGroup>
106+
92107
<!--
93108
Instead of showing an error when $(TargetFramework) or $(RuntimeIdentifier) cannot be identified
94109
we simply do no further work
@@ -118,6 +133,13 @@ $(PreparePackageAssetsDependsOn):
118133
<Output ItemName="PackageAsset" TaskParameter="Include"/>
119134
</CreateItem>
120135

136+
<!-- Route ijwhost.dll to runtimes\<rid>\native\ for managed C++/CLI projects -->
137+
<CreateItem Include="$(OutDir)ijwhost.dll"
138+
AdditionalMetadata="RelativePath=$(ArtifactsPackagingDir)$(NormalizedPackageName)\$(NativeRuntimeSubFolder)"
139+
Condition="'$(NativeRuntimeSubFolder)'!='' and '$(DestinationSubFolder)'!='' and '$(IsPackagingProject)'!='true' and Exists('$(OutDir)ijwhost.dll')">
140+
<Output ItemName="PackageAsset" TaskParameter="Include"/>
141+
</CreateItem>
142+
121143
<!--
122144
Normally, .lib files are not included in packaging - projects have to opt in by setting
123145
<PropertyGroup>

src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/DirectWriteForwarder.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<ItemGroup>
9393
<AdditionalPackageReference Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" />
9494
</ItemGroup>
95-
<!-- ijwhost.dll is required for mixed-mode C++/CLI assemblies -->
95+
<!-- ijwhost.dll packaging is handled centrally in eng/WpfArcadeSdk/tools/Packaging.targets -->
9696
<Target Name="AddWindowsBaseDefine" AfterTargets="ResolveProjectReferences">
9797
<Error Text="Unexpected result from _WindowsBaseReference '@(_WindowsBaseReference->Count())'" Condition="'@(_WindowsBaseReference->Count())' != '1'" />
9898
<PropertyGroup>

src/Microsoft.DotNet.Wpf/src/System.Printing/System.Printing.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
<ItemGroup>
162162
<AdditionalPackageReference Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" />
163163
</ItemGroup>
164-
<!-- ijwhost.dll is required for mixed-mode C++/CLI assemblies -->
164+
<!-- ijwhost.dll packaging is handled centrally in eng/WpfArcadeSdk/tools/Packaging.targets -->
165165
<Target Name="AddDefineReferences" BeforeTargets="ClCompile" AfterTargets="ResolveReferences" Returns="@(CLCompile)">
166166
<PropertyGroup>
167167
<_defineReferences>@(_defineReference->'%(Define)=&lt;%(Identity)&gt;')</_defineReferences>

0 commit comments

Comments
 (0)