Home > front end >  ClickOnce on a net6 Console Web Project
ClickOnce on a net6 Console Web Project

Time:02-11

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

CodePudding user response:

I think you could stay with Microsoft.NET.Sdk and add a reference to the ASP.NET Core shared framework.

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/target-aspnetcore?view=aspnetcore-6.0&tabs=visual-studio#use-the-aspnet-core-shared-framework

Your .csproj file should be something similar to this

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>
</Project>
  • Related