示例#1
0
        private void PreHandleUnitTestProjects(Dictionary <string, string> replacementsDictionary)
        {
            var testProjectPicker = new TestProjectPicker();
            var result            = testProjectPicker.ShowModal();

            if (!result.HasValue || result.Value == false)
            {
                throw new WizardBackoutException();
            }

            if (testProjectPicker.SelectedProject != null)
            {
                var solution     = _dte.Solution;
                var project      = testProjectPicker.SelectedProject;
                var path         = string.Empty;
                var projectPath  = Path.GetDirectoryName(project.FullName);
                var solutionPath = Path.GetDirectoryName(solution.FullName);
                if (!string.IsNullOrEmpty(projectPath) && !string.IsNullOrEmpty(solutionPath))
                {
                    if (projectPath.StartsWith(solutionPath))
                    {
                        path = "..\\" + project.UniqueName;
                    }
                    else
                    {
                        path = project.FullName;
                    }
                }

                ProjectDataHandler.AddOrUpdateReplacements("$referenceproject$", "True", ref replacementsDictionary);
                ProjectDataHandler.AddOrUpdateReplacements("$projectPath$", path, ref replacementsDictionary);
                ProjectDataHandler.AddOrUpdateReplacements("$projectId$", project.Kind, ref replacementsDictionary);
                ProjectDataHandler.AddOrUpdateReplacements("$projectName$", project.Name, ref replacementsDictionary);
            }

            if (testProjectPicker.SelectedUnitTestFramework != null)
            {
                _unitTestFrameworkPackage = testProjectPicker.SelectedUnitTestFramework.NugetName;

                ProjectDataHandler.AddOrUpdateReplacements("$useXrmToolingClientUsing$",
                                                           testProjectPicker.SelectedUnitTestFramework.CrmMajorVersion >= 8 ? "1" : "0", ref replacementsDictionary);
            }
            else
            {
                if (testProjectPicker.SelectedProject == null)
                {
                    return;
                }

                var version = ProjectWorker.GetSdkCoreVersion(testProjectPicker.SelectedProject);
                ProjectDataHandler.AddOrUpdateReplacements("$useXrmToolingClientUsing$",
                                                           Versioning.StringToVersion(version).Major >= 8 ? "1" : "0", ref replacementsDictionary);
            }
        }
        private void PreHandleUnitTestProjects(Dictionary <string, string> replacementsDictionary)
        {
            var  testProjectPicker = new TestProjectPicker();
            bool?result            = testProjectPicker.ShowModal();

            if (testProjectPicker.SelectedProject != null)
            {
                //TODO: Why am I doing this?
                Solution solution     = _dte.Solution;
                Project  project      = testProjectPicker.SelectedProject;
                string   path         = string.Empty;
                string   projectPath  = Path.GetDirectoryName(project.FullName);
                string   solutionPath = Path.GetDirectoryName(solution.FullName);
                if (!string.IsNullOrEmpty(projectPath) && !string.IsNullOrEmpty(solutionPath))
                {
                    if (projectPath.StartsWith(solutionPath))
                    {
                        path = "..\\" + project.UniqueName;
                    }
                    else
                    {
                        path = project.FullName;
                    }
                }

                replacementsDictionary["$referenceproject$"] = "True";
                replacementsDictionary.Add("$projectPath$", path);
                replacementsDictionary.Add("$projectId$", project.Kind);
                replacementsDictionary.Add("$projectName$", project.Name);
            }

            if (testProjectPicker.SelectedUnitTestFramework != null)
            {
                _unitTestFrameworkPackage = testProjectPicker.SelectedUnitTestFramework.NugetName;

                replacementsDictionary.Add("$useXrmToolingClientUsing$",
                                           testProjectPicker.SelectedUnitTestFramework.CrmMajorVersion >= 8 ? "1" : "0");
            }
            else
            {
                if (testProjectPicker.SelectedProject == null)
                {
                    return;
                }

                string version = ProjectWorker.GetSdkCoreVersion(testProjectPicker.SelectedProject);
                replacementsDictionary.Add("$useXrmToolingClientUsing$",
                                           Versioning.StringToVersion(version).Major >= 8 ? "1" : "0");
            }
        }