导出 EXE:服务器上的教材 dll 读不了(root 拷进去的文件是 600,容器里的平台用户读不到)时提示中文原因和改法,不再把英文的系统报错给学生看;部署说明补上 chmod 755 目录、644 文件
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5e5d29b2aa
commit
77bfaba7ff
2 files changed
+34
-1
No files matched your search
@@ -69,7 +69,7 @@ internal static class ExeExporter
|
||||
/// <summary>libsDir:教材 dll 所在目录;galleryDir:平台素材库</summary>
|
||||
public static Result Export(string projectDir, string libsDir, string galleryDir, string assemblyName)
|
||||
{
|
||||
var libs = Directory.Exists(libsDir) ? Directory.GetFiles(libsDir, "*.dll").OrderBy(p => p, StringComparer.Ordinal).ToArray() : Array.Empty<string>();
|
||||
var libs = TextbookLibs(libsDir);
|
||||
if (!libs.Any(p => Path.GetFileName(p) == "DeviceCtrlLibrary.dll"))
|
||||
throw new InvalidOperationException("服务器上没有放教材的设备类库(真机版 DeviceCtrlLibrary.dll 等),不能导出 EXE,请联系老师");
|
||||
|
||||
@@ -135,6 +135,32 @@ internal static class ExeExporter
|
||||
return new Result(emit.Success, pe.ToArray(), diagnostics);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 教材 dll 的路径。目录或文件读不了时(服务器上拷进去的文件权限是 600,容器里的平台用户读不到)说明原因,
|
||||
/// 不把英文的系统报错直接给学生看。
|
||||
/// </summary>
|
||||
private static string[] TextbookLibs(string libsDir)
|
||||
{
|
||||
if (!Directory.Exists(libsDir)) return Array.Empty<string>();
|
||||
string? current = null;
|
||||
try
|
||||
{
|
||||
var libs = Directory.GetFiles(libsDir, "*.dll").OrderBy(p => p, StringComparer.Ordinal).ToArray();
|
||||
foreach (var lib in libs)
|
||||
{
|
||||
current = lib;
|
||||
using var _ = File.OpenRead(lib);
|
||||
}
|
||||
return libs;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
var what = current == null ? "目录" : Path.GetFileName(current);
|
||||
throw new InvalidOperationException(
|
||||
$"服务器上的教材设备类库读不了({what} 的权限不够),不能导出 EXE,请联系老师(服务器上执行 chmod 755 textbook-libs 和 chmod 644 textbook-libs/*.dll)");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 每个窗体、控件类的 .resources:VS 生成的 Designer.cs 用 ComponentResourceManager 读窗体的 .resx,
|
||||
/// 平台没有 .resx。媒体播放器的 OcxState 放默认状态,其他取到 null(和运行时一样)。
|
||||
|
||||
Reference in new issue
Block a user