Move Razor library resources to MVC published folder

Ok, I found the solution. I added the following tasks to the csproj file of my MVC app:

<Target Name="CopyRazorResourceFilesNl" AfterTargets="Publish">
    <Copy SourceFiles="$(PublishDir)\wwwroot\_framework\_bin\nl\RazorComponentLibrary.resources.dll" DestinationFolder="$(PublishDir)\nl" />
</Target>
<Target Name="CopyRazorResourceFilesEn" AfterTargets="Publish">
    <Copy SourceFiles="$(PublishDir)\wwwroot\_framework\_bin\en\RazorComponentLibrary.resources.dll" DestinationFolder="$(PublishDir)\en" />
</Target>

This copies the dll in wwwroot to the nl (and en) folder that is used by the MVC app for localization. I need the dll in both locations, so this is perfect.

You can find the reference for the Copy task here: https://docs.microsoft.com/en-us/visualstudio/msbuild/copy-task?view=vs-2019

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top