Skip to content

Commit b9f64fd

Browse files
Addressing more review comments
1 parent 292b853 commit b9f64fd

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

src/SourceBuild/content/build.proj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@
114114
<SdkSymbolsLayout>$(ArtifactsTmpDir)SdkSymbols</SdkSymbolsLayout>
115115
<SdkSymbolsTarball>$(OutputPath)dotnet-sdk-symbols-$(MicrosoftSourceBuildIntermediateInstallerVersion)-$(TargetRid).tar.gz</SdkSymbolsTarball>
116116
<SdkLayout>$(ArtifactsTmpDir)Sdk</SdkLayout>
117-
<SdkTarballPath>%(SdkTarballItem.Identity)</SdkTarballPath>
117+
<SdkTarball>%(SdkTarballItem.Identity)</SdkTarball>
118118
</PropertyGroup>
119119

120120
<MakeDir Directories="$(SdkLayout)" />
121-
<Exec Command="tar -xzf $(SdkTarballPath) -C $(SdkLayout)"
121+
<Exec Command="tar -xzf $(SdkTarball) -C $(SdkLayout)"
122122
WorkingDirectory="$(OutputPath)" />
123123

124124
<CreateSdkSymbolsLayout SdkLayoutPath="$(SdkLayout)"

src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/CreateSdkSymbolsLayout.cs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ namespace Microsoft.DotNet.Build.Tasks
1717
// Creates a symbols layout that matches the SDK layout
1818
public class CreateSdkSymbolsLayout : Task
1919
{
20-
private Hashtable AllPdbGuids;
21-
2220
/// <summary>
2321
/// Path to SDK layout.
2422
/// </summary>
@@ -44,8 +42,7 @@ public class CreateSdkSymbolsLayout : Task
4442

4543
public override bool Execute()
4644
{
47-
IndexAllSymbols(AllSymbolsPath);
48-
IList<string> filesWithoutPDBs = GenerateSymbolsLayout(SdkLayoutPath, SdkSymbolsLayoutPath);
45+
IList<string> filesWithoutPDBs = GenerateSymbolsLayout(IndexAllSymbols());
4946
if (filesWithoutPDBs.Count > 0)
5047
{
5148
LogErrorOrWarning(FailOnMissingPDBs, $"Did not find PDBs for the following SDK files:");
@@ -70,16 +67,16 @@ private void LogErrorOrWarning(bool isError, string message)
7067
}
7168
}
7269

73-
private IList<string> GenerateSymbolsLayout(string sdkRoot, string destinationRoot)
70+
private IList<string> GenerateSymbolsLayout(Hashtable allPdbGuids)
7471
{
7572
List<string> filesWithoutPDBs = new List<string>();
7673

77-
if (Directory.Exists(destinationRoot))
74+
if (Directory.Exists(SdkSymbolsLayoutPath))
7875
{
79-
Directory.Delete(destinationRoot, true);
76+
Directory.Delete(SdkSymbolsLayoutPath, true);
8077
}
8178

82-
foreach (string file in Directory.GetFiles(sdkRoot, "*", SearchOption.AllDirectories))
79+
foreach (string file in Directory.GetFiles(SdkLayoutPath, "*", SearchOption.AllDirectories))
8380
{
8481
if (file.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) &&
8582
!file.EndsWith(".resources.dll", StringComparison.InvariantCultureIgnoreCase))
@@ -107,16 +104,16 @@ private IList<string> GenerateSymbolsLayout(string sdkRoot, string destinationRo
107104

108105
if (guid != string.Empty)
109106
{
110-
if (!AllPdbGuids.ContainsKey(guid))
107+
if (!allPdbGuids.ContainsKey(guid))
111108
{
112-
filesWithoutPDBs.Add(file.Substring(sdkRoot.Length + 1));
109+
filesWithoutPDBs.Add(file.Substring(SdkLayoutPath.Length + 1));
113110
}
114111
else
115112
{
116113
// Copy matching pdb to symbols path, preserving sdk binary's hierarchy
117-
string sourcePath = (string)AllPdbGuids[guid]!;
114+
string sourcePath = (string)allPdbGuids[guid]!;
118115
string destinationPath =
119-
file.Replace(sdkRoot, destinationRoot)
116+
file.Replace(SdkLayoutPath, SdkSymbolsLayoutPath)
120117
.Replace(Path.GetFileName(file), Path.GetFileName(sourcePath));
121118

122119
Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)!);
@@ -129,11 +126,11 @@ private IList<string> GenerateSymbolsLayout(string sdkRoot, string destinationRo
129126
return filesWithoutPDBs;
130127
}
131128

132-
public void IndexAllSymbols(string path)
129+
public Hashtable IndexAllSymbols()
133130
{
134-
AllPdbGuids = new Hashtable();
131+
Hashtable allPdbGuids = new Hashtable();
135132

136-
foreach (string file in Directory.GetFiles(path, "*.pdb", SearchOption.AllDirectories))
133+
foreach (string file in Directory.GetFiles(AllSymbolsPath, "*.pdb", SearchOption.AllDirectories))
137134
{
138135
try
139136
{
@@ -147,19 +144,18 @@ public void IndexAllSymbols(string path)
147144

148145
var id = new BlobContentId(metadataReader.DebugMetadataHeader.Id);
149146
string guid = $"{id.Guid:N}";
150-
if (!string.IsNullOrEmpty(guid))
147+
if (!string.IsNullOrEmpty(guid) && !allPdbGuids.ContainsKey(guid))
151148
{
152-
if (!AllPdbGuids.ContainsKey(guid))
153-
{
154-
AllPdbGuids.Add(guid, file);
155-
}
149+
allPdbGuids.Add(guid, file);
156150
}
157151
}
158152
catch(Exception)
159153
{
160154
// ignore symbols that could not be indexed
161155
}
162156
}
157+
158+
return allPdbGuids;
163159
}
164160
}
165161
}

0 commit comments

Comments
 (0)