如何在同一程序集中嵌入C#程序集资源? [英] How can I embed C# assembly resources in the same assembly?

查看:76
本文介绍了如何在同一程序集中嵌入C#程序集资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在班级图书馆项目中添加了不同文化的资源.构建时,将为每个区域性创建单独的文件夹,并在每个区域中都有一个程序集.

I have added resources for different cultures to my Class Library Project. When building, seperate folders are created for each culture with an assembly in each of them.

是否有一种方法可以将所有资源嵌入类库程序集中,而不是为每种文化都提供一个额外的程序集?该类库最终会用在另一个项目中,因此,在这些单独的文件夹中,它需要分发一个zip文件,而不是仅分发一个程序集.

Is there a way to embed all the resources in the Class Library Assembly, instead of having an extra assembly for each culture? The class library is eventually used in another project, so with theses seperate folders, it need to distribute a zip file instead of just one assembly.

说明:我一直在寻找没有安装程序或第二方工具的解决方案.而是我希望在Visual Studio中找到一种解决方案,使结果将是其中具有不同资源的一个程序集.

Clarification: I was looking for a solution without installers or second party tools. Rather was I hoping for a solution inside Visual Studio where the outcome would be one assembly with the different resources in it.

推荐答案

要将多个程序集合并为一个,可以使用Fody/Costura .它允许您将多个程序集合并到一个项目中.在您的主项目中添加它(可以通过nuget完成).然后在weavers.xml(将自动生成的文件中添加以下文本:

To murge multiple assemblys into one you can use Fody/Costura. It allows you to merge multiple assemblys into 1 project. In your main project you add it(can be done via nuget). Then just in weavers.xml (file that will be automaticly generated add these text:

<Costura>
    <IncludeAssemblies>
        Project.MyData.Dutch
        Project.MyData.French
        Project.MyData.English
    </IncludeAssemblies>
</Costura>

(它应该与引用的名称相同,因此不带.dll后缀)

(it should be the same name as the reference, so without the .dll suffix)

这篇关于如何在同一程序集中嵌入C#程序集资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆