Razor HTML Helpers giving intellisense errors in Nop Commerce Plugin

前端 未结 3 691
心在旅途
心在旅途 2021-02-10 17:04

I am writing a plugin for Nop Commerce and my HTML helpers are giving me intellisense errors. I get red lines underlining them and the errors:

Feature \'extension method

3条回答
  •  清歌不尽
    2021-02-10 17:22

    The above answer about modifying the project from a Class Library to a MVC Project did not work for me as of VS2013 Update 4.

    The following does work, however:

    1. For all configurations, set Build, Output, Output Path to bin\ and not ..\..\Presentation\Nop.Web\Plugins\PLUGINNAMESPACE.PLUGINNAME\ as stated in nopCommerce documentation.

      In the .csproj file it should look like:

      bin\
      
    2. Set Build Events, Post-build command line: to copy to directory nopCommerce wants.

      (robocopy $(ProjectDir)$(OutDir) $(ProjectDir)..\..\Presentation\Nop.Web\Plugins\PLUGINNAMESPACE.PLUGINNAME\ /MIR) ^& IF %ERRORLEVEL% LEQ 1 exit 0
      

      In the .csproj file it should look like:

      
          (robocopy $(ProjectDir)$(OutDir)  $(ProjectDir)..\..\Presentation\Nop.Web\Plugins\PLUGINNAMESPACE.PLUGINNAME\ /MIR)  ^& IF %25ERRORLEVEL%25 LEQ 1 exit 0
      
      
    3. Setting Build Events, Run the post-build event: to "Always".

      In the .csproj file it should look like:

      
          Always
      
      
    4. Ensure that every single DLL file Reference in your plugin project is set to Copy Local. This is not necessary for the ProjectReference entries like Nop.Core, Nop.Data etc. Again, this is not what they tell you to do in the nopCommerce documentation, but it is required to make Intellisense work.

      In the .csproj file it should look like:

      
          True
      
      
      (repeat for all DLL file references)...
      
    5. Close and reopen the solution, rebuild the plugin project and now open any razor .cshtml files. Intellisense will work as expected and there is no need for any future hacks to maintain it.

提交回复
热议问题