简体   繁体   English

如何从Build Process中删除App_LocalResources

[英]How to remove App_LocalResources from Build Process

We have a Large-scale Application and it have dozens of resx file to localize application 我们有一个大型应用程序,它有几十个resx文件来本地化应用程序

these files build each time and take much time to build and the build process goes longer 每次构建这些文件并花费大量时间来构建,构建过程会更长

how to remove these kind of files from build process 如何从构建过程中删除这些类型的文件

Maybe I'm missing somethings. 也许我错过了一些事情。 If you are after to exempt ASP.NET from generating code for .resx files, you have to remove its build provider as follows. 如果您要免除ASP.NET生成.resx文件的代码,则必须按如下方式删除其构建提供程序。

<compilation>
  <buildProviders>
    <remove extension=".resx"/>
  </buildProviders>
</compilation>

I believe the default ASP.NET Resource Provider picks up local page resources using a one-to-one relationship between the pages themselves and associated *.resx files in your App_LocalResources folder. 我相信默认的ASP.NET资源提供程序使用页面本身与App_LocalResources文件夹中相关的* .resx文件之间的一对一关系来获取本地页面资源。 I'm not sure there is a way to change this default behaviour. 我不确定是否有办法更改此默认行为。

It is possible however; 然而,它是可能的; to implement your own Resource Provider and Resource Provider Factory. 实现自己的资源提供者和资源提供者工厂。 This is done by implementing the IResourceProvider interface to define your own methods for resource retrival and also creating an associated ResourceProviderFactory to instantiate instances of your custom provider. 这是通过实现IResourceProvider接口来定义您自己的资源回溯方法以及创建关联的ResourceProviderFactory来实例化自定义提供程序的实例来完成的。

Once you've done this you can reference the custom provider factory by adding the following to your Web.config file: 完成此操作后,您可以通过将以下内容添加到Web.config文件来引用自定义提供程序工厂:

<system.web>
  <globalization resourceProviderFactoryType="Company.Product.CustomResourceProviderFactory" />
</system.web>

Using this you could - for example - switch to storing your localisations in a database (as described in the guide here ) instead of compiling them with your application each time, thus hopefully improving the build speed. 使用这个你可以-例如-切换到存储你的本地化在数据库(如用户手册中说明这里 ),而不是与你的应用程序每次编译它们,从而有望提高建造速度。

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

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