Fixing code generation for modules

This commit is contained in:
Sebastien Ros 2011-10-03 13:23:05 -07:00
parent 64c468a4f9
commit 4420bc5ee4

View File

@ -210,7 +210,6 @@ namespace Orchard.CodeGeneration.Commands {
string propertiesPath = modulePath + "Properties";
var content = new HashSet<string>();
var folders = new HashSet<string>();
var contentNoDeploy = new HashSet<string>();
foreach(var folder in _moduleDirectories) {
Directory.CreateDirectory(modulePath + folder);
@ -227,8 +226,6 @@ namespace Orchard.CodeGeneration.Commands {
content.Add(modulePath + "Scripts\\Web.config");
File.WriteAllText(modulePath + "Styles\\Web.config", File.ReadAllText(_codeGenTemplatePath + "StaticFilesWebConfig.txt"));
content.Add(modulePath + "Styles\\Web.config");
File.WriteAllText(modulePath + "CodeTemplates\\AddController\\Controller.tt", File.ReadAllText(_codeGenTemplatePath + "Controller.tt."));
contentNoDeploy.Add(modulePath + "CodeTemplates\\AddController\\Controller.tt");
string templateText = File.ReadAllText(_codeGenTemplatePath + "ModuleAssemblyInfo.txt");
templateText = templateText.Replace("$$ModuleName$$", moduleName);
@ -241,7 +238,7 @@ namespace Orchard.CodeGeneration.Commands {
File.WriteAllText(modulePath + "Module.txt", templateText);
content.Add(modulePath + "Module.txt");
var itemGroup = CreateProjectItemGroup(modulePath, content, folders, contentNoDeploy);
var itemGroup = CreateProjectItemGroup(modulePath, content, folders);
File.WriteAllText(modulePath + moduleName + ".csproj", CreateCsProject(moduleName, projectGuid, itemGroup));
}
@ -324,7 +321,7 @@ namespace Orchard.CodeGeneration.Commands {
// create new csproj for the theme
if (projectGuid != null) {
var itemGroup = CreateProjectItemGroup(themePath, createdFiles, createdFolders, null);
var itemGroup = CreateProjectItemGroup(themePath, createdFiles, createdFolders);
string projectText = CreateCsProject(themeName, projectGuid, itemGroup);
File.WriteAllText(themePath + "\\" + themeName + ".csproj", projectText);
}
@ -332,7 +329,7 @@ namespace Orchard.CodeGeneration.Commands {
if (includeInSolution) {
if (projectGuid == null) {
// include in solution but dont create a project: just add the references to Orchard.Themes project
var itemGroup = CreateProjectItemGroup(HostingEnvironment.MapPath("~/Themes/"), createdFiles, createdFolders, null);
var itemGroup = CreateProjectItemGroup(HostingEnvironment.MapPath("~/Themes/"), createdFiles, createdFolders);
AddFilesToOrchardThemesProject(output, itemGroup);
TouchSolution(output);
}
@ -359,8 +356,7 @@ namespace Orchard.CodeGeneration.Commands {
}
}
private static string CreateProjectItemGroup(string relativeFromPath, HashSet<string> content, HashSet<string> folders, HashSet<string> contentNoDeploy)
{
private static string CreateProjectItemGroup(string relativeFromPath, HashSet<string> content, HashSet<string> folders) {
var contentInclude = "";
if (relativeFromPath != null && !relativeFromPath.EndsWith("\\", StringComparison.OrdinalIgnoreCase)) {
relativeFromPath += "\\";
@ -378,10 +374,6 @@ namespace Orchard.CodeGeneration.Commands {
contentInclude += "\r\n" + string.Join("\r\n", from folder in folders
select " <Folder Include=\"" + folder.Replace(relativeFromPath, "") + "\" />");
}
if (contentNoDeploy != null && contentNoDeploy.Count > 0) {
contentInclude += "\r\n" + string.Join("\r\n", from file in contentNoDeploy
select " <None Include=\"" + file.Replace(relativeFromPath, "") + "\" />");
}
return string.Format(CultureInfo.InvariantCulture, "<ItemGroup>\r\n{0}\r\n </ItemGroup>\r\n ", contentInclude);
}