summaryrefslogtreecommitdiff
path: root/src/.nuget/dir.targets
blob: 807d99d06e143c18cfcadee46d2bea3e2b973713 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />

  <PropertyGroup>
    <!-- Reset PackageOutputPath. The ProjectDefaults targets from Arcade set it to be in the artifacts directory,
         but our publishing step currently looks under PackagesBinDir -->
    <PackageOutputPath>$(PackagesBinDir)/pkg/</PackageOutputPath>
  </PropertyGroup>

  <Import Project="$(NuGetPackageRoot)\microsoft.dotnet.build.tasks.packaging\$(MicrosoftDotNetBuildTasksPackagingVersion)\build\Microsoft.DotNet.Build.Tasks.Packaging.targets" />

  <!--
    Finds symbol files and injects them into the package build.
  -->
  <Target Name="GetSymbolPackageFiles" BeforeTargets="GetPackageFiles">
    <ItemGroup Condition="'$(SymbolFileExtension)' != ''">
      <AdditionalLibPackageExcludes Include="%2A%2A\%2A$(SymbolFileExtension)"/>
    </ItemGroup>

    <ItemGroup>
      <AdditionalLibPackageExcludes Include="@(LongNameFile -> '%(TargetPath)')" />
    </ItemGroup>

    <ItemGroup>
      <NativeWithSymbolFile Include="@(NativeBinary);@(CrossGenBinary)">
        <TargetPath>runtimes/$(PackageTargetRuntime)/native</TargetPath>
      </NativeWithSymbolFile>
      <!-- Using lib/netstandard1.0 here.  There is no TFM for this since it is a runtime itself. -->
      <NativeWithSymbolFile Include="@(ArchitectureSpecificLibFile)">
        <TargetPath>runtimes/$(PackageTargetRuntime)/lib/netstandard1.0</TargetPath>
      </NativeWithSymbolFile>
      <NativeWithSymbolFile Include="@(ArchitectureSpecificToolFile)">
        <TargetPath>tools</TargetPath>
      </NativeWithSymbolFile>
    </ItemGroup>

    <ItemGroup Condition="'$(HasCrossTargetComponents)'=='true'">
      <NativeWithSymbolFile Include="@(CrossArchitectureSpecificNativeFileAndSymbol)">
        <TargetPath>runtimes/$(CrossTargetComponentFolder)_$(Platform)/native</TargetPath>
      </NativeWithSymbolFile>
      <NativeWithSymbolFile Include="@(CrossArchitectureSpecificToolFile)">
        <TargetPath>tools/$(CrossTargetComponentFolder)_$(Platform)</TargetPath>
      </NativeWithSymbolFile>
    </ItemGroup>

    <ItemGroup>
      <!-- The symbols for these files are already in place together with respective *.ni.pdb -->
      <IlForCrossGenedFile Include="@(CrossGenBinary -> '%(RootDir)%(Directory)IL\%(Filename).dll')">
        <TargetPath>runtimes/$(PackageTargetRuntime)/il</TargetPath>
      </IlForCrossGenedFile>
    </ItemGroup>

    <ItemGroup>
      <File Include="@(NativeWithSymbolFile)" />
      <File Include="@(LongNameFile);@(IlForCrossGenedFile)">
        <IsSymbolFile>true</IsSymbolFile>
      </File>
    </ItemGroup>

    <ItemGroup>
      <!-- On Windows, trim ".dll" before adding ".pdb". -->
      <WindowsNativeFile Include="@(NativeWithSymbolFile)"
                         Condition="'%(NativeWithSymbolFile.Extension)'=='.dll' OR '%(NativeWithSymbolFile.Extension)'=='.exe'" />
      <WindowsSymbolFile Include="@(WindowsNativeFile -> '%(RootDir)%(Directory)PDB\%(Filename).pdb')" />
      <!-- Crossgened files (on windows) have both a *.pdb and a *.ni.pdb symbol file.  Include the *.ni.pdb file as well if it exists. -->
      <WindowsSymbolFile Include="@(WindowsNativeFile -> '%(RootDir)%(Directory)PDB\%(Filename).ni.pdb')" />

      <!--
        Search for all xplat symbol file extensions on every xplat native binary. Some binaries have
        no ".so" or ".dylib" extension, so we can't tell which convention its symbol files would
        use. On xplat, the symbol extension is simply appended.
      -->
      <NonWindowsNativeFile Include="@(NativeWithSymbolFile)"
                            Exclude="@(WindowsNativeFile)" />

      <NonWindowsSymbolFile Include="@(NonWindowsNativeFile -> '%(Identity)$(SymbolFileExtension)')" />

      <ExistingWindowsSymbolFile Include="@(WindowsSymbolFile)" Condition="Exists('%(Identity)')" />
      <ExistingNonWindowsSymbolFile Include="@(NonWindowsSymbolFile)" Condition="Exists('%(Identity)') AND '$(SkipPackagingXplatSymbols)'!='true'" />

      <!-- Include all found symbols. -->
      <File Include="@(ExistingWindowsSymbolFile);@(ExistingNonWindowsSymbolFile)">
        <IsSymbolFile>true</IsSymbolFile>
      </File>
    </ItemGroup>

    <PropertyGroup>
      <NeedsPlaceholderPdb Condition="'@(ExistingNonWindowsSymbolFile)'!='' AND '@(ExistingWindowsSymbolFile)'==''">true</NeedsPlaceholderPdb>
    </PropertyGroup>

    <ItemGroup>
      <File Include="$(MSBuildThisFileDirectory)\_.pdb"
            Condition="'$(NeedsPlaceholderPdb)'=='true' AND '$(PackageTargetRuntime)'!=''">
        <TargetPath>runtimes/$(PackageTargetRuntime)/native</TargetPath>
        <IsSymbolFile>true</IsSymbolFile>
      </File>
    </ItemGroup>
  </Target>

</Project>