Skip to content

Commit 7e9e95b

Browse files
committed
Add output DebugSymbolsFiles to ResolvePackageAssets
This property contains the list of files related to debug symbols, and xml per asset.
1 parent b0b9714 commit 7e9e95b

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/Tasks/Common/MetadataKeys.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,12 @@ internal static class MetadataKeys
131131
public const string IsVersion5 = "IsVersion5";
132132
public const string CreateCompositeImage = "CreateCompositeImage";
133133
public const string PerfmapFormatVersion = "PerfmapFormatVersion";
134+
135+
// Debug symbols
136+
public const string Related = "related";
137+
public const string Xml = ".xml";
138+
public const string XmlPath = "XmlPath";
139+
public const string Pdb = ".pdb";
140+
public const string PdbPath = "PdbPath";
134141
}
135142
}

src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,15 @@ public sealed class ResolvePackageAssets : TaskBase
231231
[Output]
232232
public ITaskItem[] PackageDependencies { get; private set; }
233233

234+
/// <summary>
235+
/// List of file symbols pdb and xml related to NuGet packages
236+
/// </summary>
237+
/// <remarks>
238+
/// This is the list of files to be copied to the output directory
239+
/// </remarks>
240+
[Output]
241+
public ITaskItem[] DebugSymbolsFiles { get; private set;}
242+
234243
/// <summary>
235244
/// Messages from the assets file.
236245
/// These are logged directly and therefore not returned to the targets (note private here).
@@ -311,6 +320,7 @@ private void ReadItemGroups()
311320
ApphostsForShimRuntimeIdentifiers = reader.ReadItemGroup();
312321
CompileTimeAssemblies = reader.ReadItemGroup();
313322
ContentFilesToPreprocess = reader.ReadItemGroup();
323+
DebugSymbolsFiles = reader.ReadItemGroup();
314324
FrameworkAssemblies = reader.ReadItemGroup();
315325
FrameworkReferences = reader.ReadItemGroup();
316326
NativeLibraries = reader.ReadItemGroup();
@@ -510,7 +520,7 @@ private static BinaryReader CreateReaderFromDisk(ResolvePackageAssets task, byte
510520
BinaryReader reader = null;
511521
try
512522
{
513-
if (File.GetLastWriteTimeUtc(task.ProjectAssetsCacheFile) > File.GetLastWriteTimeUtc(task.ProjectAssetsFile))
523+
if (IsCacheFileNewerThanAssetsFile())
514524
{
515525
reader = OpenCacheFile(task.ProjectAssetsCacheFile, settingsHash);
516526
}
@@ -537,6 +547,8 @@ private static BinaryReader CreateReaderFromDisk(ResolvePackageAssets task, byte
537547
}
538548

539549
return reader;
550+
551+
bool IsCacheFileNewerThanAssetsFile() => File.GetLastWriteTimeUtc(task.ProjectAssetsCacheFile) > File.GetLastWriteTimeUtc(task.ProjectAssetsFile);
540552
}
541553

542554
private static BinaryReader OpenCacheStream(Stream stream, byte[] settingsHash)
@@ -776,6 +788,7 @@ private void WriteItemGroups()
776788
WriteItemGroup(WriteApphostsForShimRuntimeIdentifiers);
777789
WriteItemGroup(WriteCompileTimeAssemblies);
778790
WriteItemGroup(WriteContentFilesToPreprocess);
791+
WriteItemGroup(WriteDebugSymbolsFiles);
779792
WriteItemGroup(WriteFrameworkAssemblies);
780793
WriteItemGroup(WriteFrameworkReferences);
781794
WriteItemGroup(WriteNativeLibraries);
@@ -1091,6 +1104,27 @@ private void WriteContentFilesToPreprocess()
10911104
});
10921105
}
10931106

1107+
private void WriteDebugSymbolsFiles()
1108+
{
1109+
WriteItems(
1110+
_runtimeTarget,
1111+
package => package.RuntimeAssemblies,
1112+
filter: asset => asset.Properties.ContainsKey(MetadataKeys.Related),
1113+
writeMetadata: (package, asset) =>
1114+
{
1115+
asset.Properties.TryGetValue(MetadataKeys.Related, out string propertyValue);
1116+
if (string.Compare(propertyValue, MetadataKeys.Pdb, true) == 0)
1117+
{
1118+
WriteMetadata(MetadataKeys.PdbPath, Path.ChangeExtension(asset.Path, ".pdb"));
1119+
}
1120+
1121+
if (string.Compare(propertyValue, MetadataKeys.Xml, true) == 0)
1122+
{
1123+
WriteMetadata(MetadataKeys.XmlPath, Path.ChangeExtension(asset.Path, ".xml"));
1124+
}
1125+
});
1126+
}
1127+
10941128
private void WriteFrameworkAssemblies()
10951129
{
10961130
if (_task.DisableFrameworkAssemblies)

0 commit comments

Comments
 (0)