Jenkins搭建.NET自动编译测试与发布环境
2017-03-24 18:03
302 查看
本文地址: http://blog.csdn.net/wangjia184/article/details/18365553
操作系统Windows, 确保需要的.NET Framework已经安装
从 http://jenkins-ci.org/下载Windows安装包。
安装后,访问http://localhost:8080 .
Jenkins => Manager Jenkins => Manage Plugins
在Available选项卡中,选中MSBuild Plugin
然后点击安装
安装完后, 切换到 Jenkins => Manager Jenkins => Configure System
找到MSBuild那节,填入 MSBuild的路径
如 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSbuild.exe
然后点击 New Job, 输入任务名称
然后配置好源代码管理,例如SVN
然后到Build节,
MSBuilder Version 为之前配置的 "Version 4.0"
MSBuild Build File 是项目文件或者工程文件的名称
然后就是MSBuild的命令行参数了。
/t:Rebuild 表示每次都重建,不使用增量编译
/property:Configuration=Release 表示编译Release版本,
/property:TargetFrameworkVersion=v4.5表示编译的目标是.NET 4.5
保存后,点击左侧Build Now开始测试一次编译。
如果编译过程中出现错误,需查看Console Output.
一种常见的错误情况是:编译的机器上没有安装Visual Studio, 在编译的过程中可能会引发MSB4019错误. 例如
[plain] view plain copy
print?
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
对于这种情况,可以将开发机上的C:\Program Files (x86)\MSBuild文件夹之间拷贝到编译机上。
如果成功,则显示 0 Error(s),在编译成功后可以启动单元测试,如果有NUnit的话.
部署的话,可以通过批处理完成, 首先安装 Post build task插件, 与之前MSBuild插件的安装方式一样
然后在Job的配置中,添加post build task
在Log Text那,可以使用正则表达式检测0 Error(s)出现了, 如\b0\s+(Errors)
Script中直接调用磁盘上的批处理文件
使用如下参数
[plain] view plain copy
print?
/t:ResolveReferences;Compile /t:_CopyWebApplication /p:Configuration=Release /p:WebProjectOutputDir=C:\Jenkins_Publish /p:OutputPath=C:\Jenkins_Publish\bin
其中WebProjectOutputDir是web站点的发布路径;OutputPath是编译输出的dll路径
配置好发布方式,比如以“文件系统”方式发布,需要注意的是,目标位置是编译服务器上的路径
在保存后,在项目的Properties/PublishProfiles可以找到这些*.pubxml文件
[html] view plain copy
print?
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>C:\Jenkins_Publish\DEV_Metadata</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
可以直接在此修改配置。最后提交到源代码管理中
最后配置参数即可
[plain] view plain copy
print?
/t:Rebuild /p:Configuration=Release;PublishProfile=Jenkins-DEV;DeployOnBuild=true;VisualStudioVersion=11.0
PublishProfile指定创建的Profile名称(没有扩展名)
DeployOnBuild=true 表示启用编译并发布
VisualStudioVersion=11.0 表示VS2012
本文地址: http://blog.csdn.net/wangjia184/article/details/18365553
操作系统Windows, 确保需要的.NET Framework已经安装
从 http://jenkins-ci.org/下载Windows安装包。
安装后,访问http://localhost:8080 .
Jenkins => Manager Jenkins => Manage Plugins
在Available选项卡中,选中MSBuild Plugin
然后点击安装
安装完后, 切换到 Jenkins => Manager Jenkins => Configure System
找到MSBuild那节,填入 MSBuild的路径
如 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSbuild.exe
然后点击 New Job, 输入任务名称
然后配置好源代码管理,例如SVN
然后到Build节,
MSBuilder Version 为之前配置的 "Version 4.0"
MSBuild Build File 是项目文件或者工程文件的名称
然后就是MSBuild的命令行参数了。
/t:Rebuild 表示每次都重建,不使用增量编译
/property:Configuration=Release 表示编译Release版本,
/property:TargetFrameworkVersion=v4.5表示编译的目标是.NET 4.5
保存后,点击左侧Build Now开始测试一次编译。
如果编译过程中出现错误,需查看Console Output.
一种常见的错误情况是:编译的机器上没有安装Visual Studio, 在编译的过程中可能会引发MSB4019错误. 例如
[plain] view plain copy
print?
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
对于这种情况,可以将开发机上的C:\Program Files (x86)\MSBuild文件夹之间拷贝到编译机上。
如果成功,则显示 0 Error(s),在编译成功后可以启动单元测试,如果有NUnit的话.
部署的话,可以通过批处理完成, 首先安装 Post build task插件, 与之前MSBuild插件的安装方式一样
然后在Job的配置中,添加post build task
在Log Text那,可以使用正则表达式检测0 Error(s)出现了, 如\b0\s+(Errors)
Script中直接调用磁盘上的批处理文件
补充1.如何发布VS2010的Web站点
如果是发布Web站点,可以直接指定需要发布站点的csproj文件,如使用如下参数
[plain] view plain copy
print?
/t:ResolveReferences;Compile /t:_CopyWebApplication /p:Configuration=Release /p:WebProjectOutputDir=C:\Jenkins_Publish /p:OutputPath=C:\Jenkins_Publish\bin
其中WebProjectOutputDir是web站点的发布路径;OutputPath是编译输出的dll路径
补充2.如何发布VS2012的Web站点
首先在VS2012中新建发布配置项配置好发布方式,比如以“文件系统”方式发布,需要注意的是,目标位置是编译服务器上的路径
在保存后,在项目的Properties/PublishProfiles可以找到这些*.pubxml文件
[html] view plain copy
print?
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>C:\Jenkins_Publish\DEV_Metadata</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
可以直接在此修改配置。最后提交到源代码管理中
最后配置参数即可
[plain] view plain copy
print?
/t:Rebuild /p:Configuration=Release;PublishProfile=Jenkins-DEV;DeployOnBuild=true;VisualStudioVersion=11.0
PublishProfile指定创建的Profile名称(没有扩展名)
DeployOnBuild=true 表示启用编译并发布
VisualStudioVersion=11.0 表示VS2012
本文地址: http://blog.csdn.net/wangjia184/article/details/18365553
相关文章推荐
- Jenkins搭建.NET自动编译测试与发布环境
- Jenkins搭建.NET自动编译测试与发布环境
- Jenkins搭建.NET自动编译测试与发布环境
- Windows2012中Jenkins搭建.NET自动编译测试与发布环境
- Java开发流程自动化(svn+maven+nexus+jenkins) --自动编译,持续集成,测试,打包,发布/部署
- SVN本地开发、测试环境版本控制-自动发布生产环境
- Java开发流程自动化(svn+maven+nexus+jenkins) --自动编译,持续集成,测试,打包,发布/部署
- ASP.Net一键自动化更新代码、编译、合并dll、压缩js、css、混淆dll、zip打包、发布到测试环境的bat批处理
- jenkins自动部署--定时轮询svn代码更新并自动发布至测试环境
- php利用svn hooks将程序自动发布到测试环境
- 测试交叉编译环境arm-elf-tools-20040427.sh安装是否成功
- 项目管理实践【四】自动编译和发布网站【Using Visual Studio with Source Control System to build and publish website automatically】
- 自动编译环境
- 编译和测试环境——VMware:简介和教程
- 项目管理实践【五】自动编译和发布网站【Using Visual Studio with Source Control System to build and publish website automatically】
- 项目管理实践【五】自动编译和发布【Using Visual Studio with Source Control System to build and publish website automatically】
- BlackBerry自动编译、签名、发布Ant脚本
- 项目管理实践五、自动编译和发布网站【Using Visual Studio with Source Control S
- 发布一个简单而又灵活的基础编译环境文件:compiler.mk,欢迎大家共同改进之
- 从VSS自动拉下文件/编译/发布到Linux服务器 一条龙脚本(无人工干预)