在为我公司的内部重用库制作NuGet模块时,我终于着手制作一个带有可视组件的模块。 此模块的.cshtml文件将驻留在特定于模块的位置(而不是标准的“Views”文件夹),因此我将一个辅助web.config放在与视图相同的文件夹中以允许MVC和Razor。
问题变了,虽然我可以在我的.nuspec文件中指定一个MVC版本作为依赖项,但我不希望必须是特定于版本的,因为我在我的视图中使用的所有功能都存在于所有版本的MVC中。
有没有办法可以查看特定(和非传统)文件夹并使用共享MVC二进制文件和配置进行操作? 是否可以在所有类型的项目中执行此操作,而无需在安装NuGet软件包后执行任何额外的步骤?
In making NuGet modules for my company's internal re-use library I finally embarked on making a module with a visual component. The .cshtml file for this module will reside in a location specific to modules (not the standard "Views" folder) so I have been putting a secondary web.config in the same folder with the view to allow for MVC and Razor.
The problem becomes, although I can specify a version of MVC as a dependency in my .nuspec file, I don't want to have to be version specific being that all the functionality I am using in my views exists in all versions of MVC.
Is there a way I can get a view into a specific (and non-traditional) folder and have it operate using shared MVC binaries and configuration? Is it possible to do this in all types of projects without requiring any extra steps for a person to take after installing the NuGet package?
最满意答案
你有几个选择:
使用razor生成器将视图编译到类中 - https://razorgenerator.codeplex.com 将视图包含为嵌入资源并编写VirtualPathProvider以获取它们(例如, 请访问http://www.ianmariano.com/2013/06/11/embedded-razor-views-in-mvc-4/ ) 在nuget包内部创建PowerShell脚本以及其他步骤依赖于Asp.Net MVC的问题在于它并不总是向后兼容,但是你必须自己检查一下
You have few options:
Use razor generator to compile views into classes - https://razorgenerator.codeplex.com Include views as embedded resources and write VirtualPathProvider to get them ( example at http://www.ianmariano.com/2013/06/11/embedded-razor-views-in-mvc-4/) Inside nuget package create PowerShell script with additional stepsThe problem with dependency into Asp.Net MVC is that it wasn't always backwards compatible, but this you will have to check yourself
更多推荐
MVC,NuGet,电脑培训,计算机培训,IT培训"/> <meta name="description" c
发布评论