_ViewImports.cshtml is ignored in Custom Plugin

8 mesi tempo fa
Views in custom Plugin cannot find 'NopHtml' helper nor the 'T' localizer.
_ViewImports.cshtml is present under Views folder as well the rest of the Views.

The plugin code is actually from the official course.

Note that injecting dependancies directly into the views works.

Version is 4.50.4
8 mesi tempo fa
Do you have
@inject INopHtmlHelper NopHtml
in your _ViewImports.cshtml file
8 mesi tempo fa
Yes. The _ViewImports file looks like this:

@inherits Nop.Web.Framework.Mvc.Razor.NopRazorPage<TModel>
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Nop.Web.Framework
@addTagHelper *, Nop.Plugin.Misc.SupportRequests

@using Microsoft.AspNetCore.Mvc.ViewFeatures
@using Nop.Core
@using Nop.Web.Framework.UI
@using Nop.Web.Framework.Extensions
@using System.Text.Encodings.Web

@inject INopHtmlHelper NopHtml
8 mesi tempo fa
Are you getting errors when the code runs, or just in Visual Studio's syntax validation?
8 mesi tempo fa
The plugin is built and appears in the Nop.Web.Plugins folder but there are several problems:

1. At the admin panel the Plugin keeps its "ready to install" state after installation and app restart.
I mean there are no 'Configure' and 'Edit' buttons as well as 'Install' and 'Delete' Buttons remain instead of 'UnInstall'.

2. Localization does not function for the plugin views. Localization keys appear as text instead of the values.

3. No views or components of the plugin appear in the Admin section.
8 mesi tempo fa
Are you running the 'published' version, or are you running in Visual Studio?

RE: "Plugin keeps its "ready to install"
Then it seems like it did not install properly.
Check \App_Data\plugins.json file.  Is your plugin still in the "PluginNamesToInstall" section (near bottom of file)

Check your .csproj file.  Be sure that output for build is under \Presentation\ .  Example:

RE:  "Localization does not function for the plugin views. "
The plugin he installation inserts localized string resources into DB table.  If install is no completing, then that won't happen.
8 mesi tempo fa
I run the app in VS.
The OutputPath is correct as you show.
And the plugin also appears in the plugins.json under "PluginNamesToInstall".
8 mesi tempo fa
Check the System > Log for errors
8 mesi tempo fa
Problem solved!

After looking at the logs, it turns out it was a migration problem. After making the appropriate corrections to the database everything works as it should.

(Editor still complains for the _ViewImports though)
Thank you for your time and advice!