public static string ConvertProjectTemplate(List<IWizardControl> listControls) { _listControls = listControls; _projectOptions = new ProjectOptions(listControls); string templateFolder = ""; string assemblyFolder = ""; if (DebugMode) { // 2 nach oben ProjectWizard\\Templates templateFolder = Path.Combine(GetBasePath(), "ProjectWizard\\Templates"); assemblyFolder = Path.Combine(GetNetOfficePath(), "Assemblies"); } else { templateFolder = Path.Combine(Application.StartupPath, "Project Wizard\\Templates"); assemblyFolder = Path.Combine(Application.StartupPath, "Project Wizard\\NetOffice Assemblies"); } string fullTemplatePath = Path.Combine(templateFolder, GetTargetTemplate(_projectOptions)); if (!File.Exists(fullTemplatePath)) throw new System.IO.FileNotFoundException(string.Format("File not found:{0}", fullTemplatePath)); string targetFolder = Path.Combine(_projectOptions.ProjectFolder, _projectOptions.AssemblyName); targetFolder = Path.Combine(targetFolder, _projectOptions.AssemblyName); if (!Directory.Exists(targetFolder)) Directory.CreateDirectory(targetFolder); else throw new InvalidOperationException(ProjectWizardControl.CurrentLanguageID == 1031 ? "Der angegebene Ordner existiert bereits." : "Directory already exists."); if (Directory.Exists(Path.Combine(_projectOptions.ProjectFolder, _projectOptions.AssemblyName))) Directory.Delete(Path.Combine(_projectOptions.ProjectFolder, _projectOptions.AssemblyName), true); Directory.CreateDirectory(Path.Combine(_projectOptions.ProjectFolder, _projectOptions.AssemblyName)); if (Directory.Exists(targetFolder)) Directory.Delete(targetFolder, true); Directory.CreateDirectory(targetFolder); FastZip fz = new FastZip(); fz.ExtractZip(fullTemplatePath, targetFolder, ""); DeleteNonUsedFiles(targetFolder); RenameProjectFile(targetFolder); DoReplace(targetFolder); CopyAssemblies(GetAssemblies(), targetFolder, assemblyFolder); string projectGuid = ValidateProjectFile(targetFolder); CreateSolutionFile(Path.Combine(_projectOptions.ProjectFolder, _projectOptions.AssemblyName), projectGuid); CreateTaskPane(targetFolder); return Path.Combine(_projectOptions.ProjectFolder, _projectOptions.AssemblyName); }
private static string GetTargetTemplate(ProjectOptions projectOptions) { switch (projectOptions.Language) { case ProgrammingLanguage.CSharp: switch (projectOptions.ProjectType) { case ProjectType.Addin: return("Automation Addin C#.zip"); case ProjectType.ToolsAddin: return("Tools Automation Addin C#.zip"); case ProjectType.WindowsForms: return("WindowsForms Application C#.zip"); case ProjectType.ClassLibrary: return("ClassLibrary C#.zip"); default: // Console return("Console Application C#.zip"); } default: // VB switch (projectOptions.ProjectType) { case ProjectType.Addin: return("Automation Addin VB.zip"); case ProjectType.ToolsAddin: return("Tools Automation Addin VB.zip"); case ProjectType.WindowsForms: return("WindowsForms Application VB.zip"); case ProjectType.ClassLibrary: return("ClassLibrary VB.zip"); default: // Console return("Console Application VB.zip"); } } }
public static string ConvertProjectTemplate(List <IWizardControl> listControls) { _listControls = listControls; _projectOptions = new ProjectOptions(listControls); string templateFolder = ""; string assemblyFolder = ""; if (DebugMode) { // 2 nach oben ProjectWizard\\Templates templateFolder = Path.Combine(GetBasePath(), "ProjectWizard\\Templates"); assemblyFolder = Path.Combine(GetNetOfficePath(), "Assemblies"); } else { templateFolder = Path.Combine(Application.StartupPath, "Project Wizard\\Templates"); assemblyFolder = Path.Combine(Application.StartupPath, "Project Wizard\\NetOffice Assemblies"); } string fullTemplatePath = Path.Combine(templateFolder, GetTargetTemplate(_projectOptions)); if (!File.Exists(fullTemplatePath)) { throw new System.IO.FileNotFoundException(string.Format("File not found:{0}", fullTemplatePath)); } string targetFolder = Path.Combine(_projectOptions.ProjectFolder, _projectOptions.AssemblyName); targetFolder = Path.Combine(targetFolder, _projectOptions.AssemblyName); if (!Directory.Exists(targetFolder)) { Directory.CreateDirectory(targetFolder); } else { throw new InvalidOperationException(ProjectWizardControl.CurrentLanguageID == 1031 ? "Der angegebene Ordner existiert bereits." : "Directory already exists."); } if (Directory.Exists(Path.Combine(_projectOptions.ProjectFolder, _projectOptions.AssemblyName))) { Directory.Delete(Path.Combine(_projectOptions.ProjectFolder, _projectOptions.AssemblyName), true); } Directory.CreateDirectory(Path.Combine(_projectOptions.ProjectFolder, _projectOptions.AssemblyName)); if (Directory.Exists(targetFolder)) { Directory.Delete(targetFolder, true); } Directory.CreateDirectory(targetFolder); FastZip fz = new FastZip(); fz.ExtractZip(fullTemplatePath, targetFolder, ""); DeleteNonUsedFiles(targetFolder); RenameProjectFile(targetFolder); DoReplace(targetFolder); CopyAssemblies(GetAssemblies(), targetFolder, assemblyFolder); string projectGuid = ValidateProjectFile(targetFolder); CreateSolutionFile(Path.Combine(_projectOptions.ProjectFolder, _projectOptions.AssemblyName), projectGuid); CreateTaskPane(targetFolder); return(Path.Combine(_projectOptions.ProjectFolder, _projectOptions.AssemblyName)); }
private static string GetTargetTemplate(ProjectOptions projectOptions) { switch (projectOptions.Language) { case ProgrammingLanguage.CSharp: switch (projectOptions.ProjectType) { case ProjectType.Addin: return "Automation Addin C#.zip"; case ProjectType.ToolsAddin: return "Tools Automation Addin C#.zip"; case ProjectType.WindowsForms: return "WindowsForms Application C#.zip"; case ProjectType.ClassLibrary: return "ClassLibrary C#.zip"; default: // Console return "Console Application C#.zip"; } default: // VB switch (projectOptions.ProjectType) { case ProjectType.Addin: return "Automation Addin VB.zip"; case ProjectType.ToolsAddin: return "Tools Automation Addin VB.zip"; case ProjectType.WindowsForms: return "WindowsForms Application VB.zip"; case ProjectType.ClassLibrary: return "ClassLibrary VB.zip"; default: // Console return "Console Application VB.zip"; } } }