src/Interlook.AspNetCore.Testing.IISExpress/IISExpress.cs
/// <summary>
/// Starts a new IIS-Express process for a given ASP .NET Core project.
/// </summary>
/// <param name="appHostConfigFilePath">Full path of an 'applicationhost.config' file, belonging to the ASP .NET Core Project under Test.</param>
/// <param name="siteName">Name of the site, which must be contained in the config file provided in <paramref name="appHostConfigFilePath"/>.</param>
/// <param name="appPool">Name of the application pool (also in file <paramref name="appHostConfigFilePath"/>).</param>
/// <param name="launcherRelativePath">File path of the executable file of the 'Project under Test' (including extension),
/// relative to the projects base path, this is usually where the <c>.csproj</c> file resides.</param>
/// <param name="iisExpressExecutableFilePath">Full path to the executable file of IIS-Express server.</param>
/// <param name="aspEnvironmentName">Name of the ASP environment (defaults to <c>Development</c>), set via the <c>ASPNETCORE_ENVIRONMENT</c> environment variable.</param>
/// <returns>An instance of <see cref="Process.Started"/>, if the server process has been successfully launched, that can be used to stop that server process;
/// otherwise a <see cref="Process.Failed"/> instance containing the error/exception that occured.</returns>
/// <exception cref="ArgumentNullException">
/// appHostConfigFilePath
/// or
/// siteName
/// or
/// appPool
/// or
/// launcherRelativePath
/// </exception>
Starts a new IIS-Express process for a given ASP .NET Core project.
Starts a new IIS - Express process for a given ASP . NET Core project .
public static Process Start(string appHostConfigFilePath, string siteName, string appPool, string launcherRelativePath, string iisExpressExecutableFilePath = DefaultIISExpressExecutablePath, string aspEnvironmentName = DefaultAspEnvironment)
        {
            try
            {
                var iis = new IISExpress(appHostConfigFilePath ?? throw new ArgumentNullException(nameof(appHostConfigFilePath)),
                    siteName ?? throw new ArgumentNullException(nameof(siteName)),
                    appPool ?? throw new ArgumentNullException(nameof(appPool)),
                    launcherRelativePath ?? throw new ArgumentNullException(nameof(launcherRelativePath)),
                    aspEnvironmentName ?? string.Empty,
                    iisExpressExecutableFilePath ?? DefaultIISExpressExecutablePath);
                if (iis._process.Start() == false)
                    return new Process.Failed(new InvalidOperationException("IIS process launch failed unexpectedly."));
                if (iis._process.HasExited)
                    return new Process.Failed(new InvalidOperationException("IIS process has exited unexpectedly."));
                return new Process.Started(iis);
            }
            catch (Exception ex)
            {
                return new Process.Failed(ex);
            }
        }
public static Process Start ( string appHostConfigFilePath , string siteName , string appPool , string launcherRelativePath , string iisExpressExecutableFilePath = DefaultIISExpressExecutablePath , string aspEnvironmentName = DefaultAspEnvironment ) { try { var iis = new IISExpress ( appHostConfigFilePath ?? throw new ArgumentNullException ( nameof ( appHostConfigFilePath ) ) , siteName ?? throw new ArgumentNullException ( nameof ( siteName ) ) , appPool ?? throw new ArgumentNullException ( nameof ( appPool ) ) , launcherRelativePath ?? throw new ArgumentNullException ( nameof ( launcherRelativePath ) ) , aspEnvironmentName ?? string . Empty , iisExpressExecutableFilePath ?? DefaultIISExpressExecutablePath ) ; if ( iis . _process . Start ( ) == false ) return new Process . Failed ( new InvalidOperationException ( " " ) ) ; if ( iis . _process . HasExited ) return new Process . Failed ( new InvalidOperationException ( " " ) ) ; return new Process . Started ( iis ) ; } catch ( Exception ex ) { return new Process . Failed ( ex ) ; } }
Starts a new IIS-Express process for a given ASP .NET Core project.
Starts a new IIS - Express process for a given ASP . NET Core project .
An instance of , if the server process has been successfully launched, that can be used to stop that server process;
otherwise a  instance containing the error/exception that occured.
An instance of if the server process has been successfully launched that can be used to stop that server process ; otherwise a instance containing the error / exception that occured .
appHostConfigFilePath
or
siteName
or
appPool
or
launcherRelativePath
appHostConfigFilePath or siteName or appPool or launcherRelativePath
appHostConfigFilePath
string
Full path of an 'applicationhost.config' file, belonging to the ASP .NET Core Project under Test.
Full path of an ' applicationhost . config ' file belonging to the ASP . NET Core Project under Test .
siteName
string
Name of the site, which must be contained in the config file provided in .
Name of the site which must be contained in the config file provided in .
appPool
string
Name of the application pool (also in file ).
Name of the application pool ( also in file ) .
launcherRelativePath
string
File path of the executable file of the 'Project under Test' (including extension),
relative to the projects base path, this is usually where the .csproj
File path of the executable file of the ' Project under Test ' ( including extension ) relative to the projects base path this is usually where the . csproj
iisExpressExecutableFilePath
string
Full path to the executable file of IIS-Express server.
Full path to the executable file of IIS - Express server .
aspEnvironmentName
string
Name of the ASP environment (defaults to DevelopmentASPNETCORE_ENVIRONMENT
Name of the ASP environment ( defaults to DevelopmentASPNETCORE_ENVIRONMENT
DevelopmentASPNETCORE_ENVIRONMENT