mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-16 09:20:44 +08:00
Fixing code generation for modules
This commit is contained in:
parent
64c468a4f9
commit
4420bc5ee4
@ -210,7 +210,6 @@ namespace Orchard.CodeGeneration.Commands {
|
|||||||
string propertiesPath = modulePath + "Properties";
|
string propertiesPath = modulePath + "Properties";
|
||||||
var content = new HashSet<string>();
|
var content = new HashSet<string>();
|
||||||
var folders = new HashSet<string>();
|
var folders = new HashSet<string>();
|
||||||
var contentNoDeploy = new HashSet<string>();
|
|
||||||
|
|
||||||
foreach(var folder in _moduleDirectories) {
|
foreach(var folder in _moduleDirectories) {
|
||||||
Directory.CreateDirectory(modulePath + folder);
|
Directory.CreateDirectory(modulePath + folder);
|
||||||
@ -227,8 +226,6 @@ namespace Orchard.CodeGeneration.Commands {
|
|||||||
content.Add(modulePath + "Scripts\\Web.config");
|
content.Add(modulePath + "Scripts\\Web.config");
|
||||||
File.WriteAllText(modulePath + "Styles\\Web.config", File.ReadAllText(_codeGenTemplatePath + "StaticFilesWebConfig.txt"));
|
File.WriteAllText(modulePath + "Styles\\Web.config", File.ReadAllText(_codeGenTemplatePath + "StaticFilesWebConfig.txt"));
|
||||||
content.Add(modulePath + "Styles\\Web.config");
|
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");
|
string templateText = File.ReadAllText(_codeGenTemplatePath + "ModuleAssemblyInfo.txt");
|
||||||
templateText = templateText.Replace("$$ModuleName$$", moduleName);
|
templateText = templateText.Replace("$$ModuleName$$", moduleName);
|
||||||
@ -241,7 +238,7 @@ namespace Orchard.CodeGeneration.Commands {
|
|||||||
File.WriteAllText(modulePath + "Module.txt", templateText);
|
File.WriteAllText(modulePath + "Module.txt", templateText);
|
||||||
content.Add(modulePath + "Module.txt");
|
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));
|
File.WriteAllText(modulePath + moduleName + ".csproj", CreateCsProject(moduleName, projectGuid, itemGroup));
|
||||||
}
|
}
|
||||||
@ -324,7 +321,7 @@ namespace Orchard.CodeGeneration.Commands {
|
|||||||
|
|
||||||
// create new csproj for the theme
|
// create new csproj for the theme
|
||||||
if (projectGuid != null) {
|
if (projectGuid != null) {
|
||||||
var itemGroup = CreateProjectItemGroup(themePath, createdFiles, createdFolders, null);
|
var itemGroup = CreateProjectItemGroup(themePath, createdFiles, createdFolders);
|
||||||
string projectText = CreateCsProject(themeName, projectGuid, itemGroup);
|
string projectText = CreateCsProject(themeName, projectGuid, itemGroup);
|
||||||
File.WriteAllText(themePath + "\\" + themeName + ".csproj", projectText);
|
File.WriteAllText(themePath + "\\" + themeName + ".csproj", projectText);
|
||||||
}
|
}
|
||||||
@ -332,7 +329,7 @@ namespace Orchard.CodeGeneration.Commands {
|
|||||||
if (includeInSolution) {
|
if (includeInSolution) {
|
||||||
if (projectGuid == null) {
|
if (projectGuid == null) {
|
||||||
// include in solution but dont create a project: just add the references to Orchard.Themes project
|
// 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);
|
AddFilesToOrchardThemesProject(output, itemGroup);
|
||||||
TouchSolution(output);
|
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 = "";
|
var contentInclude = "";
|
||||||
if (relativeFromPath != null && !relativeFromPath.EndsWith("\\", StringComparison.OrdinalIgnoreCase)) {
|
if (relativeFromPath != null && !relativeFromPath.EndsWith("\\", StringComparison.OrdinalIgnoreCase)) {
|
||||||
relativeFromPath += "\\";
|
relativeFromPath += "\\";
|
||||||
@ -378,10 +374,6 @@ namespace Orchard.CodeGeneration.Commands {
|
|||||||
contentInclude += "\r\n" + string.Join("\r\n", from folder in folders
|
contentInclude += "\r\n" + string.Join("\r\n", from folder in folders
|
||||||
select " <Folder Include=\"" + folder.Replace(relativeFromPath, "") + "\" />");
|
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);
|
return string.Format(CultureInfo.InvariantCulture, "<ItemGroup>\r\n{0}\r\n </ItemGroup>\r\n ", contentInclude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user