C# 尝试在Windows服务中托管.NET core 2.1 web应用程序会创建dll而不是exe

C# 尝试在Windows服务中托管.NET core 2.1 web应用程序会创建dll而不是exe,c#,asp.net-core,C#,Asp.net Core,按照指示一: 已安装visual studio 2017预览版 已安装.NET Core 2.1 RC1 dotnet添加包Microsoft.AspNetCore.Hosting.WindowsServices--版本2.1.0-rc1-final 新项目-> 选择左侧的.NET Core-> 选择ASP.NET核心Web应用程序-> 在顶部选择ASP.NET Core 2.1-> 选择Web应用程序-> 在program.cs中,使用Microsoft.AspNetCore.Hostin

按照指示一:

  • 已安装visual studio 2017预览版
  • 已安装.NET Core 2.1 RC1
  • dotnet添加包Microsoft.AspNetCore.Hosting.WindowsServices--版本2.1.0-rc1-final
新项目->
选择左侧的.NET Core->
选择ASP.NET核心Web应用程序->
在顶部选择ASP.NET Core 2.1->
选择Web应用程序->
在program.cs中,使用Microsoft.AspNetCore.Hosting.WindowsServices添加
->
在program.cs中,将
Run()
更改为
runaservice()
->
生成版本->
在cmd do
dotnet publish中

我得到:

>dotnet publish
Microsoft (R) Build Engine version 15.7.177.53362 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for C:\Temp\VoyDashServer\VoyDashServer\VoyDashServer\VoyDashServer.csproj...
  Generating MSBuild file C:\Temp\VoyDashServer\VoyDashServer\VoyDashServer\obj\VoyDashServer.csproj.nuget.g.props.
  Restore completed in 1.56 sec for C:\Temp\VoyDashServer\VoyDashServer\VoyDashServer\VoyDashServer.csproj.
  You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452
  VoyDashServer -> C:\Temp\VoyDashServer\VoyDashServer\VoyDashServer\bin\Debug\netcoreapp2.1\VoyDashServer.dll
  VoyDashServer -> C:\Temp\VoyDashServer\VoyDashServer\VoyDashServer\bin\Debug\netcoreapp2.1\VoyDashServer.Views.dll
  VoyDashServer -> C:\Temp\VoyDashServer\VoyDashServer\VoyDashServer\bin\Debug\netcoreapp2.1\publish\
也就是说,结果是一个dll而不是一个exe


我做错了什么?

在最后一步中,不是
dotnet publish
do

dotnet publish -c Release --self-contained -r win-x64

这将在最后一步生成.exe,而不是
dotnet publish
do

dotnet publish -c Release --self-contained -r win-x64

这将生成.exe

Camilo,我按照这里的说明:即使是通过.net核心web应用程序,也应该生成一个exe。Camilo,我按照这里的说明:即使是通过.net核心web应用程序,也应该生成一个exe。我仍然得到一个dll:(您将获得一个dll和一个exe?我想有一件事需要注意->此命令必须针对.csproj而不是.sln运行;此外,它会生成两个文件夹->
/bin/Release/win-x64/
/bin/Release/win-x64/publish
。exe仅在第二个文件夹中。我仍然获得一个dll:(您将获得一个dll和一个exe?我想有一件事需要注意->此命令必须针对.csproj而不是.sln运行;此外,它还生成两个文件夹->
/bin/Release/win-x64/
/bin/Release/win-x64/publish
。exe仅在第二个文件夹中