/// <summary>
        /// Reads package restore data generated by the GenerateModuleAssetFlagFile target located in cbt\build.props
        /// </summary>
        /// <returns> a PackageRestoreData object based off the contents of the flag file.</returns>
        internal PackageRestoreData GetPackageRestoreData()
        {
            if (NuGetPackagesConfigParser.IsPackagesConfigFile(PackageRestoreFile))
            {
                return(new PackageRestoreData
                {
                    // At the moment, NuGet sets the restore style to Unknown if its not PackageReference or project.json
                    RestoreProjectStyle = "Unknown"
                });
            }

            if (String.IsNullOrWhiteSpace(RestoreInfoFile) || !File.Exists(RestoreInfoFile))
            {
                Log.LogMessage(MessageImportance.Low, $"Package reference {RestoreInfoFile} not found.  Either you are not using PackageReference elements for your packages or you are using a version of nuget.exe prior to 4.x, or the project does not import CBT in some way.");
                return(null);
            }

            return(JsonConvert.DeserializeObject <PackageRestoreData>(File.ReadAllText(RestoreInfoFile)));
        }
        public void VerifyPackagesConfigParserTest()
        {
            string packageConfigFile = Path.Combine(TestRootPath, "packages.config");

            PackageRestoreData packageRestoreData = LoadPackageRestoreObject(packageConfigFile, GetTempFileName(), _packageConfigRestoreFlagContents);

            File.WriteAllText(packageConfigFile, _packageConfigFileContents);

            string packagePath = CreatePackagesFolder(new List <Tuple <string, string> >
            {
                new Tuple <string, string>("Newtonsoft.Json", "6.0.1"),
                new Tuple <string, string>("Newtonsoft.Json", "7.0.1")
            });

            MockSettings settings = new MockSettings
            {
                {
                    "config", new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
                    {
                        { "repositoryPath", packagePath },
                    }
                }
            };

            bool result = new NuGetPackagesConfigParser(settings, _log).TryGetPackages(packageConfigFile, packageRestoreData, out IEnumerable <PackageIdentityWithPath> packages);

            result.ShouldBeTrue();

            packageConfigFile = Path.Combine(TestRootPath, "foo.proj");

            packageRestoreData = LoadPackageRestoreObject(packageConfigFile, GetTempFileName(), _packageConfigRestoreFlagContents);

            result = new NuGetPackagesConfigParser(settings, _log).TryGetPackages(packageConfigFile, packageRestoreData, out packages);

            result.ShouldBeTrue();

            IList <PackageIdentityWithPath> packageIdentityWithPaths = packages as IList <PackageIdentityWithPath> ?? packages.ToList();

            packageIdentityWithPaths.Count.ShouldBe(2);
            packageIdentityWithPaths.Select(i => i.Id).ShouldBe(new [] { "Newtonsoft.Json", "Newtonsoft.Json" });
            packageIdentityWithPaths.Select(i => i.Version.ToString()).ShouldBe(new[] { "6.0.1", "7.0.1" });
        }