.NET Framework Bookmark and Share   
 index > MSBuild > Changing designer generated file for embedded resources
 

Changing designer generated file for embedded resources

Hello,

Is it possible to rename and change the path of the designer generated file that is created by the ResXFileCodeGenerator tool?

I'm working on a library Project that consists of several C# projects, each one representing a major namespace.

I would like to keep the string resources that need to be translated in a common directory, so the build server can easily pick all culture specific resources in that directory and create satellite asssemblies from there.

I'm trying to make this directory structure:

  • ProjectRoot
    • resources
      • MyProject.Strings.resx
      • MyProject.Namespace1.Strings.resx
      • ...
    • source
      • MyProject
        • MyProject.csproj
        • MyProject.Strings.resx (link)
          • SR.cs
      • MyProject.Namespace1
        • MyProject.Namespace1.csproj
        • MyProject.Namespace1.Strings.resx (link)
          • SR.cs
      • ...

So, each projectshould havea link to it's own resource file, that is named like ProjectName[.Namespace].Strings.resx, and the generated file should be named SR.cs (with a SR class) and should be placed inthe project directory.

I believe that this is possible by adding a <LogicalName> node inside the <EmbeddedResource> node, and maybe change the <LastGenOutput> node value. Although I can't make it work.

This also should be done in a common .targets file (that's why I'm asking here :) ).

Does anyone made it work this way? Or maybe someone canpoint me to the rightdirection..

Thanks

Pedro

Pedro Ferreira

Here's what the owner of this "single file generator" tool says:

I only see one way of making this work in Whidbey using the single file generators.

1) Create a project to hold the common resources

2) This project and all projects which want to share its resources must be given the same default root namespace (e.g., “MyCompany.MyAppication1�

3) Put your .resx file in the common resources project in the same subdirectory structure that you’re going to put them into in the shared projects (e.g., “Common\Resources� produces namespace MyCompany.MyApplication1.Common. Resources�. Note that the directory structure controls the namespace used for the .resources file in the assembly’s manifest

4) In the projects which will use these resources, create a link to both the .resx and generated .Designer.cs files (in the same subfolder structure). Make sure the linked .resx file’s Custom Tool property is blank.

5) Only edit strings in the common resources project’s .resx file, not the linked versions

Example directory structure:

Solution1

Project “CommonResources�(default namespace = “MyCompany.MyApp1�

Common

Resources

Resources.resx

+Resources.Designer.cs

Project “Project1�(default namespace = “MyCompany.MyApp1�

Common

Resources

Link to Resources.resx

Link to Resources.Designer.cs

DanMoseley - MSFT

Pedro,

ResXFileCodeGenerator doesn't use MSBuild yet - it doesn't use us at all yet. I don't know of a way to customize it at all -- I'm asking the owner and I'll post back.

LogicalName I do know about -- that forces a specific name for the resource stream in the final assembly.

Dan

DanMoseley - MSFT

Here's what the owner of this "single file generator" tool says:

I only see one way of making this work in Whidbey using the single file generators.

1) Create a project to hold the common resources

2) This project and all projects which want to share its resources must be given the same default root namespace (e.g., “MyCompany.MyAppication1�

3) Put your .resx file in the common resources project in the same subdirectory structure that you’re going to put them into in the shared projects (e.g., “Common\Resources� produces namespace MyCompany.MyApplication1.Common. Resources�. Note that the directory structure controls the namespace used for the .resources file in the assembly’s manifest

4) In the projects which will use these resources, create a link to both the .resx and generated .Designer.cs files (in the same subfolder structure). Make sure the linked .resx file’s Custom Tool property is blank.

5) Only edit strings in the common resources project’s .resx file, not the linked versions

Example directory structure:

Solution1

Project “CommonResources�(default namespace = “MyCompany.MyApp1�

Common

Resources

Resources.resx

+Resources.Designer.cs

Project “Project1�(default namespace = “MyCompany.MyApp1�

Common

Resources

Link to Resources.resx

Link to Resources.Designer.cs

DanMoseley - MSFT
Hello Dan! Thanks for finding the solution for me.

The described solution seems good, and I'll use it with some minor modifications.

Thanks!
Pedro Ferreira

You can use google to search for other answers

Custom Search

More Threads

• Target UnmanagedUnregistration
• Issues with MSBuild
• Visual C# Express 2005 Release Configuration vs. MSBuild
• How-to deal with dynamically loaded assemblies (e.g. plugins) under VS ?
• strange file not found error..
• Handle exception in Build Event?
• custom "build" task
• Problem Creating BizTalk Resource
• Resource Preprocessor Problem using command line.
• To mention single key in an XML file for all prjoects