internal void AddFileIfMissing(string path)
            {
                path = Path.GetFullPath(path);
                if (!UpdateProjectFile || File.Exists(path) || !ProjectFound)
                {
                    return;
                }

                var line = string.Format(LineFormat, path.Substring(ProjectDir.Length + 1, path.Length - ProjectDir.Length - 1));

                lock (_dictionaryLock)
                {
                    if (ProjectFiles.ContainsKey(line))
                    {
                        return;
                    }

                    ProjectFiles.Add(line, line);
                }
                if (TfsWorkspace != null)
                {
                    // Create File so it can be added:
                    using (File.Create(path))
                    {
                        TfsWorkspace.PendAdd(path, false);
                    }
                }

                ProjectUpdated = true;
            }
예제 #2
0
            internal void AddFileIfMissing(string path)
            {
                path = Path.GetFullPath(path);

                if (!UpdateProjectFile || !ProjectFound)
                {
                    return;
                }

                Log("Checking if project \"{0}\" contains file \"{1}\"", ProjectPath, path);
                var line = string.Format(LineFormat, path.Substring(ProjectDir.Length + 1, path.Length - ProjectDir.Length - 1));

                lock (_dictionaryLock)
                {
                    if (ProjectFiles.ContainsKey(line))
                    {
                        Log("Project \"{0}\" contains file \"{1}\"", ProjectPath, path);
                        return;
                    }

                    Log("Project \"{0}\" does not contains file \"{1}\"", ProjectPath, path);
                    ProjectFiles.Add(line, line);
                }
                if (UseTfsToCheckoutFiles)
                {
                    Tfs.Add(path);
                }

                Console.WriteLine(path + " added to project.");
                ProjectUpdated = true;
            }
예제 #3
0
        public Boolean AddProjectFile(ProjectFile pf)
        {
            if (ProjectFiles.Contains(pf))
            {
                // TODO: maybe the build system is dumb and recompiles the same file multiple times?
                return(false);
            }

            ProjectFiles.Add(pf);

            if (pf.ProjectFolder != null)
            {
                // create project structure
                RelativeCrosspath projectFolder = new RelativeCrosspath(pf.ProjectFolder);
                Stack <String>    todo          = new Stack <String>();
                while (true)
                {
                    String fldr = projectFolder.ToString().Replace('/', '\\');
                    if (fldr == "." || ProjectFilters.Contains(fldr))
                    {
                        break;
                    }

                    todo.Push(fldr);
                    projectFolder.ToContainingDirectory();
                }

                foreach (String filter in todo)
                {
                    ProjectFilters.Add(filter);
                }
            }

            return(true);
        }
예제 #4
0
        public MSBuildProject(FilePath filePath)
        {
            FilePath = filePath;

            _msBuildProject = ProjectRootElement.Open(filePath.FullPath, _globalCollection);

            foreach (var item in _msBuildProject.Items)
            {
                if (item.ItemType == "Reference")
                {
                    References.Add(item.Include);
                }
                else if (item.ItemType == "Compile" || item.ItemType == "None")
                {
                    var entry = new ProjectFileEntry(new FilePath(this.ProjectDirectory, item.Include));

                    foreach (var element in item.Metadata)
                    {
                        if (element.Name == "DependentUpon")
                        {
                            entry.Dependencies.Add(element.Value);
                        }
                    }

                    entry.ParentProject = this;
                    AddFileEventHandlers(entry);
                    ProjectFiles.Add(entry);
                }
            }

            SetupEventHandlers();
            HasUnsavedData = false;
        }
예제 #5
0
 private void ProjectDataService_ProjectLoaded(RecentProject p, EventArgs e)
 {
     ProjectFiles.Clear();
     foreach (BaseMd fileMd in projectDataService.ProjectFiles)
     {
         // Scan for a tag that describes the type.
         // TODO: create the proper model classes to assign them in here.
         //File.OpenRead(filePath);
         ProjectFiles.Add(fileMd);
     }
 }
예제 #6
0
        private void AddProject(Match match, string workingDirectory)
        {
            var projectName = match.Groups["ProjectName"].Value;
            var projectPath = match.Groups["ProjectPath"].Value;

            projectPath = Path.Combine(workingDirectory, projectPath);

            if (ShouldAddProject(projectName, projectPath))
            {
                InfoFormat("Dependency: Adding project files {0} @ {1}...", projectName, projectPath);
                ProjectFiles.Add(projectName, new FileInfo(projectPath));
            }
        }
            internal void AddFileIfMissing(string path)
            {
                path = Path.GetFullPath(path);

                if (!UpdateProjectFile || !ProjectFound)
                {
                    return;
                }

                Log("Checking if project \"{0}\" contains file \"{1}\"", ProjectPath, path);
                var line = string.Format(LineFormat, path.Substring(ProjectDir.Length + 1, path.Length - ProjectDir.Length - 1));

                lock (_dictionaryLock)
                {
                    if (ProjectFiles.ContainsKey(line))
                    {
                        Log("Project \"{0}\" contains file \"{1}\"", ProjectPath, path);
                        return;
                    }

                    Log("Project \"{0}\" does not contains file \"{1}\"", ProjectPath, path);
                    ProjectFiles.Add(line, line);
                }
                if (TfsWorkspace != null)
                {
                    // Create File so it can be added:
                    using (File.Create(path))
                    {
                        Console.WriteLine("Created New File: " + path);
                    }
                    var pendingCompleted = TfsWorkspace.PendAdd(path, false);
                    if (pendingCompleted == 0)
                    {
                        pendingCompleted = TfsWorkspace.PendEdit(path);
                    }
                    if (pendingCompleted == 0)
                    {
                        Log("Unable to Add \"{0}\" to TFS.", path);
                    }
                    else
                    {
                        Log("Unable to Add \"{0}\" to TFS.", path);
                    }
                }

                ProjectUpdated = true;
            }
예제 #8
0
        public MSBuildProject(FilePath filePath)
        {
            FilePath = filePath;

            _msBuildProject = ProjectRootElement.Open(filePath.FullPath, _globalCollection);

            foreach (var item in _msBuildProject.Items)
            {
                if (item.ItemType == "Reference")
                {
                    References.Add(ReadAssemblyReferenceItem(item));
                }
                else if (_fileItemTypes.Contains(item.ItemType))
                {
                    var entry = ReadProjectFileEntryItem(item);
                    AddFileEventHandlers(entry);
                    ProjectFiles.Add(entry);
                }
            }

            SetupEventHandlers();
            HasUnsavedData = false;
        }
예제 #9
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            Init();

            var path = txtPath.Text?.Trim();

            if (string.IsNullOrEmpty(path) || !Directory.Exists(path))
            {
                MessageBox.Show("Please input the correct path which includes .csproj files!", "error");
                return;
            }

            SenparcTrace.SendCustomLog("Task", "Search .csproj files begin.");

            var csprojFiles = Directory.GetFiles(path, "*.csproj", SearchOption.AllDirectories);

            if (csprojFiles == null || csprojFiles.Length == 0)
            {
                MessageBox.Show("No valiable .csproj file!", "error");
                return;
            }

            foreach (var file in csprojFiles)
            {
                try
                {
                    var doc           = XDocument.Load(file);
                    var propertyGroup = doc.Root.Elements("PropertyGroup").FirstOrDefault();
                    if (propertyGroup == null)
                    {
                        SenparcTrace.SendCustomLog("Task Falid", $"{file} is not a valid xml.csproj file.");
                        continue;
                    }

                    var projectFile = PropertyGroup.GetObjet(propertyGroup, file);
                    ProjectFiles.Add(projectFile);
                    ProjectDocuments.Add(doc);

                    SenparcTrace.SendCustomLog("Task", $"[Success] Load file:{file}");
                }
                catch (Exception ex)
                {
                    SenparcTrace.SendCustomLog("Task", $"[Faild] Load file:{file}");
                    SenparcTrace.SendCustomLog("Error", ex.Message);
                }
            }

            if (ProjectFiles.Count == 0)
            {
                MessageBox.Show("No valiable .csproj file!", "error");
                return;
            }

            if (lbFiles.Items.Count > 0)
            {
                lbFiles.SelectedIndex = 0;//default select the first item.
            }

            //lbFiles.DataContext = ProjectFiles;
            //lbFiles.ItemsSource = ProjectFiles;

            //foreach (var projectFile in ProjectFiles)
            //{
            //    BindFileData.Add(new KeyValuePair<string, string>(projectFile.FileName, projectFile.FullFilePath));
            //}
            //lbFiles.ItemsSource = BindFileData;
        }