Resolved: ClickOnce on a net6 Console + Web Project


I have a kestrel enabled web app (I need to set up a web server listening on a custom port), but this should remain a console application that must be executed on our customers’ PCs.
Everything’s working as expected but I cannot use ClickOnce as publish profile. It just does not appear on Visual Studio 2022 publish profiles.
In my current configuration my csproj file is:
<Project Sdk="Microsoft.NET.Sdk.Web">
Modifying that with:
<Project Sdk="Microsoft.NET.Sdk">
magically ClickOnce publish profile appears, but I cannot use kestrel and infrastructure (that I need), even adding the dependencies.
How can I force visual studio to allow ClickOnce also on Web Projects?
Or as an alternative (but the former is preferred), how can I run infrastructure without Microsoft.NET.Sdk.Web?
Thanks in advance


I think you could stay with Microsoft.NET.Sdk and add a reference to the ASP.NET Core shared framework.
Your .csproj file should be something similar to this
<Project Sdk="Microsoft.NET.Sdk">


    <FrameworkReference Include="Microsoft.AspNetCore.App" />

If you have better answer, please add a comment about this, thank you!