Example #1
0
        /// <summary>
        /// Updates physical directory attribute value to the absolute path of the related project.
        /// </summary>
        private static void UpdatePhysicalDirectory(XmlNode node, bool updateBinaryReferences)
        {
            string physicalDirectory = node.Attributes["physicalDirectory"].Value;

            string relatedProjectName    = Path.GetFileName(physicalDirectory);
            string relatedProjectFile    = relatedProjectName + ".csproj";
            string relatedProjectVersion = ReferenceFolder.GetLatestVersion(
                Arguments.InternalReferencesPath,
                relatedProjectName);

            string projectPath = Path.Combine(Arguments.WorkingDirectoryRelated, relatedProjectName, relatedProjectFile);

            physicalDirectory = Path.Combine(Arguments.WorkingDirectoryRelated, relatedProjectName);

            node.Attributes["physicalDirectory"].Value = physicalDirectory;

            if (updateBinaryReferences)
            {
                UpdateBinaryReferences(projectPath, false);

                Console.WriteLine(
                    Resources.LogReferencesTo,
                    relatedProjectFile,
                    relatedProjectName,
                    relatedProjectVersion);
            }
        }
Example #2
0
        /// <summary>
        /// Updates project references.
        /// </summary>
        private static void UpdateProjectReferences()
        {
            string text = File.ReadAllText(Paths.ProjectFile);

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(text);

            XmlNamespaceManager xnm = new XmlNamespaceManager(doc.NameTable);

            xnm.AddNamespace("ms", "http://schemas.microsoft.com/developer/msbuild/2003");

            foreach (XmlNode node in doc.SelectNodes("/ms:Project/ms:ItemGroup/ms:ProjectReference", xnm))
            {
                string include = node.Attributes["Include"].Value;

                string relatedProjectFile    = Path.GetFileName(include);
                string relatedProjectName    = Path.GetFileNameWithoutExtension(include);
                string relatedProjectVersion = ReferenceFolder.GetLatestVersion(
                    Arguments.InternalReferencesPath,
                    relatedProjectName);

                include = Path.Combine(Arguments.WorkingDirectoryRelated, relatedProjectName, relatedProjectFile);
                node.Attributes["Include"].Value = include;

                UpdateBinaryReferences(include, false);

                Console.WriteLine(
                    Resources.LogReferencesTo,
                    relatedProjectFile,
                    relatedProjectName,
                    relatedProjectVersion);
            }

            using (XmlTextWriter xtw = new XmlTextWriter(Paths.ProjectFile, Encoding.UTF8))
            {
                xtw.Formatting = Formatting.Indented;
                doc.WriteTo(xtw);
            }
        }
Example #3
0
        /// <summary>
        /// Gets the list of obsolete subfolders.
        /// Returns false if project path is unknown.
        /// </summary>
        public bool GetObsoleteSubfolders(string projectPath, out List <string> obsoleteSubfolders)
        {
            string projectFolder = Path.GetFileName(projectPath);

            string latestVersion = ReferenceFolder.GetLatestVersion(
                Arguments.InternalReferencesPath,
                projectFolder);

            string latestFolderName = Path.GetFileName(
                ReferenceFolder.GetLatestPath(
                    Arguments.InternalReferencesPath,
                    projectFolder));

            obsoleteSubfolders = ObsoleteHelper.GetObsoletePaths(
                Directory.GetDirectories(projectPath),
                new List <string>
            {
                latestVersion,
                latestFolderName
            },
                Arguments.DaysToLive);

            return(true);
        }