基线:全量源码首提(D1 版本控制落地,含第一轮优化 B1-B4/A1/A4/缩放修复)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// resx2res: 把 .resx(XML) 编译成 .resources(二进制),等价 SDK 的 resgen。
|
||||
// 背景:本机无 Windows SDK 无 resgen.exe;csc 的 /resource 只会原样嵌入文件,
|
||||
// 直接嵌 resx 运行时报"流不是有效的资源文件"。msbuild(SD F5)会自动转换,
|
||||
// 命令行 csc 编译前需先用本工具生成 .resources。
|
||||
// 用法: resx2res <输入.resx> <输出.resources>
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Resources;
|
||||
|
||||
class Resx2Res
|
||||
{
|
||||
static int Main(string[] args)
|
||||
{
|
||||
if (args.Length < 2)
|
||||
{
|
||||
Console.WriteLine("用法: resx2res <in.resx> <out.resources>");
|
||||
return 1;
|
||||
}
|
||||
using (var reader = new ResXResourceReader(args[0]))
|
||||
{
|
||||
reader.UseResXDataNodes = true;
|
||||
using (var writer = new ResourceWriter(args[1]))
|
||||
{
|
||||
foreach (DictionaryEntry e in reader)
|
||||
{
|
||||
var node = e.Value as ResXDataNode;
|
||||
object val = node != null
|
||||
? node.GetValue((System.ComponentModel.Design.ITypeResolutionService)null)
|
||||
: e.Value;
|
||||
writer.AddResource((string)e.Key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine("OK: " + args[1]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user