public ClientBuildManager(string appVirtualDir, string appPhysicalSourceDir, string appPhysicalTargetDir, ClientBuildManagerParameter parameter, TypeDescriptionProvider typeDescriptionProvider)
 {
     this._lock = new object();
     if (parameter == null)
     {
         parameter = new ClientBuildManagerParameter();
     }
     this.InitializeCBMTDPBridge(typeDescriptionProvider);
     if (!string.IsNullOrEmpty(appPhysicalTargetDir))
     {
         parameter.PrecompilationFlags |= PrecompilationFlags.Clean;
     }
     this._hostingParameters = new HostingEnvironmentParameters();
     this._hostingParameters.HostingFlags = HostingEnvironmentFlags.ClientBuildManager | HostingEnvironmentFlags.DontCallAppInitialize;
     this._hostingParameters.ClientBuildManagerParameter           = parameter;
     this._hostingParameters.PrecompilationTargetPhysicalDirectory = appPhysicalTargetDir;
     if (typeDescriptionProvider != null)
     {
         this._hostingParameters.HostingFlags |= HostingEnvironmentFlags.SupportsMultiTargeting;
     }
     if (appVirtualDir[0] != '/')
     {
         appVirtualDir = "/" + appVirtualDir;
     }
     if (((appPhysicalSourceDir == null) && appVirtualDir.StartsWith("/IISExpress/", StringComparison.OrdinalIgnoreCase)) && (appVirtualDir.Length > "/IISExpress/".Length))
     {
         int index = appVirtualDir.IndexOf('/', "/IISExpress/".Length);
         if (index > 0)
         {
             this._hostingParameters.IISExpressVersion = appVirtualDir.Substring("/IISExpress/".Length, index - "/IISExpress/".Length);
             appVirtualDir = appVirtualDir.Substring(index);
         }
     }
     this.Initialize(VirtualPath.CreateNonRelative(appVirtualDir), appPhysicalSourceDir);
 }
        /*
         * Creates an instance of the PrecompilationManager.
         * appPhysicalSourceDir points to the physical root of the application (e.g "c:\myapp")
         * appVirtualDir is the virtual path to the app root. It can be anything (e.g. "/dummy"),
         *      but ideally it should match the path later given to Cassini, in order for
         *      compilation that happens here to be reused there.
         * appPhysicalTargetDir is the directory where the precompiled site is placed
         * typeDescriptionProvider is the provider used for retrieving type
         * information for multi-targeting
         */
        public ClientBuildManager(string appVirtualDir, string appPhysicalSourceDir,
                                  string appPhysicalTargetDir, ClientBuildManagerParameter parameter,
                                  TypeDescriptionProvider typeDescriptionProvider)
        {
            if (parameter == null)
            {
                parameter = new ClientBuildManagerParameter();
            }

            InitializeCBMTDPBridge(typeDescriptionProvider);

            // Always build clean in precompilation for deployment mode,
            // since building incrementally raises all kind of issues (VSWhidbey 382954).
            if (!String.IsNullOrEmpty(appPhysicalTargetDir))
            {
                parameter.PrecompilationFlags |= PrecompilationFlags.Clean;
            }

            _hostingParameters = new HostingEnvironmentParameters();
            _hostingParameters.HostingFlags = HostingEnvironmentFlags.DontCallAppInitialize |
                                              HostingEnvironmentFlags.ClientBuildManager;
            _hostingParameters.ClientBuildManagerParameter           = parameter;
            _hostingParameters.PrecompilationTargetPhysicalDirectory = appPhysicalTargetDir;
            if (typeDescriptionProvider != null)
            {
                _hostingParameters.HostingFlags |= HostingEnvironmentFlags.SupportsMultiTargeting;
            }

            // Make sure the app virtual dir starts with /
            if (appVirtualDir[0] != '/')
            {
                appVirtualDir = "/" + appVirtualDir;
            }

            if (appPhysicalSourceDir == null &&
                appVirtualDir.StartsWith(IISExpressPrefix, StringComparison.OrdinalIgnoreCase) &&
                appVirtualDir.Length > IISExpressPrefix.Length)
            {
                // appVirtualDir should have the form "/IISExpress/<version>/LM/W3SVC/",
                // and we will try to extract the version.  The version will be validated
                // when it is passed to IISVersionHelper..ctor.
                int endSlash = appVirtualDir.IndexOf('/', IISExpressPrefix.Length);
                if (endSlash > 0)
                {
                    _hostingParameters.IISExpressVersion = appVirtualDir.Substring(IISExpressPrefix.Length, endSlash - IISExpressPrefix.Length);
                    appVirtualDir = appVirtualDir.Substring(endSlash);
                }
            }

            Initialize(VirtualPath.CreateNonRelative(appVirtualDir), appPhysicalSourceDir);
        }