Search code examples
c#assemblypropertiesasp.net-mvc-5embedded-resource

Change Resource Type property in asp.net mvc-5


Is there any way to change the Build-Action of a resource in C#. I have done it manually on the local-system but when published this project on TFS-Domain, it does not load the file and gives an exception:

{"No resource with name myAppName.Assets.fonts.abc.ttf"}

The point is I don't want to do it manually always when I publish the site (manual-steps are):

  1. Right-clicked on the file
  2. Clicked on Properties
  3. Changed its Build-Action from Content to Embedded Resource

Solution

  • Just copy the files into your app_data directory and access is normally instead of making it a embedded resource.

    var path = HttpContext.Current.Server.MapPath("~/App_Data/abc.ttf");