'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 asp.net 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 asp.net infrastructure without Microsoft.NET.Sdk.Web?

Thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source