在使用MSBuild进行Asp.net MVC website CI部署过程中的若干问题解决

下载web deploy:

https://www.iis.net/downloads/microsoft/web-deploy

安装web deploy:

http://edi.wang/Post/2013/12/21/iis-webdeploy-on-ws2008r2

安装web deploy以及进行部署

https://blog.csdn.net/codec007/article/details/46442957

BuildTool:

https://download.microsoft.com/download/E/E/D/EEDF18A8-4AED-4CE0-BEBE-70A83094FC5A/BuildTools_Full.exe

正确命令:

FileSystem(推荐,简单)

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" /p:DeployOnBuild=true /p:PublishProfile=Server1Profile /p:WebPublishMethod=FileSystem "E:\MyProject\Myproject.Web.csproj"

MsDeploy(维护方便,但前期需要配置)

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" /p:DeployOnBuild=true /p:PublishProfile=Server1Profile /p:WebPublishMethod=MSDeploy E:\MyProject\Myproject.Web.csproj

 

Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

nuget的版本为3.5版本,其对应的MSBuild版本为14,而服务器上未安装此版本MSBuild。

解决方案:安装对应MSBuild版本的BuildTool工具

另外可行:运行命令nuget update -self更新至最新版本,但同时意味着package里的内容也会相应需要更新。

 

Error CS0012 The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51

查找原因,答案大部分为给项目添加reference,因为此项目都是使用nuget获取package,reference需要恢复,直接引用不方便。折衷方案:添加<>到各个csproj中去

 

使用类型为WebDeploy的Profile进行publish

Msbuild WebPublishMethod does not have a valid value. Current Value is ‘’

此问题为未制定WebPublishMethod的参数

 

public class global_asax : global::Agency.Web.MvcApplication CS0012: The type 'System.Object' is defined in an assembly that is not referenced.

解决方案:拷贝netstandard.dll进bin文件夹中

 

ERROR_DESTINATION_NOT_REACHABLE

未安装Web deploy, 或者服务器未启动Web Deployment Agent Service,或者服务器打开了防火墙

 

ERROR_USER_NOT_ADMIN ... Web Deployment Agent Service, but could not authorize. Make sure you are an administrator on

问题为credential无效,不能进行web deploy发布,使用参考4, 5, 6进行配置允许匿名用户发布,中间遇到问题,未果。

 

可以进行部署,运行起网站的时候报错缺少若干dll

因为MSBuild运行在服务器上,服务器缺少一些dll环境或者dll版本比较旧,

解决方案:从正常发布的文件夹中拷贝出dll并进行/拷贝替换bin目类下对应项

 

页面不再报错,但是网站无法显示出来,空白页

查看windows log,发现有错误日志:ABP编译过程缺少dll,

解决方案:继续使用拷贝替换bin目类下dll的方式。

 

【参考】

1, https://stackoverflow.com/questions/46461278/msbuild-webpublishmethod-does-not-have-a-valid-value

2, https://stackoverflow.com/questions/13920146/using-msbuild-exe-to-publish-a-asp-net-mvc-4-project-with-the-cmd-line

3, https://stackoverflow.com/questions/16246562/using-msbuild-to-execute-a-file-system-publish-profile

4, https://forums.asp.net/t/2126876.aspx?WebDeploy+ERROR_USER_NOT_ADMIN

5, https://blogs.msdn.microsoft.com/amol/2011/02/09/allowing-non-admin-users-to-deploy-web-applications-on-iis-7-using-web-deploy-2-0/

6, https://forums.iis.net/t/1190239.aspx

7, https://docs.microsoft.com/en-us/iis/publish/troubleshooting-web-deploy/troubleshooting-web-deploy-problems-with-visual-studio

8, nuget build checker https://github.com/NuGet/Home/issues/4091

9, nuget error version https://github.com/NuGet/Home/issues/4091

10, add netstandard reference to project https://github.com/dotnet/standard/issues/542

11, nuget cli command https://docs.microsoft.com/en-us/nuget/tools/nuget-exe-cli-reference

12: Jenkins需要安装插件NodeJS Plugin

13, netstandard reference https://davidsekar.com/asp-net/you-must-add-a-reference-to-assembly-netstandard

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值