我正在关注关于此 OrchardProject.net link 的文档.我打开并激活了 CodeGeneration 模块,并在项目 (Orchard.Web) 的根目录打开了命令提示符,并编写了“bin/Orchard.exe”来运行命令。到那时一切都很好。现在,当我尝试运行以下命令时,它给了我以下异常。命令是:
codegen 主题 mishrajiTheme/BasedOn:TheThemeMachine/CreateProject:true/IncludeInSolution:true
下面是命令的输出。
Creating Theme mishrajiTheme
Error executing command "codegen theme mishrajiTheme"
Specified argument was out of the range of valid values. Parameter name: startIndex
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: startIndex
Stack Trace:
[ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: startIndex] at System.String.Insert(Int32 startIndex, String value) at Orchard.CodeGeneration.Commands.CodeGenerationCommands.AddToSolution(TextWriter output, String projectName, String projectGuid, String containingFolder, String solutionFolderGuid) at Orchard.CodeGeneration.Commands.CodeGenerationCommands.CreateThemeFromTemplates(TextWriter output, String themeName, String baseTheme, String projectGuid, Boolean includeInSolution) at Orchard.CodeGeneration.Commands.CodeGenerationCommands.IntegrateTheme(String themeName, String baseTheme) at Orchard.CodeGeneration.Commands.CodeGenerationCommands.CreateTheme(String themeName)
我在这里做错了什么或者它是 Orchard 代码生成模块中的错误。 请指导。我使用的是 Orchard 1.10 版本。
请您参考如下方法:
我通过更改 Orchard 1.10 中第 434 行的 CodeGenerationCommands 类解决了这个问题。该行是:
solutionText = solutionText.Insert(solutionText.LastIndexOf("EndProject\r\n"), projectReference);
为此:
solutionText = solutionText.Insert(solutionText.LastIndexOf("EndProject\n"), projectReference);
我不知道为什么 \r\n 找不到最终的 EndProject 并且通过将其更改为 \n 它工作正常
