最近在用jenkins搭建.NET自动编译发布环境时遇到的一些问题,解释不必定都对,仅记录以备后用。git
Build a Visual Studio project or solution using MSBuildweb
可能问题一、这个WorkSpace没有被替换,在bat命令行时才可使用,因而将MSBuild Build File改成 .\angularDemo\angularDemo.csprojwindows
可能问题二、检查各个属性键值里面 有没有多余的空格,有多空格也会报错。服务器
出现如下错误:error MSB4019: 未找到导入的项目“C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets”。请确认 <Import> 声明中的路径正确,且磁盘上存在该文件。
看了下电脑上有C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\ Microsoft.WebApplication.targets网络
命令行参数改成:/p:Configuration=Release;VisualStudioVersion=11.0app
error : 这台计算机上缺乏此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见http://go.microsoft.com/fwlink/?LinkID=322105。缺乏的文件是 ..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props。
由于项目中nuget下载的packages是不会上传到git 的,因此须要下载。svn
咱们在把项目提交到git或者svn上的时候并不包含这些包,咱们把项目从git上拉到下来后用vs打开,vs会首先来还原这些nuget包,一样,若是咱们是使用msbuild.exe来构建这些项目,也须要首先还原nuget包,不然项目因为缺乏依赖而没法正常编译,下面咱们就介绍如何使用nuget.exe来还原项目依赖。ui
在jenkins的项目,配置中,build节中 增长一个bat处理命令:this
"F:\Software\nuget.exe" restore ".\angularDemo\angularDemo.csproj"
注:bat命令 必需要在Build命令以前。点中拖动,可调换顺序。spa
bat命令改成:"F:\Software\nuget.exe" restore "%WORKSPACE%\angularDemo\angularDemo.csproj"
注:WORKSPACE 仅能适用于bat命令行参数。仍是同样的错误。再修改成
"F:\Software\nuget.exe" restore "%WORKSPACE%\angularDemo.sln"
终于成功了 。在jenkins工做空间 对应的项目目录下 生成了bin目录。
开关:/p:Configuration=Release;VisualStudioVersion=11.0;
不要有多于的分号,应该是 /p:Configuration=Release;VisualStudioVersion=11.0
检查一下,安装配置中MSBuild配置的路径,是否与vs版本一致。
由于个人项目是vs2017构建的,因此Msbuild改成15.0。
我就是修改后才成功出现部署步骤的。
Web 部署任务失败。(没法完成向远程代理 URL“https://dstxxx:8172/msdeploy.axd?site=Test”发送请求。) [C:\Program
error : 此错误指示您没法链接到服务器。请确保服务 URL 正确,此计算机和服务器计算机上的防火墙和网络设置配置正确,而且已在服务器上启动了适当的服务。 [C:\Program Files
将机器名(dstxxx) 改成本机ip地址后 能够了。
(你尝试使用的应用程序池已将“managedRuntimeVersion”属性设置为“v2.0”。此应用程序须要“v4.0”。
部署服务的机器上的iis站点,应用程序池 .net framework版本改成V4.0
(已使用指定的进程(“Web Management Service”)链接到远程计算机(“172.xxx.yy.zz”),但未能验证服务器的证书。若是你信任该服务器,请再次链接并容许不信任的证书。
在配置中的 ——>构建中加一个参数(容许未信任的证书)
/p:AllowUntrustedCertificate=True
(已使用 Web 管理服务链接到远程计算机(“172.xxx.yy.zz”),但未能受权。请确保你使用了正确的用户名和密码、你链接的站点已存在而且凭据表明的用户有权访问该站点。
看了下 密码并无保存在PublishProfile文件中。
因此配置项中还得加上password属性。若是已经加了password属性,则大概是用户密码错了,能够从新建立一个试试。
(Unable to perform the operation ("Create Directory") for the specified directory ("E:\IIS_Deploy\FirstSite").
This can occur if the server administrator has not authorized this operation for the user credentials you are using.
应该是配置的用户不对,在IIS中从新设置:IIS管理器权限的用户 。【在实际中我用windows用户,而不是iis管理器类型的用户,是ok的】
msdeploy error ERROR_FILE_IN_USE: Web deployment task failed. (Web Deploy cannot modify the file 'xx.InjectModule.dll'
on the destination because it is locked by an external process. In order to allow the publish operation to succeed,
you may need to either restart your application to release the lock, or use the AppOffline rule handler for .
Net applications on your next publish attempt. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.)
缘由:是说某个某件被占用了。解决方法是 重启应用程序池或者添加配置(参考连接),我使用重启应用程序池解决的,有多个应用的时候能够只重启一个,
应用程序->右键 deploy里面有选项。
The OutputPath property is not set for project 'xx.Service.Config.csproj'. Please check to make sure that you have specified
a valid combination of Configuration and Platform for this project. Configuration='DEV' Platform='AnyCPU'.
You may be seeing this message because you are trying to build a project without a solution file, and have specified a
non-default Configuration or Platform that doesn't exist for this project.
缘由:指出的项目 没有配置Dev的配置。在项目的配置管理器中配置相应的环境。