Hardcoded packages.config string

Topics: General
Jul 13, 2013 at 12:25 PM
Recently I needed to switch between frameworks so I made a bunch of scripts that copies projects and packages.config to eg sample.Net40.proj and packages.Net40.proj.
However nuget -install /path/to/packages.Net40.config fails with the message
WARNING: Second path fragment must not be a drive or UNC name.
Parameter name: path2
Unable to find package '/path/to/packages.Net40.config'.
I checked the code and it's because NuGet insists on the packages.config name here (InstallCommand.cs@93):
// If the first argument is a packages.config file, install everything it lists
// Otherwise, treat the first argument as a package Id
if (Arguments.Count == 0 || Path.GetFileName(Arguments[0]).Equals(Constants.PackageReferenceFile, StringComparison.OrdinalIgnoreCase))
It does not make much sense to me to take a config file on the commandline and then put restrictions on the filename, but anyway an esay fix for myself is changing that into
Arguments[0].EndsWith(Constants.PackageReferenceFileExtension, StringComparison.OrdinalIgnoreCase)
where PackageReferenceFileExtension is .config. That still restricts the file name, but at least to something imo more sensible. But that also means atm I have to keep a fork of NuGet and put my own NuGet.exe in my repositories instead of just downloading it, maintain it etc. Not so nice.
So I was wondering if it's worth making a pull request for this? (Also I noticed that the Equals(Constants.PackageReferenceFile, StringComparison.OrdinalIgnoreCase) is repeated multiple times all over the NuGet projects which is a bit ugly. So I'd probably refactor that out as well, but then I'm not sure if I break things)