将缺少的 PartialView 显示为构建错误
我一直在重新整理我们在工作中的观点,并将它们转移到更合适的位置。
因为我们当前正在将许多视图组织到 Views 文件夹中自己的文件夹中,所以我们必须使用 RenderView 中的完整路径来引用我们的视图。
如果 RenderPartial 方法指向的 ascx 文件的位置不存在,有没有办法让 Visual Studio 抛出构建错误?
运行时显示错误,但我希望它成为构建过程的一部分。
感谢您的任何建议
I've been reorganising our views at work and moving them around to more appropriate locations.
Because we're currently organising many of our views into their own folders within the Views folder, we're having to reference our views using the full path in RenderView.
Is there a way that I can get Visual Studio to throw a build error if the location of the ascx file that the RenderPartial method points to doesn't exist?
There is an error shown at run time however I'd like it to be part of the build process.
Thanks for any advice
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
视图位置仅在运行时解析,因此我真的不知道如何做到这一点,除非您在 MSBuild 中编写一些自定义步骤来分析源代码并检查相应视图文件是否存在,但这将是一项具有挑战性的任务。
View locations are resolved only at runtime so I really don't see how this could be done, unless you write some custom step in MSBuild that will analyze the source code and check the existence of corresponding view files but this will be a challenging task.
MvcBuildViews 可能会对此有所帮助:
在 ASP.NET MVC 中编译视图
MvcBuildViews might help with this:
Compile Views in ASP.NET MVC