views:

148

answers:

1

I create my solution by using Asp.net MVC pattern which has at least 4 projects.

  1. App.Models
  2. App.Globalization
  3. App.Controllers
    • References : App.Model and App.Globalization
  4. App.Views
    • References : App.Model, App.Globalization and App.Controller

I need to create .net resources file for using by both App.Controller project and App.Views project. First, I try to create App.Globalization project for sharing resources. But I need to save resx file in App_Globalization folder in App.Views project and save designer.cs file(generated code of resx file) in App.Globalization project because it's easy to modify & save data in resources file.

Is it possible for creating separated resouce files for Asp.net MVC without using custom tool(s) or post-build command?

A: 

It's very easy by using the following step.

  1. Add resource file to App_GlobalResources folder in App.Views project.
  2. Set Build Action property of designer.cs file to None.
  3. Unload App.Globalization project.
  4. Edit App.Globalization project by adding the following code.
<Project>
    <ItemGroup>
        <Compile Include="..\App.Views\App_GlobalResources\WebApp.designer.cs">
            <Link>WebApp.designer.cs</Link>
        </Compile>
    </ItemGroup>
</Project>
Soul_Master