I seem to be using Umbraco just like you, wrapping it up as an MVC 4 project. Therefore, it becomes a “VS web application” instead of a “VS website”.
It is important to remember that initially Umbraco did not start as an application, and many functions in Umbraco are primarily aimed at using App_Code.
The inner classes AssemblyExtensions, PluginManager, TypeHelper, and the public TypeFinder class in Umbraco.Core have methods that depend on whether there is an App_Code folder. Even if you do not need App_Code in your Umbraco solution, if you do not want to just hide it from your solution. If you really do not want it to delete all links to it in the source and create your own Umbraco compilation.
== CHANGE BELOW ==
After reading your comment and posting again, I created a small solution to your problem. The fact that Umbraco creates App_Code is still due to initialization of the structure, which will not work without the existing App_Code. But recompiling and creating your own Umbraco distribution will mean that the OP indicates some additional maintenance when upgrading, etc.
This is not ideal, but the cleanest way to handle this issue is for Umbraco to create the App_Code folder, but also delete it when the application is initialized. I would use IApplicationEventHandler. Sample code works in my box.
using Umbraco.Core; using Umbraco.Core.IO; namespace YourNamespace.EventHandlers { public class AppCodeEvents : IApplicationEventHandler { public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { } public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { } public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { if (System.IO.Directory.Exists(IOHelper.MapPath(IOHelper.ResolveUrl("~/App_Code")))) { System.IO.Directory.Delete(IOHelper.MapPath(IOHelper.ResolveUrl("~/App_Code"))); } } } }
Eric Herlitz
source share