开发者

Package an ASP.NET MVC application with Nuget

Has anyone tried packing an entire ASP.NET MVC application with Nuget and did it work for him? I have a bunch of controllers, views, helpers an开发者_StackOverflow社区d utilities that I would like to bring in into another MVC project.

The problem is, routes don't work and I don't whether they should or not. The thing is, the project for the package we brought in had its own global.asax.cs and its own routes. How does that get combined with our current project's global.asax and its routes?

So if anyone had any experience with such packages, please reply.


You should try to use the MVC Area feature to allow routes to be registered from multiple places. To see what that looks like, right click an MVC project and choose Add / Area; then look at the AreaRegistration file that gets created.

UPDATE: using WebActivator provides another approach to executing code at startup without having to modify global.asax.


Your routes will not get merged so you will need to combine the routes yourself to make this work. You could use areas which have their own routes if you wanted to keep them separate but if you are just pulling in a bunch of controllers and views you'll need to edit the routes in your project so they make sense in the new application.


There is a scriptable application that can help you with copying the required files, see: https://nugetpackager.codeplex.com

This work well with an Area / Webactivator setup.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜