【修复】解决不在Luban.Server或者Luban.ClientServer目录运行Luban.Server或者Luban.ClientServer时,生成代码发生无法找到Templates目录的问题。如果未指定-t参数,自动使用程序所在目录的Templates目录。
parent
003f4cadb6
commit
77fe01dea6
|
|
@ -7,6 +7,7 @@ using Luban.Common.Utils;
|
||||||
using Luban.Server;
|
using Luban.Server;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -33,7 +34,7 @@ namespace Luban.ClientServer
|
||||||
|
|
||||||
public string[] WatchDir { get; set; }
|
public string[] WatchDir { get; set; }
|
||||||
|
|
||||||
public string StringTemplateDir { get; set; } = "Templates";
|
public string StringTemplateDir { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PrintUsage(string err)
|
private static void PrintUsage(string err)
|
||||||
|
|
@ -205,6 +206,10 @@ Options:
|
||||||
ThreadPool.SetMinThreads(Math.Max(4, processorCount), 5);
|
ThreadPool.SetMinThreads(Math.Max(4, processorCount), 5);
|
||||||
ThreadPool.SetMaxThreads(Math.Max(16, processorCount * 4), 10);
|
ThreadPool.SetMaxThreads(Math.Max(16, processorCount * 4), 10);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(options.StringTemplateDir))
|
||||||
|
{
|
||||||
|
options.StringTemplateDir = FileUtil.GetPathRelateApplicationDirectory("Templates");
|
||||||
|
}
|
||||||
if (string.IsNullOrWhiteSpace(options.Host))
|
if (string.IsNullOrWhiteSpace(options.Host))
|
||||||
{
|
{
|
||||||
options.Host = "127.0.0.1";
|
options.Host = "127.0.0.1";
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,16 @@ namespace Luban.Common.Utils
|
||||||
{
|
{
|
||||||
private static readonly NLog.Logger s_logger = NLog.LogManager.GetCurrentClassLogger();
|
private static readonly NLog.Logger s_logger = NLog.LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
public static string GetApplicationDirectory()
|
||||||
|
{
|
||||||
|
return Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().Location);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetPathRelateApplicationDirectory(string relatePath)
|
||||||
|
{
|
||||||
|
return Path.Combine(GetApplicationDirectory(), relatePath);
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetFileName(string path)
|
public static string GetFileName(string path)
|
||||||
{
|
{
|
||||||
int index = path.Replace('\\', '/').LastIndexOf('/');
|
int index = path.Replace('\\', '/').LastIndexOf('/');
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
{
|
{
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"Luban.Server": {
|
"Luban.Server": {
|
||||||
"commandName": "Project",
|
"commandName": "Project"
|
||||||
"commandLineArgs": "-p 8899 -t ../../../Templates"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Luban.Server
|
||||||
public string LogLevel { get; set; } = "INFO";
|
public string LogLevel { get; set; } = "INFO";
|
||||||
|
|
||||||
[Option('t', "string template directory", Required = false, HelpText = "string template directory.")]
|
[Option('t', "string template directory", Required = false, HelpText = "string template directory.")]
|
||||||
public string StringTemplateDir { get; set; } = "Templates";
|
public string StringTemplateDir { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CommandLineOptions ParseOptions(String[] args)
|
private static CommandLineOptions ParseOptions(String[] args)
|
||||||
|
|
@ -48,6 +48,10 @@ namespace Luban.Server
|
||||||
|
|
||||||
var options = ParseOptions(args);
|
var options = ParseOptions(args);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(options.StringTemplateDir))
|
||||||
|
{
|
||||||
|
options.StringTemplateDir = FileUtil.GetPathRelateApplicationDirectory("Templates");
|
||||||
|
}
|
||||||
Job.Common.Utils.StringTemplateUtil.TemplateDir = options.StringTemplateDir;
|
Job.Common.Utils.StringTemplateUtil.TemplateDir = options.StringTemplateDir;
|
||||||
|
|
||||||
Luban.Common.Utils.LogUtil.InitSimpleNLogConfigure(NLog.LogLevel.FromString(options.LogLevel));
|
Luban.Common.Utils.LogUtil.InitSimpleNLogConfigure(NLog.LogLevel.FromString(options.LogLevel));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue