Include libnethost.pdb in implementation packages (#72688)
authorElinor Fung <elfung@microsoft.com>
Sat, 23 Jul 2022 01:19:14 +0000 (18:19 -0700)
committerGitHub <noreply@github.com>
Sat, 23 Jul 2022 01:19:14 +0000 (18:19 -0700)
src/installer/pkg/projects/Microsoft.NETCore.DotNetAppHost/Microsoft.NETCore.DotNetAppHost.pkgproj
src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Host.sfxproj

index 8f078c7..279e238 100644 (file)
         The symbols file is also shipped to enable users to fully debug
         binaries that link against the static version. -->
     <NativeBinary Include="$(DotNetHostBinDir)/libnethost.lib" />
-    <NativeBinary Include="$(DotNetHostBinDir)/PDB/libnethost.pdb" />
+    <_SymbolsToIncludeAlways Include="$(DotNetHostBinDir)PDB/libnethost.pdb" />
     <NativeBinary Include="$(DotNetHostBinDir)/libhostfxr.lib" />
-    <NativeBinary Include="$(DotNetHostBinDir)/PDB/libhostfxr.pdb" />
+    <_SymbolsToIncludeAlways Include="$(DotNetHostBinDir)PDB/libhostfxr.pdb" />
+
+    <!-- By default, the packaging infrastructure excludes all PDBs from implementation packages.
+        Explicitly set the excludes such that we exclude symbols corresponding to our native binaries
+        except for the ones we explicity want to include. -->
+    <LibPackageExcludes Include="@(NativeBinary -> '%2A%2A\%(Filename).pdb')" />
+    <LibPackageExcludes Remove="@(_SymbolsToIncludeAlways -> '%2A%2A\%(Filename).pdb')" />
   </ItemGroup>
   <ItemGroup Condition="'$(TargetOS)' != 'windows'">
     <NativeBinary Include="$(DotNetHostBinDir)/$(LibPrefix)hostfxr$(StaticLibSuffix)" />
   </ItemGroup>
 
   <ItemGroup Condition="'$(PackageTargetRuntime)' != ''">
-    <File Include="@(NativeBinary)">
+    <File Include="@(NativeBinary);@(_SymbolsToIncludeAlways)">
       <TargetPath>runtimes/$(PackageTargetRuntime)/native</TargetPath>
       <IsNative>true</IsNative>
     </File>
index 0fc6d8a..2e4834b 100644 (file)
     <NativeRuntimeAsset Include="$(DotNetHostBinDir)/ijwhost.dll" />
     <NativeRuntimeAsset Include="$(DotNetHostBinDir)/ijwhost.lib" />
     <NativeRuntimeAsset Include="$(DotNetHostBinDir)/libnethost.lib" />
+
+    <!-- Always include the static library PDB. When consuming the static library on Windows,
+        the linker needs the PDB to produce complete debug information for whatever is linking
+        in the static library. Without the PDB, consumers will hit LNK4099. -->
+    <_SymbolsToIncludeAlways Include="$(DotNetHostBinDir)PDB/libnethost.pdb" />
+    <NativeRuntimeAsset Include="@(_SymbolsToIncludeAlways)" IncludeAlways="true" />
   </ItemGroup>
 
   <ItemGroup>
@@ -46,6 +52,9 @@
                     Include="@(NativeRuntimeAsset->'%(RootDir)%(Directory)PDB/%(Filename)%(Extension)%(SymbolsSuffix)')"
                     IsSymbolFile="true"
                     IsNative="true" />
+
+    <!-- Remove symbols that are explicitly shipped with implementation package -->
+    <_SymbolFiles Remove="@(_SymbolsToIncludeAlways)" />
   </ItemGroup>
 
   <Target Name="AddSymbolFiles" BeforeTargets="GetFilesToPackage">