#17061: Codegen'ing a theme should put the theme in the themes folder of the solution, not the modules folder.

--HG--
branch : 1.x
This commit is contained in:
Dave Reed
2011-03-28 12:35:45 -07:00
parent 0afaf13b47
commit d69a22dc35

View File

@@ -16,6 +16,8 @@ namespace Orchard.CodeGeneration.Commands {
public class CodeGenerationCommands : DefaultOrchardCommandHandler { public class CodeGenerationCommands : DefaultOrchardCommandHandler {
private readonly IExtensionManager _extensionManager; private readonly IExtensionManager _extensionManager;
private readonly ISchemaCommandGenerator _schemaCommandGenerator; private readonly ISchemaCommandGenerator _schemaCommandGenerator;
private const string SolutionDirectoryModules = "E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5";
private const string SolutionDirectoryThemes = "74492CBC-7201-417E-BC29-28B4C25A58B0";
private static readonly string[] _themeDirectories = new [] { private static readonly string[] _themeDirectories = new [] {
"", "Content", "Styles", "Scripts", "Views", "Zones" "", "Content", "Styles", "Scripts", "Views", "Zones"
@@ -191,7 +193,7 @@ namespace Orchard.CodeGeneration.Commands {
CreateFilesFromTemplates(moduleName, projectGuid); CreateFilesFromTemplates(moduleName, projectGuid);
// The string searches in solution/project files can be made aware of comment lines. // The string searches in solution/project files can be made aware of comment lines.
if (IncludeInSolution) { if (IncludeInSolution) {
AddToSolution(Context.Output, moduleName, projectGuid, "Modules"); AddToSolution(Context.Output, moduleName, projectGuid, "Modules", SolutionDirectoryModules);
} }
} }
@@ -333,13 +335,13 @@ namespace Orchard.CodeGeneration.Commands {
} }
else { else {
// create a project (already done) and add it to the solution // create a project (already done) and add it to the solution
AddToSolution(output, themeName, projectGuid, "Themes"); AddToSolution(output, themeName, projectGuid, "Themes", SolutionDirectoryThemes);
} }
} }
} }
private void AddToSolution(TextWriter output, string projectName, string projectGuid, string containingFolder) { private void AddToSolution(TextWriter output, string projectName, string projectGuid, string containingFolder, string solutionFolderGuid) {
if (!string.IsNullOrEmpty(projectGuid)) { if (!string.IsNullOrEmpty(projectGuid)) {
var solutionPath = Directory.GetParent(_orchardWebProj).Parent.FullName + "\\Orchard.sln"; var solutionPath = Directory.GetParent(_orchardWebProj).Parent.FullName + "\\Orchard.sln";
if (File.Exists(solutionPath)) { if (File.Exists(solutionPath)) {
@@ -347,7 +349,7 @@ namespace Orchard.CodeGeneration.Commands {
var projectConfiguationPlatforms = string.Format("GlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{{{0}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r\n\t\t{{{0}}}.Debug|Any CPU.Build.0 = Debug|Any CPU\r\n\t\t{{{0}}}.Release|Any CPU.ActiveCfg = Release|Any CPU\r\n\t\t{{{0}}}.Release|Any CPU.Build.0 = Release|Any CPU\r\n", projectGuid); var projectConfiguationPlatforms = string.Format("GlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{{{0}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r\n\t\t{{{0}}}.Debug|Any CPU.Build.0 = Debug|Any CPU\r\n\t\t{{{0}}}.Release|Any CPU.ActiveCfg = Release|Any CPU\r\n\t\t{{{0}}}.Release|Any CPU.Build.0 = Release|Any CPU\r\n", projectGuid);
var solutionText = File.ReadAllText(solutionPath); var solutionText = File.ReadAllText(solutionPath);
solutionText = solutionText.Insert(solutionText.LastIndexOf("EndProject\r\n"), projectReference).Replace("GlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n", projectConfiguationPlatforms); solutionText = solutionText.Insert(solutionText.LastIndexOf("EndProject\r\n"), projectReference).Replace("GlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n", projectConfiguationPlatforms);
solutionText = solutionText.Insert(solutionText.LastIndexOf("EndGlobalSection"), "\t{" + projectGuid + "} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}\r\n\t"); solutionText = solutionText.Insert(solutionText.LastIndexOf("EndGlobalSection"), "\t{" + projectGuid + "} = {" + solutionFolderGuid + "}\r\n\t");
File.WriteAllText(solutionPath, solutionText); File.WriteAllText(solutionPath, solutionText);
TouchSolution(output); TouchSolution(output);
} }