@@ -814,6 +814,43 @@ private IEnumerable<string> GetFeeds(Func<IList<string>> getNugetFeeds)
814814 private ( HashSet < string > explicitFeeds , HashSet < string > allFeeds ) GetAllFeeds ( )
815815 {
816816 var nugetConfigs = fileProvider . NugetConfigs ;
817+
818+ // On systems with case-sensitive file systems (for simplicity, we assume that is Linux), the
819+ // filenames of NuGet configuration files must be named correctly. For compatibility with projects
820+ // that are typically built on Windows or macOS where this doesn't matter, we accept all variants
821+ // of `nuget.config` ourselves. However, `dotnet` does not. If we detect that incorrectly-named
822+ // files are present, we emit a diagnostic to warn the user.
823+ if ( SystemBuildActions . Instance . IsLinux ( ) )
824+ {
825+ string [ ] acceptedNugetConfigNames = [ "nuget.config" , "NuGet.config" , "NuGet.Config" ] ;
826+ var invalidNugetConfigs = nugetConfigs
827+ . Where ( path => acceptedNugetConfigNames . Contains ( Path . GetFileName ( path ) ) ) ;
828+
829+ if ( invalidNugetConfigs . Count ( ) > 0 )
830+ {
831+ this . logger . LogWarning ( string . Format (
832+ "Found incorrectly named NuGet configuration files: {0}" ,
833+ string . Join ( ", " , invalidNugetConfigs )
834+ ) ) ;
835+ this . diagnosticsWriter . AddEntry ( new DiagnosticMessage (
836+ Language . CSharp ,
837+ "buildless/case-sensitive-nuget-config" ,
838+ "Found NuGet configuration files which are not correctly named" ,
839+ visibility : new DiagnosticMessage . TspVisibility ( statusPage : true , cliSummaryTable : true , telemetry : true ) ,
840+ markdownMessage : string . Format (
841+ "On platforms with case-sensitive file systems, NuGet only accepts files with one of the following names: {0}.\n \n " +
842+ "CodeQL found the following files while performing an analysis on a platform with a case-sensitive file system:\n \n " +
843+ "{1}\n \n " +
844+ "To avoid unexpected results, rename these files to match the casing of one of the accepted filenames." ,
845+ string . Join ( ", " , acceptedNugetConfigNames ) ,
846+ string . Join ( "\n " , invalidNugetConfigs . Select ( path => string . Format ( "- `{0}`" , path ) ) )
847+ ) ,
848+ severity : DiagnosticMessage . TspSeverity . Warning
849+ ) ) ;
850+ }
851+ }
852+
853+ // Find feeds that are explicitly configured in the NuGet configuration files that we found.
817854 var explicitFeeds = nugetConfigs
818855 . SelectMany ( config => GetFeeds ( ( ) => dotnet . GetNugetFeeds ( config ) ) )
819856 . ToHashSet ( ) ;
0 commit comments