Exemple #1
0
        public static XDocument ReadExisting(string path, ILogger log)
        {
            XDocument result = null;

            if (File.Exists(path))
            {
                try
                {
                    result = XmlUtility.Load(path);
                }
                catch (Exception ex)
                {
                    // Log a debug message and ignore, this will force an overwrite
                    log.LogDebug($"Failed to open imports file: {path} Error: {ex.Message}");
                }
            }

            return(result);
        }
Exemple #2
0
        private static IEnumerable <Packaging.PackageReference> GetInstalledPackageReferences(string projectConfigFilePath, bool allowDuplicatePackageIds, Common.ILogger log)
        {
            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(
                        Strings.Error_PackagesConfigParseError,
                        projectConfigFilePath,
                        ex.Message);

                    throw new XmlException(message, ex);
                }
            }

            return(Enumerable.Empty <Packaging.PackageReference>());
        }