Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing problem on Linux where dotnet run fails because we try to set an IIS config #17903

Open
wants to merge 5 commits into
base: contrib
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,35 @@ public static IUmbracoBuilder AddHelpers(this IUmbracoBuilder builder)
[Obsolete("This is not necessary any more. This will be removed in v17")]
public static IUmbracoBuilder AddWebServer(this IUmbracoBuilder builder)
{
builder.Services.Configure<KestrelServerOptions>(options =>
{
options.AllowSynchronousIO = true;
});

try
{
// See https://github.com/umbraco/Umbraco-CMS/pull/17886. This is a workaround for non-windows machines
// they won't have IIS available and trying to set this option will throw an exception.
//
// We're deferring this call to a method because if we just try to set the options here, we still get a
// TypeLoadException on non-windows machines.
// This workaround came from this comment: https://stackoverflow.com/a/3346975
AllowSynchronousIOForIIS(builder);
}
catch (Exception)
nul800sebastiaan marked this conversation as resolved.
Show resolved Hide resolved
{
// Ignoring this exception because it's expected on non-windows machines
}
return builder;
}

private static void AllowSynchronousIOForIIS(IUmbracoBuilder builder) =>
nul800sebastiaan marked this conversation as resolved.
Show resolved Hide resolved
builder.Services.Configure<IISServerOptions>(
options =>
{
options.AllowSynchronousIO = true;
});

private static IProfiler GetWebProfiler(IConfiguration config, IHttpContextAccessor httpContextAccessor)
{
var isDebug = config.GetValue<bool>($"{Constants.Configuration.ConfigHosting}:Debug");
Expand Down
Loading