コード例 #1
0
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            // Get SDK path
            tpath = ToolsPathInfo.ToolsRootPath;
            if (string.IsNullOrEmpty(tpath))
            {
                RegistryKey kpath = Registry.CurrentUser.OpenSubKey(kname);
                tpath = kpath?.GetValue("ToolsPath") as string;
                if (!string.IsNullOrEmpty(tpath))
                {
                    tpath = tpath.Substring(16); // Remove System.String prefix
                }
            }

            if (string.IsNullOrEmpty(tpath))
            {
                MessageBox.Show("Tizen SDK path is undefined");
                throw new WizardCancelledException();
            }

            PrepareListOfTemplates();

            if (nativeTemplates.Count <= 0)
            {
                MessageBox.Show("Tizen SDK template list is empty. Check toolchains.");
                throw new WizardCancelledException();
            }

            VsProjectHelper.Initialize();
            VsProjectHelper prjHelperInstance = VsProjectHelper.GetInstance;

            string solutionDirectory = replacementsDictionary["$solutiondirectory$"];

            destinationDirectory = replacementsDictionary["$destinationdirectory$"];

            ProjectWizardViewTizenNative nWizard = new ProjectWizardViewTizenNative(replacementsDictionary["$projectname$"],
                                                                                    solutionDirectory, nativeTemplates);

            if (nWizard.ShowDialog() == false)
            {
                EnvDTE80.DTE2 dte2 = VsProjectHelper.GetInstance.GetDTE2();
                if (replacementsDictionary["$exclusiveproject$"] == "True")
                {
                    Directory.Delete(solutionDirectory, true);
                    dte2.ExecuteCommand("File.NewProject");
                }
                else
                {
                    Directory.Delete(destinationDirectory, true);
                    dte2.ExecuteCommand("File.AddNewProject");
                }
                throw new WizardCancelledException();
            }

            // Fix values
            replacementsDictionary["$tizen_profile$"]       = nWizard.data.profile;
            replacementsDictionary["$tizen_toolset$"]       = nWizard.data.toolset;
            replacementsDictionary["$tizen_api$"]           = nWizard.data.tizenApi;
            replacementsDictionary["$tizen_project_type$"]  = nWizard.data.projectType;
            replacementsDictionary["$tizen_template_name$"] = nWizard.data.projectType;
            string safename = replacementsDictionary["$safeprojectname$"];

            replacementsDictionary["$tizen_name$"]   = safename.ToLower();
            replacementsDictionary["$tizen_output$"] = "lib" + replacementsDictionary["$tizen_name$"] + ".so";

            // At this moment project directory exists but empty, remove and regenerate it
            Directory.Delete(replacementsDictionary["$destinationdirectory$"]);
            Process process = getTizenBatProcess();

            process.StartInfo.Arguments        = $"create native-project -n {safename} -p {nWizard.data.profile}-{nWizard.data.tizenApi} -t {nWizard.data.projectType}";
            process.StartInfo.WorkingDirectory = solutionDirectory;

            //debug
            //process.StartInfo.Arguments = " /A/K " + process.StartInfo.FileName + " " + process.StartInfo.Arguments;
            //process.StartInfo.FileName = "cmd.exe";
            //process.StartInfo.CreateNoWindow = false;
            //process.StartInfo.RedirectStandardInput= false;
            //process.StartInfo.RedirectStandardError = false;
            //process.StartInfo.RedirectStandardOutput = false;
            process.Start();
            process.WaitForExit();
            int code = process.ExitCode;

            process.Close();
            if (code != 0)
            {
                MessageBox.Show("Template generation fail for {safename}");
                throw new WizardCancelledException();
            }

            // Parse files
            using (StreamReader input = new StreamReader(Path.Combine(destinationDirectory, "project_def.prop")))
            {
                string line;
                while ((line = input.ReadLine()) != null)
                {
                    var match = keywords.Match(line);
                    if (match.Success)
                    {
                        string key   = match.Groups[1].Value;
                        string value = match.Groups[2].Value;
                        switch (key)
                        {
                        case "APPNAME":
                            replacementsDictionary["$tizen_name$"] = value;
                            break;

                        case "type":
                            fixType(replacementsDictionary, value);
                            break;
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            VsProjectHelper.Initialize();
            VsProjectHelper prjHelperInstance = VsProjectHelper.GetInstance;
            List <string>   prjlist           = new List <string>();
            Project         prj = null;

            prjlist.Add("Empty");

            IEnumerator prjEnum = prjHelperInstance.GetProjects().GetEnumerator();

            while (prjEnum.MoveNext())
            {
                prj = (Project)prjEnum.Current;
                prjlist.Add(prj.Name);
            }

            ProjectWizardViewTizenCrossPlatform nWizard = new ProjectWizardViewTizenCrossPlatform(replacementsDictionary["$projectname$"], replacementsDictionary["$solutiondirectory$"],
                                                                                                  Trans_boolean(replacementsDictionary["$hasCommon$"]), Trans_boolean(replacementsDictionary["$hasMobile$"]), Trans_boolean(replacementsDictionary["$hasTV$"]),
                                                                                                  Trans_boolean(replacementsDictionary["$hasWearable$"]), Trans_boolean(replacementsDictionary["$hasSharedLib$"]), prjlist);

            if (nWizard.ShowDialog() == false)
            {
                EnvDTE80.DTE2 dte2 = VsProjectHelper.GetInstance.GetDTE2();
                if (replacementsDictionary["$exclusiveproject$"] == "True")
                {
                    Directory.Delete(replacementsDictionary["$solutiondirectory$"], true);
                    dte2.ExecuteCommand("File.NewProject");
                }
                else
                {
                    Directory.Delete(replacementsDictionary["$destinationdirectory$"], true);
                    dte2.ExecuteCommand("File.AddNewProject");
                }
                throw new WizardCancelledException();
            }
            else
            {
                replacementsDictionary["$select_common$"]   = nWizard.manifestData.Select_common.ToString().ToLower();
                replacementsDictionary["$select_mobile$"]   = nWizard.manifestData.Select_mobile.ToString().ToLower();
                replacementsDictionary["$select_tv$"]       = nWizard.manifestData.Select_tv.ToString().ToLower();
                replacementsDictionary["$select_wearable$"] = nWizard.manifestData.Select_wearable.ToString().ToLower();
                if (nWizard.manifestData.Shared_library)
                {
                    replacementsDictionary["$hasSharedLib$"] = "true";
                }
                else
                {
                    replacementsDictionary["$hasSharedLib$"] = nWizard.manifestData.Selected_project_name;
                }
            }

            // Project Name change
            int    idx     = replacementsDictionary["$safeprojectname$"].IndexOf("Tizen");
            string prjName = replacementsDictionary["$safeprojectname$"];

            replacementsDictionary["$namespace$"]   = prjName;
            replacementsDictionary["$lib_prjName$"] = prjName;
            if (idx != -1)// && Trans_boolean(replacementsDictionary["$hasSharedLib$"]))
            {
                if (replacementsDictionary["$hasSharedLib$"] != "true")
                {
                    replacementsDictionary["$common_prjName$"] = prjName;
                }
                else
                {
                    replacementsDictionary["$common_prjName$"] = prjName + ".Tizen";
                }
                replacementsDictionary["$mobile_prjName$"]   = prjName + ".Mobile";
                replacementsDictionary["$tv_prjName$"]       = prjName + ".TV";
                replacementsDictionary["$wearable_prjName$"] = prjName + ".Wearable";
            }
            else
            {
                replacementsDictionary["$common_prjName$"]   = prjName + ".Tizen";
                replacementsDictionary["$mobile_prjName$"]   = prjName + ".Tizen.Mobile";
                replacementsDictionary["$tv_prjName$"]       = prjName + ".Tizen.TV";
                replacementsDictionary["$wearable_prjName$"] = prjName + ".Tizen.Wearable";
            }
        }