开发者

Should Resources.Designer.cs be under source control?

I have Resources.resx, which is开发者_运维技巧 used to generate Resources.designer.cs. Should Resources.designer.cs be checked in, or can I rely on Visual Studio generating it when required?


My preference is: If it's modified by the build system, ensure the build process will create it and don't check it in.

For autogenerated files like 'designer', I check them in. They only get modified when other components get changed (by me). It's generated by VS and not modified by the build system.


I ran across your post for a problem I am experiencing, not quite the same, but it helped me find a temporary solution. This is what I found that might help you…

I am creating a simple string resource file. I then use a modified CodeProject program that translates it into foreign languages. (We will use professional services once we stabilize the code) The utility does not create the designer.cs files. Doing a rebuild all did not re-create the files either. It appears that any time you use an external tool (not the Visual Studio designer) to modify an resx file, you will lose those synced changes. In my case the designer file is used merely to strongly type the strings to property names. If you are using the ID’s to pull the string (age old method) then you won’t need these files at all and thus wouldn’t need to check them in to source control. However, if you are using the strongly typed access to these string (more modern method) you should check them in.

As an aside… I did find a way to re-sync those designer.cs files with their resx counter parts as that was my problem… I needed them. Selecting a resx file in the Solution Explorer and setting the CustomTool property to PublicResXFileCodeGenerator instantly created the designer.cs file. Unfortunately, if it is already set, you have to un-set it and then re-set it to create the file. If anyone knows a way to force a re-creation of these via some automated means… I would really appreciate it.

Thanks.


I'm not 100% sure about the build scenarios around this file. I think that it's likely Studio, or more appropriately msbuild, will re-generate the file every time you build your application but not sure.

Either way, I would still check this file in for a couple of reasons

  1. It's the default for most source control providers in Visual Studio. They've thought a lot harder about this problem than I have and likely have good reasons for doing this
  2. Debugging: It's unlikely there would ever be a issue in the Resource.Designer.cs but if there was you'd be forced to build before you could attach / debug
  3. Source Control should be a history of your sources. What good is it doing if you can't see all of the sources related to your application.

The first reason being the most important

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜