You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the Microsoft.CodeAnalysis.Analyzer.Testing.ReferenceAssemblies class has very limited configurability when it comes to the settings for NuGet. It allows you to specify a single NuGet config file, or none at all. If you don't specify a NuGet config file, it uses the system- and user-level config, but not the config for the current working directory. That is, it doesn't traverse the directory hierarchy searching for NuGet config files that should apply to the current directory. This is because, at this line in the code, it passes null as the root directory when loading NuGet settings. The root path is what the NuGet configuration library uses to identify configuration files that should apply to a given directory. By passing null, ReferenceAssemblies ignores all directory-scoped configuration files.
This causes problems for setups where essential config is located in multiple config files, and one or more of them are scoped to a directory. Specifying any single config file wouldn't capture everything that's required, and ReferenceAssemblies ignores all of the directory-scoped config files. In my case, I need ReferenceAssemblies to make use of a specific NuGet source that is configured in a directory-scoped config file generated by a CI pipeline. However, I can't point it to just that config file, as that would break my ability to run tests locally.
I would propose that the ReferenceAssemblies class should, at a minimum, allow one to specify the root path via something like WithNuGetConfigRoot(string root). Having it use the current working directory by default would likely be a breaking change, but at least allowing consumers of the class to configure that value would help a ton.
The text was updated successfully, but these errors were encountered:
I would propose that the ReferenceAssemblies class should, at a minimum, allow one to specify the root path via something like WithNuGetConfigRoot(string root).
Currently, the
Microsoft.CodeAnalysis.Analyzer.Testing.ReferenceAssemblies
class has very limited configurability when it comes to the settings for NuGet. It allows you to specify a single NuGet config file, or none at all. If you don't specify a NuGet config file, it uses the system- and user-level config, but not the config for the current working directory. That is, it doesn't traverse the directory hierarchy searching for NuGet config files that should apply to the current directory. This is because, at this line in the code, it passesnull
as the root directory when loading NuGet settings. The root path is what the NuGet configuration library uses to identify configuration files that should apply to a given directory. By passingnull
,ReferenceAssemblies
ignores all directory-scoped configuration files.This causes problems for setups where essential config is located in multiple config files, and one or more of them are scoped to a directory. Specifying any single config file wouldn't capture everything that's required, and
ReferenceAssemblies
ignores all of the directory-scoped config files. In my case, I needReferenceAssemblies
to make use of a specific NuGet source that is configured in a directory-scoped config file generated by a CI pipeline. However, I can't point it to just that config file, as that would break my ability to run tests locally.I would propose that the
ReferenceAssemblies
class should, at a minimum, allow one to specify theroot
path via something likeWithNuGetConfigRoot(string root)
. Having it use the current working directory by default would likely be a breaking change, but at least allowing consumers of the class to configure that value would help a ton.The text was updated successfully, but these errors were encountered: