Ejemplo n.º 1
0
        public void Execute()
        {
            var walker = _directoryWalkerFactory.New(x =>
            {
                x.Directory(_directory);

                x.FileRule(y =>
                {
                    y.Extension("csproj");

                    y.Execute(filePath =>
                    {
                        try
                        {
                            var filePathUri = new Uri(filePath);

                            var project = new Project(filePath);

                            var items = project.Items.Where(item =>
                                                            item.ItemType == "Reference" &&
                                                            item.Metadata.Any(md =>
                                                                              md.Name == "HintPath" && md.UnevaluatedValue.Contains("packages")
                                                                              )
                                                            ).ToList();

                            items.ForEach(item =>
                            {
                                var hintPathMetadata = item.Metadata.First(md => md.Name == "HintPath");

                                var oldHintPath = hintPathMetadata.UnevaluatedValue;

                                var oldHintPathParts = oldHintPath.Split(
                                    new[] { "packages" },
                                    StringSplitOptions.RemoveEmptyEntries);

                                var newHintPath    = _newPath + oldHintPathParts[1];
                                var newHintPathUri = new Uri(newHintPath);

                                var newRelativeHintPathUri = filePathUri.MakeRelativeUri(newHintPathUri);

                                hintPathMetadata.UnevaluatedValue = newRelativeHintPathUri.ToString();

                                _traceWriter.Output(string.Format("Switch: {0} to {1}", oldHintPath, hintPathMetadata.UnevaluatedValue));
                            });

                            project.Save();
                        }
                        catch (InvalidProjectFileException)
                        {
                            _traceWriter.Output(string.Format("Skipping: {0}", filePath));
                        }
                    });
                });
            });

            walker.Execute();
        }
Ejemplo n.º 2
0
        public void Execute()
        {
            var walker = _directoryWalkerFactory.New(x =>
            {
                x.Directory(_directory);

                _excludes.ToList().ForEach(x.Exclude);

                x.FileRule(y =>
                {
                    y.Extension("csproj");

                    y.Execute(filePath =>
                    {
                        try
                        {
                            var filePathUri    = new Uri(filePath);
                            var newHintPathUri = new Uri(_packagePath);

                            var newRelativeHintPathUri = filePathUri.MakeRelativeUri(newHintPathUri);

                            var project = new Project(filePath);

                            if (!TryRemoveReference(project, _isProject, _itemName, _itemPath))
                            {
                                return;
                            }

                            _traceWriter.Output(string.Format("Working on: {0}", filePath));

                            _traceWriter.Output(string.Format("Adding reference: {0}, {1}", _itemName, newRelativeHintPathUri));
                            AddAssemblyReference(project, _itemName, newRelativeHintPathUri);

                            _traceWriter.Output("Updating packages.config");
                            UpdatePackagesConfig(project, _packageName, _packageVersion);

                            AddPackagesConfigItem(project);

                            _traceWriter.Output("Saving...");
                            project.Save();
                        }
                        catch (InvalidProjectFileException)
                        {
                            _traceWriter.Output(string.Format("Skipping: {0}", filePath));
                        }
                    });
                });
            });

            walker.Execute();
        }
Ejemplo n.º 3
0
        public void Execute()
        {
            var graph = new DataAccess.Graphing.Graph();
            var nodes = new List <INode>();

            var walker = _directoryWalkerFactory.New(x =>
            {
                x.Directory(_directory);

                _excludes.ToList().ForEach(x.Exclude);

                x.FileRule(y =>
                {
                    y.Extension("sln");
                    y.Execute(filePath =>
                    {
                        Solution solution;
                        Solution.TryParse(_directory, filePath, out solution);

                        nodes.Add(solution);
                    });
                });

                x.FileRule(y =>
                {
                    y.Extension("csproj");
                    y.Execute(filePath =>
                    {
                        Project project;
                        Project.TryParse(_directory, filePath, out project);

                        nodes.Add(project);
                    });
                });
            });

            walker.TraceAction(_traceWriter.Output);
            walker.Execute();

            _traceWriter.Output("Adding nodes to graph...");
            nodes.ForEach(n => graph.AddNode(n));

            _traceWriter.Output("Computing edge weights");
            graph.ComputeWeights();

            _traceWriter.Output("Saving to database...");
            _graphDatabase.Save(graph);
        }
Ejemplo n.º 4
0
        public void Execute()
        {
            var walker = _directoryWalkerFactory.New(x =>
            {
                x.Directory(_directory);

                _excludes.ToList().ForEach(x.Exclude);

                _includes.ToList().ForEach(i =>
                {
                    x.DirectoryRule(r =>
                    {
                        r.Name(i);
                        r.Execute(dir => Directory.Delete(dir, true));
                    });
                });
            });

            walker.TraceAction(_traceWriter.Output);
            walker.Execute();
        }
Ejemplo n.º 5
0
        public void Execute()
        {
            var walker = _directoryWalkerFactory.New(x =>
            {
                x.Directory(_settings.Directory);
                _settings.Excludes.ToList().ForEach(x.Exclude);

                x.FileRule(y =>
                {
                    y.Extension("csproj");

                    y.Execute(filePath =>
                    {
                        try
                        {
                            var frameworks = new[] { "v3.5", "v4.0", "v4.5" };

                            var project = new Project(filePath);

                            var targetFrameworkVersion = project.Properties.FirstOrDefault(p => p.Name == "TargetFrameworkVersion");

                            if (targetFrameworkVersion == null || !frameworks.Contains(targetFrameworkVersion.UnevaluatedValue))
                            {
                                return;
                            }

                            targetFrameworkVersion.UnevaluatedValue = _settings.TargetFramework;

                            project.Save();
                        }
                        catch (InvalidProjectFileException)
                        {
                            _traceWriter.Output(string.Format("Skipping: {0}", filePath));
                        }
                    });
                });
            });

            walker.Execute();
        }
Ejemplo n.º 6
0
        public void Execute()
        {
            var walker = _directoryWalkerFactory.New(x =>
            {
                x.Directory(_directory);

                _excludes.ToList().ForEach(x.Exclude);

                x.FileRule(y =>
                {
                    y.Extension("sln");

                    y.Execute(filePath =>
                    {
                        Solution.RemoveProject(_directory, filePath, _projectName);
                    });
                });
            });

            walker.TraceAction(_traceWriter.Output);
            walker.Execute();
        }
Ejemplo n.º 7
0
        public void Execute()
        {
            var walker = _directoryWalkerFactory.New(x =>
            {
                x.Directory(_directory);

                _excludes.ToList().ForEach(x.Exclude);

                x.FileRule(y =>
                {
                    y.Extension("csproj");

                    y.Execute(filePath =>
                    {
                        try
                        {
                            var project = new Project(filePath);

                            if (!TryRemoveReference(project, _isProject, _itemName, _itemPath))
                            {
                                return;
                            }

                            _traceWriter.Output(string.Format("Saving project: {0}", filePath));
                            project.Save();
                        }
                        catch (InvalidProjectFileException)
                        {
                            _traceWriter.Output(string.Format("Skipping: {0}", filePath));
                        }
                    });
                });
            });

            walker.Execute();
        }