Using MVC5, it has been very easy to create a bootstrapper project that had references to all layers, thus decoupling the UI layer from references to, lets say, infrastructure logic. The project would contain startup configuration logic, such as setting up the IoC container.
The way to do this was to define a startup class:
public class Startup
{
public static void Start()
{
// startup configuration (IoC etc) goes here
}
}
And then add a line in AssemblyInfo.cs
:
[assembly: PreApplicationStartMethod(typeof(Startup), "Start")]
Unfortunatelly, this approach no longer works with asp.net 5. I had a brief look at the documentation but all I found out was that the framework looks for a class named Startup within the Web project.
I also had a look within the Microsoft.AspNet.Hosting
source code which seems to be responsible for finding the Startup class. I can see some references to the configuration class, so there is a chance that the assembly can be loaded by using some kind of configuration setting, but I couldn't confirm this or determine which setting.
Also, if this is true, how could the Startup class be determined by using the config.json
file, when the file itself is being loaded within the Startup class? Are there different options for configuring the startup assembly, like for example using an environment variable?