Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【demo演示】一键发布WindowsService项目(netcore web项目) #5

Open
yuzd opened this issue Feb 16, 2019 · 3 comments
Open

【demo演示】一键发布WindowsService项目(netcore web项目) #5

yuzd opened this issue Feb 16, 2019 · 3 comments
Labels
good first issue Good for newcomers

Comments

@yuzd
Copy link
Owner

yuzd commented Feb 16, 2019

前提:由于是演示WindowsService项目所以得部署好agent

参考:#1
注意:Windows 服务器上 需要安装一个agent 就是 安装一个windows服务,用来处理iis的发布和windows服务的发布,可以点击上面的参考链接进行安装。
注意: 得用管理员权限部署agent 防止会出现部署到Windows 服务上权限不足问题

这里演示的是将dotnetcore web 项目 host进Windows服务

1. 新建一个netcore的 ASP.NET Core Web应用程序

image

image

2.安装nuget依赖:Microsoft.AspNetCore.Hosting.WindowsServices

image

2.1 在Program的Main方法中,把默认的host.Run改为host.RunAsService

image

参考微软官方文档:https://github.com/aspnet/Docs/blob/master/aspnetcore/host-and-deploy/windows-service.md#get-started

3.在工程上点击右键 然后选择 AntDeploy

image

4配置AntDeploy

4.1添加一个环境 名字叫 测试

image

4.2在 测试环境里面添加 windows服务器 这里我做测试就添加就是我本机,注意Host里面是填写格式为:ip:端口号

image
注意:Token不是windows服务器的密码!!!是安装agent后,agent的配置文件里面配置的Token(你自己自定义配置的)
注意:Port不是你要发布的项目的端口号!!!是安装agent后,agent的配置文件里面配置的端口号(你自己自定义配置的)
点击【Connect Test】按钮进行确认agent可以成功链接,否则会发布失败
如果【Connect Fail】失败 请查看 #10

4.3进入 WindowsService Tab界面

Sdk类型选择 netcore
ServiceName 请自己填写 不能和现有的有重复就行 我这里就填 testnetcoreservice
image

点击 【Deploy】按钮进行发布
如下图所示:
image

确认服务器无误 点击 【是】开始执行一键部署
如果发布出现错误会出现下图所示:
image

可以在Log里面查看失败原因是因为我部署agent没有用管路员权限 报权限不足失败
image

部署成功 如下图:
image

image

这里演示的是windows服务上没有这个service
所以自动创建了。
如果service已存在的情况 Deploy 就会全量覆盖 不会重新创建site的。
如果想要覆盖时排除指定文件 可以在 Setting Tab界面的IgnoreList里面增加(支持正则)

常见错误

1.1 编译失败 日志里面报NU1605

可能在vs里面的编译是没有报错,但是antdeploy采用的是带runtime的publish
解决方案 :https://stackoverflow.com/questions/50286990/error-nu1605-detected-package-downgrade/50323131

@cns2004
Copy link

cns2004 commented Feb 27, 2019

我在添加本机Ip、端口测试的时候总是通不过,不知怎么回事。我已关闭本机防火墙。connect test提示“connect fail”

@yuzd
Copy link
Owner Author

yuzd commented Feb 27, 2019

@cns2004 方便加qq群488312978 反馈吗

@cns2004
Copy link

cns2004 commented Feb 27, 2019

@yuzd 已加。

@yuzd yuzd changed the title 【demo演示】一键发布WindowsService项目(netcore) 【demo演示】一键发布WindowsService项目(netcore web项目) Mar 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants