예제 #1
0
        protected IEnumerable <Packaging.PackageReference> GetInstalledPackageReferences(
            string projectConfigFilePath,
            bool allowDuplicatePackageIds)
        {
            if (File.Exists(projectConfigFilePath))
            {
                try
                {
                    XDocument xDocument = XmlUtility.Load(projectConfigFilePath);
                    var       reader    = new PackagesConfigReader(xDocument);
                    return(reader.GetPackages(allowDuplicatePackageIds));
                }
                catch (XmlException ex)
                {
                    var message = string.Format(
                        CultureInfo.CurrentCulture,
                        LocalizedResourceManager.GetString("Error_PackagesConfigParseError"),
                        projectConfigFilePath,
                        ex.Message);

                    throw new CommandException(message);
                }
            }

            return(Enumerable.Empty <Packaging.PackageReference>());
        }
 private List <PackageReference> GetPackageReferencesFromConfigFile()
 {
     try
     {
         XDocument xDocument = XmlUtility.Load(_packageConfigFile);
         var       reader    = new PackagesConfigReader(xDocument);
         return(reader.GetPackages(true).ToList());
     }
     catch (XmlException ex)
     {
         throw new PortingAssistantClientException("Unable to parse packages.config file", ex);
     }
 }