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

Missing code for .NET 6.0 #25880

Closed
JoshClose opened this issue May 17, 2022 · 4 comments · Fixed by #25882
Closed

Missing code for .NET 6.0 #25880

JoshClose opened this issue May 17, 2022 · 4 comments · Fixed by #25882
Assignees
Labels
doc-enhancement Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

@JoshClose
Copy link
Contributor

.NET 6.0 uses WebApplicationBuilder. For this to work, some modifications need to be made. I was not able to get this to run without these.

https://stackoverflow.com/questions/70571849/host-asp-net-6-in-a-windows-service

var webApplicationOptions = new WebApplicationOptions
{ 
    ContentRootPath = AppContext.BaseDirectory, 
    Args = args, 
    ApplicationName = System.Diagnostics.Process.GetCurrentProcess().ProcessName 
};
var builder = WebApplication.CreateBuilder(webApplicationOptions);

builder.Host.UseWindowsService();

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@dotnet-bot dotnet-bot added ⌚ Not Triaged Source - Docs.ms Docs Customer feedback via GitHub Issue labels May 17, 2022
@Rick-Anderson
Copy link
Contributor

Thanks for reporting.
Any chance you could PR this? At the top right of the article, select the Edit pen icon:

image

Select the pen icon again. Save.

@Rick-Anderson Rick-Anderson self-assigned this May 17, 2022
@JoshClose
Copy link
Contributor Author

I'll give it a shot.

@JoshClose
Copy link
Contributor Author

Looks like there are some unresolved issues for this. You are in on the conversation on the docs one. Seems like the solution that @davidfowl suggests is setting the --contentRoot instead of changing the WebApplicationOptions.

dotnet/runtime#69212
dotnet/aspnetcore#37464
#23387

I tried this and it works fine that way.

I updated the doc to change the PowerShell New-Service command to use --contentRoot instead of the other code.

#25882

@Rick-Anderson
Copy link
Contributor

Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-enhancement Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants