Exemplo n.º 1
0
 internal SolutionFile(SolutionFileInfo solutionFileInfo, IEnumerable <ProjectFile> projectFiles, IEnumerable <ProjectFile> productiveProjectFiles, IEnumerable <ProjectFile> unitTestProjectFiles)
 {
     SolutionFileInfo   = solutionFileInfo;
     Projects           = projectFiles;
     ProductiveProjects = productiveProjectFiles;
     UnitTestProjects   = unitTestProjectFiles;
 }
Exemplo n.º 2
0
        private SolutionProject GetSolutionProjectEntryFrom(Project project, SolutionFileInfo solutionFileInfo)
        {
            SolutionProject toReturn = new SolutionProject(project.Guid, project.TypeGuid, project.Name, project.RelativePath, project.Sections, project.Dependencies);

            SetAdditionalProjectProperties(toReturn, project.Guid, solutionFileInfo, config =>
            {
                if (!toReturn.ConfigurationPlatformMapping.TryGetValue(config.SolutionConfig, out ProjectConfigurationPlatformMapping mapping))
                {
                    toReturn.ConfigurationPlatformMapping.Add(config.SolutionConfig, mapping = new ProjectConfigurationPlatformMapping());
                }
                mapping.ConfigurationPlatform = config.ProjectConfig;

                switch (config.Property)
                {
                case "ActiveCfg":
                    break;

                case "Build.0":
                    mapping.EnabledForBuild = true;
                    break;
                }
            });

            return(toReturn);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Method copies components
        /// </summary>
        /// <param name="solutionFileInfo">solution info file</param>
        public void CopyComponents(SolutionFileInfo solutionFileInfo)
        {
            solutionFileInfo.Solution[Constants.SourceControlQueueAttributeNameForStatus] = Constants.SourceControlQueuemMergingStatus;
            solutionFileInfo.Update();
            var          solutions    = this.RetrieveSolutions();
            CopySettings copySettings = this.GetCopySettings();

            foreach (var solution in solutions)
            {
                if (solution["uniquename"].ToString().ToLower().Equals(solutionFileInfo.SolutionUniqueName.ToString().ToLower()))
                {
                    copySettings.TargetSolutions.Add(solution);
                }
                else if (solutionFileInfo.SolutionsToBeMerged.Any(cc => cc.ToString().ToLower().Equals(solution["uniquename"].ToString().ToLower())))
                {
                    copySettings.SourceSolutions.Add(solution);
                }
            }

            Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<br><br><table cellpadding='5' cellspacing='0' style='border: 1px solid #ccc;font-size: 9pt;font-family:Arial'><tr><th style='background-color: #B8DBFD;border: 1px solid #ccc'>Copying components into Master Solution</th></tr>");

            var components = this.CopyComponents(copySettings);

            Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</table><br><br>");

            var componentsMaster    = this.RetrieveComponentsFromSolutions(copySettings.TargetSolutions.Select(T => T.Id).ToList(), copySettings.ComponentsTypes);
            var differentComponents = (from cm in componentsMaster where !components.Any(list => list.GetAttributeValue <Guid>("objectid") == cm.GetAttributeValue <Guid>("objectid")) select cm).ToList();

            Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<br><br><table cellpadding='5' cellspacing='0' style='border: 1px solid #ccc;font-size: 9pt;font-family:Arial'><tr><th style='background-color: #B8DBFD;border: 1px solid #ccc'>Displaying different(additional) components after merging</th></tr>");

            if (differentComponents != null)
            {
                foreach (var target in copySettings.TargetSolutions)
                {
                    foreach (var componentdetails in differentComponents)
                    {
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<tr>");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<td style='width:100px;background-color:LightCyan;border: 1px solid #ccc'>");

                        this.GetComponentDetails(copySettings, target, componentdetails, componentdetails.GetAttributeValue <OptionSetValue>("componenttype").Value, componentdetails.GetAttributeValue <Guid>("objectid"), "componenttype", null);
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</td>");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</tr>");
                    }
                }
            }
            else
            {
                Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<tr>");
                Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<td style='width:100px;background-color:LightCyan;border: 1px solid #ccc'>");
                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" No different(additional components found after Merging)");
                Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</td>");
                Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</tr>");
            }

            Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</table><br><br>");
            solutionFileInfo.Solution[Constants.SourceControlQueueAttributeNameForStatus] = Constants.SourceControlQueuemMergingSuccessfulStatus;
            solutionFileInfo.Update();
        }
        /// <summary>
        /// Commits all changes
        /// </summary>
        /// <param name="solutionFileInfo">solution file info</param>
        /// <param name="solutionFilePath">release solution list file</param>
        public void CommitAllChanges(SolutionFileInfo solutionFileInfo, string solutionFilePath)
        {
            try
            {
                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" Committing Powershell Scripts" + "<br>");
                string multilpleSolutionsImportPSPath        = AzureFunction.BinPath + Singleton.CrmConstantsInstance.MultilpleSolutionsImport;
                string multilpleSolutionsImportPSPathVirtual = this.localFolder.FullName + Singleton.CrmConstantsInstance.MultilpleSolutionsImport;
                File.Copy(multilpleSolutionsImportPSPath, multilpleSolutionsImportPSPathVirtual, true);

                string solutionToBeImportedPSPath        = AzureFunction.BinPath + Singleton.CrmConstantsInstance.SolutionToBeImported;
                string solutionToBeImportedPSPathVirtual = this.localFolder + Singleton.CrmConstantsInstance.SolutionToBeImported;
                File.Copy(solutionToBeImportedPSPath, solutionToBeImportedPSPathVirtual, true);

                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" Committing solutions" + "<br>");
                string fileUnmanaged = this.solutionlocalFolder + solutionFileInfo.SolutionUniqueName + "_.zip";
                File.Copy(solutionFileInfo.SolutionFilePath, fileUnmanaged, true);

                string fileManaged = this.solutionlocalFolder + solutionFileInfo.SolutionUniqueName + "_managed_.zip";
                File.Copy(solutionFileInfo.SolutionFilePathManaged, fileManaged, true);

                string webResources = solutionFileInfo.SolutionExtractionPath + "\\WebResources";

                using (var repo = new Repository(this.localFolder.FullName))
                {
                    this.AddRepositoryIndexes(fileUnmanaged, repo);
                    this.AddRepositoryIndexes(fileManaged, repo);
                    this.AddWebResourcesToRepository(webResources, repo);
                    //// todo: add extracted solution files to repository
                    this.AddExtractedSolutionToRepository(solutionFileInfo, repo);

                    repo.Index.Add(solutionFilePath.Replace(this.localFolder.FullName, string.Empty));
                    repo.Index.Add(multilpleSolutionsImportPSPathVirtual.Replace(this.localFolder.FullName, string.Empty));
                    repo.Index.Add(solutionToBeImportedPSPathVirtual.Replace(this.localFolder.FullName, string.Empty));

                    var           offset        = DateTimeOffset.Now;
                    Signature     author        = new Signature(this.authorName, this.authorEmail, offset);
                    Signature     committer     = new Signature(this.committerName, this.committerEmail, offset);
                    CommitOptions commitOptions = new CommitOptions
                    {
                        AllowEmptyCommit = false
                    };

                    var    commit    = repo.Commit(solutionFileInfo.Message, author, committer);
                    string commitIds = solutionFileInfo.Solution.GetAttributeValue <string>(Constants.SourceControlQueueAttributeNameForCommitIds);
                    if (string.IsNullOrEmpty(commitIds))
                    {
                        commitIds = string.Empty;
                    }

                    commitIds += string.Format("Commit Info <br/><a href='{0}/commit/{1}'>{2}</a>", this.repoUrl, commit.Id.Sha, commit.Message);
                    solutionFileInfo.Solution[Constants.SourceControlQueueAttributeNameForCommitIds] = commitIds;
                }
            }
            catch (EmptyCommitException ex)
            {
                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" " + ex.Message + "<br>");
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Method adds extracted solution resources to repository
 /// </summary>
 /// <param name="solutionFileInfo">Solution file information</param>
 /// <param name="repo">repository to be committed</param>
 private void AddExtractedSolutionToRepository(SolutionFileInfo solutionFileInfo, Repository repo)
 {
     if (repo != null)
     {
         this.CopyDirectory(solutionFileInfo.SolutionExtractionPath, this.solutionlocalFolder.FullName + solutionFileInfo.SolutionUniqueName, repo, null);
     }
     else
     {
         this.CopyDirectory(solutionFileInfo.SolutionExtractionPath, this.solutionlocalFolder.FullName + solutionFileInfo.SolutionUniqueName, null, _workspace);
     }
 }
        public static SolutionFile Parse(SolutionFileInfo solutionFileInfo)
        {
            if (solutionFileInfo == null)
            {
                throw new ArgumentNullException(nameof(solutionFileInfo));
            }

            var solutionFile = Microsoft.Build.Construction.SolutionFile.Parse(solutionFileInfo.Value.FullName);

            var projects = solutionFile.ProjectsInOrder.Where(item => Path.GetExtension(item.RelativePath) == ProjectFileExtension)
                           .Select(item => new ProjectFileInfo(item.AbsolutePath))
                           .Select(ProjectFileParser.Parse)
                           .ToList();

            var unitTestProjects   = projects.Where(item => item.ProjectTypes.Any(type => type == ProjectType.Test)).ToList();
            var productiveProjects = projects.Except(unitTestProjects);

            return(new SolutionFile(solutionFileInfo, projects, productiveProjects, unitTestProjects));
        }
Exemplo n.º 7
0
        public void CommitFilesToGitHub(SolutionFileInfo solutionFileInfo, string solutionFilePath, string fileUnmanaged, string fileManaged,
                                        string webResources, string multilpleSolutionsImportPSPathVirtual, string solutionToBeImportedPSPathVirtual)
        {
            try
            {
                using (var repo = new Repository(this.localFolder.FullName))
                {
                    this.AddRepositoryIndexes(fileUnmanaged, repo);
                    this.AddRepositoryIndexes(fileManaged, repo);
                    this.AddWebResourcesToRepository(webResources, repo);
                    //// todo: add extracted solution files to repository
                    this.AddExtractedSolutionToRepository(solutionFileInfo, repo);

                    repo.Index.Add(solutionFilePath.Replace(this.localFolder.FullName, string.Empty));
                    repo.Index.Add(multilpleSolutionsImportPSPathVirtual.Replace(this.localFolder.FullName, string.Empty));
                    repo.Index.Add(solutionToBeImportedPSPathVirtual.Replace(this.localFolder.FullName, string.Empty));
                    var           offset        = DateTimeOffset.Now;
                    Signature     author        = new Signature(this.authorName, this.authorEmail, offset);
                    Signature     committer     = new Signature(this.committerName, this.committerEmail, offset);
                    CommitOptions commitOptions = new CommitOptions
                    {
                        AllowEmptyCommit = false
                    };

                    var    commit    = repo.Commit(solutionFileInfo.Message, author, committer);
                    string commitIds = solutionFileInfo.Solution.GetAttributeValue <string>(Constants.SourceControlQueueAttributeNameForCommitIds);
                    if (string.IsNullOrEmpty(commitIds))
                    {
                        commitIds = string.Empty;
                    }

                    commitIds += string.Format("Commit Info <br/><a href='{0}/commit/{1}'>{2}</a>", this.repoUrl.Replace(".git", ""), commit.Id.Sha, commit.Message);
                    solutionFileInfo.Solution[Constants.SourceControlQueueAttributeNameForCommitIds] = commitIds;
                }
            }
            catch (EmptyCommitException ex)
            {
                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" " + ex.Message + "<br>");
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Method copies components
        /// </summary>
        /// <param name="solutionFileInfo">solution info file</param>
        public void CopyComponents(SolutionFileInfo solutionFileInfo)
        {
            solutionFileInfo.Solution[Constants.SourceControlQueueAttributeNameForStatus] = Constants.SourceControlQueuemMergingStatus;
            solutionFileInfo.Update();
            var          solutions    = this.RetrieveSolutions();
            CopySettings copySettings = this.GetCopySettings();

            foreach (var solution in solutions)
            {
                if (solution["uniquename"].ToString().ToLower().Equals(solutionFileInfo.SolutionUniqueName.ToString().ToLower()))
                {
                    copySettings.TargetSolutions.Add(solution);
                }
                else if (solutionFileInfo.SolutionsToBeMerged.Any(cc => cc.ToString().ToLower().Equals(solution["uniquename"].ToString().ToLower())))
                {
                    copySettings.SourceSolutions.Add(solution);
                }
            }

            this.CopyComponents(copySettings);
            solutionFileInfo.Solution[Constants.SourceControlQueueAttributeNameForStatus] = Constants.SourceControlQueuemMergingSuccessfulStatus;
            solutionFileInfo.Update();
        }
Exemplo n.º 9
0
        private SolutionProject CreateSolutionProjectEntry(CSProjectInfo project, Uri relativePath, SolutionFileInfo solutionFileInfo)
        {
            IEnumerable <SolutionSection> sections = null;

            if (solutionFileInfo.Projects.TryGetValue(project.Guid, out Project parsedProject))
            {
                sections = parsedProject.Sections;
            }

            SolutionProject toReturn = new SolutionProject(project.Guid, SolutionProject.CSharpProjectTypeGuid, project.Name + ".msb4u", relativePath, sections, project.ProjectDependencies.Select(t => t.Dependency.Guid));

            foreach (CompilationPlatformInfo platform in AvailablePlatforms)
            {
                ProcessConfigurationPlatformMapping(toReturn, UnityConfigurationType.InEditor, platform, project.InEditorPlatforms);
                ProcessConfigurationPlatformMapping(toReturn, UnityConfigurationType.Player, platform, project.PlayerPlatforms);
            }

            SetAdditionalProjectProperties(toReturn, project.Guid, solutionFileInfo);

            return(toReturn);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Method updates repository
        /// </summary>
        public Workspace ConnectTFSMap(SolutionFileInfo solutionFileInfo, string solutionFilePath, HashSet <string> hashSet)
        {
            try
            {
                string wkSpcName    = "C" + DateTime.Today.DayOfYear + DateTime.Today.Minute;
                bool   folderExists = Directory.Exists(this.localFolder.FullName);
                //if (!folderExists)
                //{
                //    Directory.CreateDirectory(this.localFolder.FullName);
                //}

                NetworkCredential  networkCredential = new NetworkCredential(this.tfsUserName, this.tfsPassword);
                VssBasicCredential basicCredential   = new VssBasicCredential(networkCredential);

                VssCredentials tfsCredentials = new VssCredentials(basicCredential);

                _tfs = new TfsTeamProjectCollection(new Uri(this.repoUrl), tfsCredentials);
                _tfs.Authenticate();
                // Get a reference to Version Control.
                _versionControl = _tfs.GetService <VersionControlServer>();

                Workspace workspace = _versionControl.QueryWorkspaces(
                    wkSpcName,
                    _versionControl.AuthorizedUser,
                    Environment.MachineName).SingleOrDefault();

                Console.WriteLine("existing workspace" + workspace);
                if (workspace != null)
                {
                    Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine("existing workspace delete <br/>" + _versionControl.AuthorizedUser);

                    workspace.Delete();
                }
                else
                {
                    Console.WriteLine(" workspace is null");
                }

                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" <br/>" + _versionControl.AuthorizedUser);

                Console.WriteLine("workspace create");
                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine("workspace create <br/>");

                _workspace = _versionControl.CreateWorkspace(wkSpcName);
                Console.WriteLine(" workspace created;");
                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine("workspace created <br/>");


                // Create a mapping using the Team Project supplied on the command line.
                _workspace.Map(this.branchName, this.localFolder.ToString());
                Console.WriteLine("Completed: Map;");

                // Get the files from the repository.
                _workspace.Get();
                _workspace.PendEdit(this.localFolder.FullName.ToString());

                Console.WriteLine("Completed: Files Mapped ");
                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine("Completed: Files Mapped  <br/>");
                this.CommitAllChanges(solutionFileInfo, solutionFilePath, hashSet);
            }
            catch (Exception ex)
            {
                if (_workspace != null)
                {
                    _workspace.Delete();
                }
                Console.WriteLine(ex.Message);
                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(ex.Message);


                bool folderExists = Directory.Exists(this.localFolder.FullName);
                if (folderExists)
                {
                    var fList = Directory.GetFiles(this.localFolder.FullName, "*.*", SearchOption.AllDirectories);
                    foreach (var f in fList)
                    {
                        File.Delete(f);
                    }
                    Directory.Delete(this.localFolder.FullName, true);
                }
                throw ex;
            }
            return(_workspace);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Commits all changes
        /// </summary>
        /// <param name="solutionFileInfo">solution file info</param>
        /// <param name="solutionFilePath">release solution list file</param>
        public void CommitAllChanges(SolutionFileInfo solutionFileInfo, string solutionFilePath, HashSet <string> hashSet)
        {
            try
            {
                string multilpleSolutionsImportPSPath        = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Singleton.CrmConstantsInstance.MultilpleSolutionsImport);
                string multilpleSolutionsImportPSPathVirtual = this.localFolder + Singleton.CrmConstantsInstance.MultilpleSolutionsImport;
                string solutionToBeImportedPSPath            = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Singleton.CrmConstantsInstance.SolutionToBeImported);
                string solutionToBeImportedPSPathVirtual     = this.localFolder + Singleton.CrmConstantsInstance.SolutionToBeImported;
                string fileUnmanaged = this.solutionlocalFolder + solutionFileInfo.SolutionUniqueName + "_.zip";
                string fileManaged   = this.solutionlocalFolder + solutionFileInfo.SolutionUniqueName + "_managed_.zip";
                string webResources  = solutionFileInfo.SolutionExtractionPath + "\\WebResources";

                if (this._workspace == null && solutionFileInfo.Repository != Constants.SourceControlAzureDevOpsServer)
                {
                    Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" Committing Powershell Scripts" + "<br>");
                    Console.WriteLine("Committing Powershell Scripts");
                    File.Copy(multilpleSolutionsImportPSPath, multilpleSolutionsImportPSPathVirtual, true);
                    File.Copy(solutionToBeImportedPSPath, solutionToBeImportedPSPathVirtual, true);
                    Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" Committing solutions" + "<br>");
                    Console.WriteLine("Committing solutions");
                    Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" Copy managed" + "<br>");
                    File.Copy(solutionFileInfo.SolutionFilePathManaged, fileManaged, true);
                    Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" Copy unmanaged" + "<br>");
                    File.Copy(solutionFileInfo.SolutionFilePath, fileUnmanaged, true);
                    CommitFilesToGitHub(solutionFileInfo, solutionFilePath, fileUnmanaged, fileManaged, webResources, multilpleSolutionsImportPSPathVirtual, solutionToBeImportedPSPathVirtual);
                }
                else
                {
                    SaveSolutionfile(solutionFilePath, hashSet);
                    //Copy Zip Files
                    Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" Committing solutions" + "<br>");
                    Console.WriteLine("Committing solutions");

                    bool solutionfileUnManagedExit = _versionControl.ServerItemExists(_workspace.GetServerItemForLocalItem(fileUnmanaged), ItemType.Any);
                    if (solutionfileUnManagedExit)
                    {
                        //_workspace.PendEdit(fileUnmanaged, RecursionType.Full);
                        Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" Copy unmanaged" + "<br>");
                        File.Copy(solutionFileInfo.SolutionFilePath, fileUnmanaged, true);
                    }
                    else
                    {
                        Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" Copy unmanaged" + "<br>");
                        File.Copy(solutionFileInfo.SolutionFilePath, fileUnmanaged, true);
                        _workspace.PendAdd(fileUnmanaged, true);
                    }


                    bool solutionfileManagedExit = _versionControl.ServerItemExists(_workspace.GetServerItemForLocalItem(fileUnmanaged), ItemType.Any);
                    if (solutionfileManagedExit)
                    {
                        //_workspace.PendEdit(fileUnmanaged, RecursionType.Full);
                        Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" Copy managed" + "<br>");
                        File.Copy(solutionFileInfo.SolutionFilePathManaged, fileManaged, true);
                    }
                    else
                    {
                        Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" Copy managed" + "<br>");
                        File.Copy(solutionFileInfo.SolutionFilePathManaged, fileManaged, true);
                        _workspace.PendAdd(fileUnmanaged, true);
                    }

                    Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" Committing Powershell Scripts" + "<br>");
                    Console.WriteLine("Committing Powershell Scripts");

                    //Copy PowerShell
                    bool fileExit = _versionControl.ServerItemExists(_workspace.GetServerItemForLocalItem(multilpleSolutionsImportPSPathVirtual), ItemType.Any);
                    if (fileExit)
                    {
                        // _workspace.PendEdit(multilpleSolutionsImportPSPathVirtual, RecursionType.Full);
                        File.Copy(multilpleSolutionsImportPSPath, multilpleSolutionsImportPSPathVirtual, true);
                    }
                    else
                    {
                        File.Copy(multilpleSolutionsImportPSPath, multilpleSolutionsImportPSPathVirtual, true);
                        _workspace.PendAdd(multilpleSolutionsImportPSPathVirtual, true);
                    }

                    //Copy PowerShell

                    bool exits = _versionControl.ServerItemExists(_workspace.GetServerItemForLocalItem(solutionToBeImportedPSPathVirtual), ItemType.Any);
                    if (exits)
                    {
                        // _workspace.PendEdit(solutionToBeImportedPSPathVirtual, RecursionType.Full);
                        File.Copy(solutionToBeImportedPSPath, solutionToBeImportedPSPathVirtual, true);
                    }
                    else
                    {
                        File.Copy(solutionToBeImportedPSPath, solutionToBeImportedPSPathVirtual, true);
                        _workspace.PendAdd(solutionToBeImportedPSPathVirtual, true);
                    }

                    CommitFilesToTFS(solutionFileInfo, solutionFilePath, fileUnmanaged, fileManaged, webResources, multilpleSolutionsImportPSPathVirtual, solutionToBeImportedPSPathVirtual, _workspace);
                }
            }
            catch (Exception ex)
            {
                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" " + ex.Message + "<br>");
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 12
0
        public void CommitFilesToTFS(SolutionFileInfo solutionFileInfo, string solutionFilePath, string fileUnmanaged, string fileManaged,
                                     string webResources, string multilpleSolutionsImportPSPathVirtual, string solutionToBeImportedPSPathVirtual, Workspace workspace)
        {
            try
            {
                this._workspace = workspace;
                this.AddRepositoryIndexes(fileUnmanaged, null);
                this.AddRepositoryIndexes(fileManaged, null);
                this.AddWebResourcesToRepository(webResources, null);
                //// todo: add extracted solution files to repository
                this.AddExtractedSolutionToRepository(solutionFileInfo, null);
                List <PendingChange> pc = new List <PendingChange>(_workspace.GetPendingChanges());

                PendingChange[] pcArr = pc.Where(x => x.ChangeType != ChangeType.Delete && x.ItemType != ItemType.Folder && x.FileName != this.localFolder.FullName.ToString()).ToArray();

                if (pcArr.Length > 0)
                {
                    _workspace.CheckIn(pcArr, "Automated Checkin (" + _workspace + ") " + DateTime.Today.ToShortDateString());
                    Console.WriteLine("Completed: Checkin");
                    Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" <br/> Completed: Checkin");
                }

                foreach (var pchg in pc)
                {
                    Console.WriteLine(pchg.ChangeType.ToString() + "::" + pchg.FileName);
                    Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine("<br/>" + pchg.ChangeType.ToString() + "::" + pchg.FileName);
                }

                _workspace.Delete();

                bool folderExists = Directory.Exists(this.localFolder.FullName);
                if (folderExists)
                {
                    var fList = Directory.GetFiles(this.localFolder.FullName, "*.*", SearchOption.AllDirectories);
                    foreach (var f in fList)
                    {
                        File.Delete(f);
                    }
                    Directory.Delete(this.localFolder.FullName, true);
                }

                solutionFileInfo.Update();
                solutionFileInfo.Solution[Constants.SourceControlQueueAttributeNameForStatus] = Constants.SourceControlQueuemPushToRepositorySuccessStatus;
                solutionFileInfo.Solution.Attributes["syed_webjobs"] = Singleton.SolutionFileInfoInstance.WebJobs();

                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" " + "Successfully Pushed files to TFS" + "<br>");
                Console.WriteLine("Successfully Pushed files to TFS");
                Singleton.SolutionFileInfoInstance.UploadFiletoDynamics(Singleton.CrmConstantsInstance.ServiceProxy, solutionFileInfo.Solution);
            }
            catch (Exception ex)
            {
                Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" " + ex.Message + "<br>");
                Console.WriteLine(ex.Message);
                if (_workspace != null)
                {
                    _workspace.Delete();
                }

                bool folderExists = Directory.Exists(this.localFolder.FullName);
                if (folderExists)
                {
                    var fList = Directory.GetFiles(this.localFolder.FullName, "*.*", SearchOption.AllDirectories);
                    foreach (var f in fList)
                    {
                        File.Delete(f);
                    }
                    Directory.Delete(this.localFolder.FullName, true);
                }
                throw ex;
            }
        }
        public void WhenClassWasCreated_ThenExpectedValuesHasToBeSet()
        {
            var result = new SolutionFileInfo(@"D:\GitHub\SolutionAndProjects\SolutionAndProjects\SolutionAndProjects\SolutionAndProjects.sln");

            Assert.AreEqual(@"D:\GitHub\SolutionAndProjects\SolutionAndProjects\SolutionAndProjects\SolutionAndProjects.sln", result.Value.FullName);
        }
Exemplo n.º 14
0
 private void SetAdditionalProjectProperties(SolutionProject solutionProject, Guid projectGuid, SolutionFileInfo solutionFileInfo, Action <ProjectConfigurationEntry> knownConfigHandler = null)
 {
     // Parse additional properties
     if (solutionFileInfo.ProjectConfigurationEntires.TryGetValue(projectGuid, out List <ProjectConfigurationEntry> projectConfigurations))
     {
         foreach (ProjectConfigurationEntry config in projectConfigurations)
         {
             if (config.Property != "Build.0" && config.Property != "ActiveCfg")
             {
                 if (solutionProject.ConfigurationPlatformMapping.TryGetValue(config.SolutionConfig, out ProjectConfigurationPlatformMapping mapping))
                 {
                     mapping.AdditionalPropertyMappings[config.Property] = config.ProjectConfig;
                 }
             }
             else
             {
                 knownConfigHandler?.Invoke(config);
             }
         }
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// Commits all changes
        /// </summary>
        /// <param name="solutionFileInfo">solution file info</param>
        /// <param name="solutionFilePath">release solution list file</param>
        public void CommitAllChanges(SolutionFileInfo solutionFileInfo, string solutionFilePath)
        {
            try
            {
                Console.WriteLine("Committing solutions");
                string file = this.solutionlocalFolder + solutionFileInfo.SolutionFileZipName;
                File.Copy(solutionFileInfo.SolutionFilePath, file, true);
                string webResources = solutionFileInfo.SolutionExtractionPath + "\\WebResources";

                using (var repo = new Repository(this.localFolder.FullName))
                {
                    if (string.IsNullOrEmpty(file))
                    {
                        var files = this.solutionlocalFolder.GetFiles("*.zip").Select(f => f.FullName);

                        {
                            foreach (var f in files)
                            {
                                if (string.IsNullOrEmpty(file))
                                {
                                    repo.Index.Add(f.Replace(this.localFolder.FullName, string.Empty));
                                }
                                else
                                {
                                    if (f.EndsWith(file))
                                    {
                                        repo.Index.Add(f.Replace(this.localFolder.FullName, string.Empty));
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        repo.Index.Add(file.Replace(this.localFolder.FullName, string.Empty));
                    }

                    this.AddWebResourcesToRepository(webResources, repo);

                    // todo: add extracted solution files to repository
                    this.AddExtractedSolutionToRepository(solutionFileInfo, repo);

                    repo.Index.Add(solutionFilePath.Replace(this.localFolder.FullName, string.Empty));

                    var           offset        = DateTimeOffset.Now;
                    Signature     author        = new Signature(this.authorName, this.authorEmail, offset);
                    Signature     committer     = new Signature(this.committerName, this.committerEmail, offset);
                    CommitOptions commitOptions = new CommitOptions
                    {
                        AllowEmptyCommit = false
                    };

                    var    commit    = repo.Commit(solutionFileInfo.Message, author, committer);
                    string commitIds = solutionFileInfo.Solution.GetAttributeValue <string>(Constants.SourceControlQueueAttributeNameForCommitIds);
                    if (string.IsNullOrEmpty(commitIds))
                    {
                        commitIds = string.Empty;
                    }

                    commitIds += string.Format("Commit Info <br/><a href='{0}/commit/{1}'>{2}</a>", this.repoUrl, commit.Id.Sha, commit.Message);
                    solutionFileInfo.Solution[Constants.SourceControlQueueAttributeNameForCommitIds] = commitIds;
                }
            }
            catch (EmptyCommitException ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// Method adds extracted solution resources to repository
 /// </summary>
 /// <param name="solutionFileInfo">Solution file information</param>
 /// <param name="repo">repository to be committed</param>
 private void AddExtractedSolutionToRepository(SolutionFileInfo solutionFileInfo, Repository repo)
 {
     this.CopyDirectory(solutionFileInfo.SolutionExtractionPath, this.solutionlocalFolder.FullName + solutionFileInfo.SolutionUniqueName, repo);
 }
Exemplo n.º 17
0
        public void ExportSolution(IUnityProjectExporter unityProjectExporter, FileInfo solutionFilePath, DirectoryInfo generatedProjectsFolder)
        {
            SolutionFileInfo  solutionFileInfo = TextSolutionFileParser.ParseExistingSolutionFile(logger, solutionFilePath.FullName);
            ISolutionExporter exporter         = unityProjectExporter.CreateSolutionExporter(logger, solutionFilePath);

            //TODO we need to figure out how to handle existing projects

            // Remove known folders
            solutionFileInfo.Projects.Remove(config.BuiltInPackagesFolderGuid);
            solutionFileInfo.Projects.Remove(config.ImportedPackagesFolderGuid);
            solutionFileInfo.Projects.Remove(config.ExternalPackagesFolderGuid);

            // Process generated projects
            foreach (KeyValuePair <string, CSProjectInfo> projectPair in CSProjects)
            {
                Uri relativePath = Utilities.GetRelativeUri(solutionFilePath.Directory.FullName, MSBuildUnityProjectExporter.GetProjectPath(projectPair.Value, generatedProjectsFolder).FullName);
                exporter.AddProject(CreateSolutionProjectEntry(projectPair.Value, relativePath, solutionFileInfo), isGenerated: true);
            }

            // Add dependency project
            string dependencyProjectName = $"{UnityProjectName}.Dependencies.msb4u";

            exporter.AddProject(GetDependencyProjectReference(dependencyProjectName, $"{dependencyProjectName}.csproj"), isGenerated: true);

            // Process existing projects
            foreach (KeyValuePair <Guid, Project> projectPair in solutionFileInfo.Projects)
            {
                if (!exporter.Projects.ContainsKey(projectPair.Key) &&
                    !solutionFileInfo.MSB4UGeneratedItems.Contains(projectPair.Key) &&
                    projectPair.Value.TypeGuid != SolutionProject.FolderTypeGuid)
                {
                    exporter.AddProject(GetSolutionProjectEntryFrom(projectPair.Value, solutionFileInfo));
                }
            }

            // Bring forward the properties, then set the one we care about
            exporter.Properties.AddRange(solutionFileInfo.Properties);
            exporter.Properties["HideSolutionNode"] = "FALSE";

            // Bring forward the extensibility globals, then set the one we care about
            exporter.ExtensibilityGlobals.AddRange(solutionFileInfo.ExtensibilityGlobals);
            exporter.ExtensibilityGlobals["SolutionGuid"] = "{" + config.SolutionGuid.ToString().ToUpper() + "}";

            // Bring forward the pairs, and then set the platforms we know of
            exporter.ConfigurationPlatforms.AddRange(solutionFileInfo.ConfigPlatformPairs);
            foreach (CompilationPlatformInfo platform in AvailablePlatforms)
            {
                exporter.ConfigurationPlatforms.Add(new ConfigurationPlatformPair(UnityConfigurationType.InEditor, platform.Name));
                exporter.ConfigurationPlatforms.Add(new ConfigurationPlatformPair(UnityConfigurationType.Player, platform.Name));
            }

            // Set the folders by scanning for "projects" with folder type in old projects
            foreach (KeyValuePair <Guid, Project> folderPair in solutionFileInfo.Projects.Where(t => t.Value.TypeGuid == SolutionProject.FolderTypeGuid))
            {
                exporter.GetOrAddFolder(folderPair.Key, folderPair.Value.Name)
                .Children.AddRange(solutionFileInfo.ChildToParentNestedMappings.Where(t => t.Value == folderPair.Key).Select(t => t.Key));
            }

            Dictionary <AssetLocation, Tuple <Guid, string> > knownFolderMapping = GetKnownFolderMapping();

            // Confiure known folders for generated projects
            ProcessSetForKnownFolders(exporter, knownFolderMapping, CSProjects.Values, t => t.AssemblyDefinitionInfo.AssetLocation, t => t.Guid);

            //TODO handle existing projects

            exporter.AdditionalSections = solutionFileInfo.SolutionSections;

            exporter.Write();
        }
Exemplo n.º 18
0
        public void WhenClassWasCreated_ThenExpectedValuesHasToBeSet()
        {
            var result = new SolutionFileInfo(@"D:\GitHub\SolutionAndProjects\SolutionAndProjects\SolutionAndProjectstest\SpecificFileInfos\CSharpFileInfoTest.cs");

            Assert.AreEqual(@"D:\GitHub\SolutionAndProjects\SolutionAndProjects\SolutionAndProjectstest\SpecificFileInfos\CSharpFileInfoTest.cs", result.Value.FullName);
        }