Skip to content

Commit 56a70da

Browse files
committed
C#: Remove package cleanup in the dependency manager.
1 parent 70996a4 commit 56a70da

File tree

1 file changed

+1
-64
lines changed

1 file changed

+1
-64
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public DependencyManager(string srcDir, IDependencyOptions options, ILogger logg
127127
UseReference(filename);
128128
}
129129

130-
RemoveUnnecessaryNugetPackages();
130+
RemoveNugetAnalyzerReferences();
131131
ResolveConflicts();
132132

133133
// Output the findings
@@ -162,23 +162,6 @@ public DependencyManager(string srcDir, IDependencyOptions options, ILogger logg
162162
DateTime.Now - startTime);
163163
}
164164

165-
private void RemoveUnnecessaryNugetPackages()
166-
{
167-
RemoveNugetAnalyzerReferences();
168-
RemoveRuntimeNugetPackageReferences();
169-
170-
if (fileContent.IsNewProjectStructureUsed
171-
&& !fileContent.UseAspNetCoreDlls)
172-
{
173-
// This might have been restored by the CLI even though the project isn't an asp.net core one.
174-
RemoveNugetPackageReference("microsoft.aspnetcore.app.ref");
175-
}
176-
177-
// TODO: There could be multiple `microsoft.netframework.referenceassemblies` packages,
178-
// we could keep the newest one, but this is covered by the conflict resolution logic
179-
// (if the file names match)
180-
}
181-
182165
private void RemoveNugetAnalyzerReferences()
183166
{
184167
if (!options.UseNuGet)
@@ -283,52 +266,6 @@ private void AddAspNetFrameworkDlls(List<string> dllPaths)
283266
}
284267
}
285268

286-
private void RemoveRuntimeNugetPackageReferences()
287-
{
288-
var runtimePackagePrefixes = new[]
289-
{
290-
"microsoft.netcore.app.runtime",
291-
"microsoft.aspnetcore.app.runtime",
292-
"microsoft.windowsdesktop.app.runtime",
293-
294-
// legacy runtime packages:
295-
"runtime.linux-x64.microsoft.netcore.app",
296-
"runtime.osx-x64.microsoft.netcore.app",
297-
"runtime.win-x64.microsoft.netcore.app",
298-
299-
// Internal implementation packages not meant for direct consumption:
300-
"runtime."
301-
};
302-
RemoveNugetPackageReference(runtimePackagePrefixes);
303-
}
304-
305-
private void RemoveNugetPackageReference(params string[] packagePrefixes)
306-
{
307-
if (!options.UseNuGet)
308-
{
309-
return;
310-
}
311-
312-
var packageFolder = packageDirectory.DirInfo.FullName.ToLowerInvariant();
313-
if (packageFolder == null)
314-
{
315-
return;
316-
}
317-
318-
var packagePathPrefixes = packagePrefixes.Select(p => Path.Combine(packageFolder, p.ToLowerInvariant()));
319-
320-
foreach (var filename in usedReferences.Keys)
321-
{
322-
var lowerFilename = filename.ToLowerInvariant();
323-
324-
if (packagePathPrefixes.Any(prefix => lowerFilename.StartsWith(prefix)))
325-
{
326-
usedReferences.Remove(filename);
327-
progressMonitor.RemovedReference(filename);
328-
}
329-
}
330-
}
331-
332269
private string? GetPackageDirectory(string packagePrefix)
333270
{
334271
if (!options.UseNuGet)

0 commit comments

Comments
 (0)