为了账号安全,请及时绑定邮箱和手机立即绑定

尝试在窗口服务中托管 .NET Core 2.1 Web 应用程序会创建 dll 而不是 exe

尝试在窗口服务中托管 .NET Core 2.1 Web 应用程序会创建 dll 而不是 exe

C#
PIPIONE 2021-06-23 18:12:12
按照这里的说明,我:已安装 Visual Studio 2017 预览版已安装 .NET Core 2.1 RC1dotnet add package Microsoft.AspNetCore.Hosting.WindowsServices --version 2.1.0-rc1-final新建项目->左侧选择.NET Core ->选择ASP.NET Core Web Application ->顶部选择ASP.NET Core 2.1 ->选择Web Application ->在program.cs中添加using Microsoft.AspNetCore.Hosting.WindowsServices;->在program.cs中更改Run()to RunAsService()->build release ->在 cmd 中做dotnet publish我得到:>dotnet publishMicrosoft (R) Build Engine version 15.7.177.53362 for .NET CoreCopyright (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我究竟做错了什么 ?
查看完整描述

1 回答

?
饮歌长啸

TA贡献1951条经验 获得超3个赞

在最后一步,而不是dotnet publish

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

这将生成 .exe


查看完整回答
反对 回复 2021-06-26
  • 1 回答
  • 0 关注
  • 186 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信