简体   繁体   English

如何在同一个程序集中嵌入C#程序集资源?

[英]How can I embed C# assembly resources in the same assembly?

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. 构建时,会为每个文化创建单独的文件夹,每个文档中都有一个程序集。

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. 类库最终在另一个项目中使用,所以使用这些单独的文件夹,它需要分发一个zip文件而不是一个程序集。

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. 相反,我希望在Visual Studio中有一个解决方案,其结果将是一个具有不同资源的程序集。

To murge multiple assemblys into one you can use Fody/Costura . 要将多个组件合并为一个,您可以使用Fody / Costura It allows you to merge multiple assemblys into 1 project. 它允许您将多个程序集合并为一个项目。 In your main project you add it(can be done via nuget). 在您的主项目中添加它(可以通过nuget完成)。 Then just in weavers.xml (file that will be automaticly generated add these text: 然后只需在weavers.xml中(将自动生成的文件添加以下文本:

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

(it should be the same name as the reference, so without the .dll suffix) (它应该与引用名称相同,因此不带.dll后缀)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM