Visual Studio资源生成-自定义工具命名空间 [英] Visual Studio Resource Generation - Custom Tool Namespace

查看:172
本文介绍了Visual Studio资源生成-自定义工具命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#类库,其中包含几个组织在文件夹中的资源文件。由于我希望生成的类全部位于同一命名空间中,因此我设置了每个资源文件的CustomToolNamespace属性。

I have a C# class library that contains several resources files organized in folders. Since I want the generated classes to be all in the same namespace I'm setting the CustomToolNamespace property of each resource file.

但是我通过Reflector发现,尽管这些类是所有这些都在同一个命名空间中生成嵌入式资源的路径包含放置资源文件的目录名称。

However I discovered through Reflector that although the classes are all being generated in the same namespace the path to the embedded resources contains the directory name in which the resource file is placed.

例如,在一个项目中,其中 FolderCustomNamespaceRes .resx 放置在名为 Folder 的目录中。

For example in a project where FolderCustomNamespaceRes.resx is placed inside a directory named Folder.

已删除的死ImageShack链接

其中 FolderCustomNamespaceRes.resx 的CustomToolNamespace设置为PublicResourcesTest,Reflector显示嵌入式资源程序集的路径为PublicResourcesTest。文件夹 .FolderCustomNamespaceRes.resources

And where CustomToolNamespace for FolderCustomNamespaceRes.resx is set to PublicResourcesTest, Reflector shows that the path to the embedded resource assembly is PublicResourcesTest.Folder.FolderCustomNamespaceRes.resources

已删除的死ImageShack链接

这是一个bug还是我缺少什么?

Is this a bug or am I missing something?

推荐答案

我发现,可以通过在 .cspproj 文件中添加元数据来控制嵌入式资源的清单名称。

After some search I found out that the manifest name of the embedded resource can be controlled by adding metadata in the .cspproj file.

在您拥有类似的内容之前,

Before you would have something like:

<EmbeddedResource Include="Folder\FolderCustomNamespaceRes.resx">
   <Generator>PublicResXFileCodeGenerator</Generator>
   <LastGenOutput>FolderCustomNamespaceRes.Designer.cs</LastGenOutput>
   <CustomToolNamespace>PublicResourcesTest</CustomToolNamespace>
</EmbeddedResource>

要控制清单名称,您必须添加:

And to control the manifest name you would have to add:

<EmbeddedResource Include="Folder\FolderCustomNamespaceRes.resx">
   ....
   <LogicalName>$(RootNamespace).FolderCustomNamespaceRes.resources</LogicalName>
</EmbeddedResource>

这篇关于Visual Studio资源生成-自定义工具命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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