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 PreHandleCrmAssemblyProjects(Dictionary <string, string> replacementsDictionary) { var sdkVersionPicker = new SdkVersionPicker(_needsWorkflow, _needsClient); var result = sdkVersionPicker.ShowModal(); if (!result.HasValue || result.Value == false) { throw new WizardBackoutException(); } _coreVersion = sdkVersionPicker.CoreVersion; _clientVersion = sdkVersionPicker.ClientVersion; _clientPackage = sdkVersionPicker.ClientPackage; if (!string.IsNullOrEmpty(_clientVersion)) { ProjectDataHandler.AddOrUpdateReplacements("$useXrmToolingClientUsing$", Versioning.StringToVersion(_clientVersion).Major >= 8 ? "1" : "0", ref replacementsDictionary); } var coreVersion = Versioning.StringToVersion(_coreVersion); var v462BaseVersion = new Version(9, 0, 2, 9); if ((_crmProjectType == ProjectType.Console && _clientPackage != Resource.SdkAssemblyExtensions) || coreVersion >= v462BaseVersion) { var targetFrameworkVersion = Versioning.StringToVersion(replacementsDictionary["$targetframeworkversion$"]); if (targetFrameworkVersion < new Version(4, 6, 2)) { ProjectDataHandler.AddOrUpdateReplacements("$targetframeworkversion$", "4.6.2", ref replacementsDictionary); } // 4.7.1 is max version for plug-ins & workflows Online if (targetFrameworkVersion >= new Version(4, 7, 2) && _crmProjectType == ProjectType.Plugin || _crmProjectType == ProjectType.Workflow) { ProjectDataHandler.AddOrUpdateReplacements("$targetframeworkversion$", "4.7.1", ref replacementsDictionary); } } else { ProjectDataHandler.AddOrUpdateReplacements("$targetframeworkversion$", "4.5.2", ref replacementsDictionary); }; }
private void PreHandleCrmAssemblyProjects(Dictionary <string, string> replacementsDictionary) { var sdkVersionPicker = new SdkVersionPicker(_needsWorkflow, _needsClient); bool?result = sdkVersionPicker.ShowModal(); if (!result.HasValue || result.Value == false) { throw new WizardBackoutException(); } _coreVersion = sdkVersionPicker.CoreVersion; _clientVersion = sdkVersionPicker.ClientVersion; _clientPackage = sdkVersionPicker.ClientPackage; if (!string.IsNullOrEmpty(_clientVersion)) { ProjectDataHandler.AddOrUpdateReplacements("$useXrmToolingClientUsing$", Versioning.StringToVersion(_clientVersion).Major >= 8 ? "1" : "0", ref replacementsDictionary); } }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { try { _dte = (DTE)automationObject; ProjectDataHandler.AddOrUpdateReplacements("$referenceproject$", "False", ref replacementsDictionary); if (replacementsDictionary.ContainsKey("$destinationdirectory$")) { _destDirectory = replacementsDictionary["$destinationdirectory$"]; } if (replacementsDictionary.ContainsKey("$wizarddata$")) { var wizardData = replacementsDictionary["$wizarddata$"]; ReadWizardData(wizardData); } if (_isUnitTest) { PreHandleUnitTestProjects(replacementsDictionary); } if (_needsCore) { PreHandleCrmAssemblyProjects(replacementsDictionary); } if (_crmProjectType == ProjectType.CustomItem) { replacementsDictionary = PreHandleCustomItem(replacementsDictionary); } if (_crmProjectType == ProjectType.TypeScript) { PreHandleTypeScriptProjects(); } } catch (WizardBackoutException) { try { var destination = new DirectoryInfo(replacementsDictionary["$destinationdirectory$"]); FileSystem.DeleteDirectory(replacementsDictionary["$destinationdirectory$"]); //Delete solution directory if empty if (destination.Parent != null && FileSystem.IsDirectoryEmpty(replacementsDictionary["$solutiondirectory$"])) { FileSystem.DeleteDirectory(replacementsDictionary["$solutiondirectory$"]); } } catch { // If it fails (doesn't exist/contains files/read-only), let the directory stay. } throw; } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_TemplateWizardError, ex); MessageBox.Show(Resource.ErrorMessage_TemplateWizardError); throw new WizardCancelledException(Resource.ErrorMessage_WizardCancelInternalError, ex); } }