不跟踪C#的设计器生成的code:拒绝与干净的检出产生 [英] Not tracking C# designer-generated code: refuses to generate with clean checkout

查看:105
本文介绍了不跟踪C#的设计器生成的code:拒绝与干净的检出产生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的ASP.NET MVC项目,我们有一个 Strings.resx 文件和附带的自动生成的 Strings.Designer.cs 文件。

In our ASP.NET MVC project we have a Strings.resx file and the accompanying autogenerated Strings.Designer.cs file.

追踪在源代码控制在 Strings.Designer.cs 文件创建了一堆难看的合并冲突的,它的自动生成反正,所以我们决定untrack它(从源代码中删除控制,并忽略该文件的本地拷贝)。

Tracking the Strings.Designer.cs file in source control creates a bunch of ugly merge conflicts and it's autogenerated anyway, so we decided to untrack it (remove it from source control and ignore the local copy of the file).

这工作得很好,但在Strings.Designer.cs文件不存在源的新鲜结帐。在 PublicResXFile codeGenerator 生成从 Strings.resx文件一个警告不太愿意:

This works well, except that on a fresh checkout of the source the Strings.Designer.cs file doesn't exist. The PublicResXFileCodeGenerator that generates the file from Strings.resx balks with a warning:

自定义工具'PublicResXFile codeGenerator在处理文件'查看\\ SETUP \\ App_LocalResources文件\\ Strings.resx失败。

"The custom tool 'PublicResXFileCodeGenerator' failed while processing the file 'Views\Setup\App_LocalResources\Strings.resx'."

和作为结果,所有在该文件中的字符串的生成编译错误。这意味着你必须手动右键单击的项目中的每个 Strings.resx 文件,并选择运行自定义工具。

And as a result, all of the strings in that file generate compile errors. This means you must manually right-click on each Strings.resx file in the project and choose "Run Custom Tool".

有什么办法来获得的ResX code生成工具来自动运行,即使Strings.Designer.cs不存在了吗?

Is there any way to get the ResX code generator tool to run automatically even if Strings.Designer.cs doesn't yet exist?

(我们已经尝试了RESGEN但它是挑剔的 - 它拒绝生成正确的文件名和命名空间字符串的文件)

(We've experimented with ResGen but it is finicky--it refuses to generate Strings files with the proper filename and namespace.)

推荐答案

您可以使用 ResGen.exe 以明确再生的.resources和了.Designer.cs文件从的.resx。随便扔,看起来像以下到您的prebuild事件的命令:

You can use ResGen.exe to explicitly regenerate the .resources and .Designer.cs files from your .resx. Just throw a command that looks something like the following into your prebuild events:

ResGen.exe Strings.resx NameSpace.Strings.resources /publicClass /str:cs,"Your.Namespace",Strings,Strings.Designer.cs

...这将产生在Your.Namespace命名空间Your.Namespace.Strings.resources文件和文件Strings.Designer.cs瓦特/字符串类。

...which will generate a Your.Namespace.Strings.resources file and a Strings.Designer.cs file w/ a "Strings" class in the "Your.Namespace" namespace.

(将/ publicClass开关告诉RESGEN生成公共成员,和CS是C#语言的选择。)

(The /publicClass switch tells ResGen to generate public members, and "cs" is the C# language choice.)

在这里阅读更多:的http:// MSDN。 microsoft.com/en-us/library/ccec7sz1(VS.80).aspx

这篇关于不跟踪C#的设计器生成的code:拒绝与干净的检出产生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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