-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C#: Fix global.json
and packages.config
lookup
#16312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -143,7 +143,7 @@ private static BuildScript DownloadDotNet(IBuildActions actions, ILogger logger, | |||
// See https://docs.microsoft.com/en-us/dotnet/core/tools/global-json | |||
var versions = new List<string>(); | |||
|
|||
foreach (var path in files.Where(p => p.EndsWith("global.json", StringComparison.Ordinal))) | |||
foreach (var path in files.Where(p => p.EndsWith(Path.DirectorySeparatorChar + "global.json", StringComparison.Ordinal))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you run into a case where a file was name myglobal.json
or something similar?
nit: Maybe consider using Path.GetFileName
? (same comment for the other similar change)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggesting Path.GetFileName
, that handles two other cases too. I'll change it...
I was putting together an integration test, and temporarily renamed the packages.config
to x_packages.config
, and then I was surprised that the packages were still picked up by the dependency manager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
catch (Exception ex) | ||
{ | ||
logger.LogDebug($"Failed to get directory name for {path}: {ex.Message}"); | ||
return ""; | ||
} |
Check notice
Code scanning / CodeQL
Generic catch clause
catch (Exception ex) | ||
{ | ||
logger.LogDebug($"Failed to get file name for {path}: {ex.Message}"); | ||
return null; | ||
} |
Check notice
Code scanning / CodeQL
Generic catch clause
No description provided.