public void Dispose()
 {
     if (_webHostAgent != null)
     {
         _webHostAgent.Shutdown();
         _webHostAgent = null;
     }
     Clean();
 }
        private void StartAspNetHost(string virtualDirectory)
        {
            Log("Starting up ASP.NET host");
            HostName          = "localhost";
            PhysicalDirectory = _tempSite;
            VirtualDirectory  = virtualDirectory;

            _webHostAgent = (WebHostAgent)ApplicationHost.CreateApplicationHost(typeof(WebHostAgent), VirtualDirectory, PhysicalDirectory);


            var shuttle = new Shuttle();

            Execute(() => { shuttle.CodeGenDir = HttpRuntime.CodegenDir; });

            // ASP.NET folder seems to be always nested into an empty directory
            _codeGenDir = shuttle.CodeGenDir;
            _codeGenDir = _codeGenDir.Parent;
            Log("ASP.NET CodeGenDir: \"{0}\"", _codeGenDir);
        }