Jenkins在Windows系统dotnet平台持续集成
之前写过一篇文章是在CentOS上构建.net自动化编译环境, 今天这篇是针对于Windows平台的环境。
Jenkins是一个开源软件项目,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能。Jenkins是基于Java开发的一种持续集成工具,用于监控持续重复的工作,
Jenkins是由Sun的前员工开发的,它的根基是Java,但也可以用在非Java的项目里,比如PHP、Ruby on Rails、.NET。持续集成相关的工具有很多。它提供了Web界面,用户可以在界面
上配置Job,每个Job都包含一系列的构建步骤。Jenkins可以完成开头那个场景中所提到的所有验证工作,它还能更进一步做自动化部署或者一键式部署。
我们开始吧, 环境 Windows Server 2012
1. Install Jenkins 2. Install MsBuild, Git Plugin for JenkinsGIT client plugin
Shared library plugin for other Git related Jenkins plugins.
GIT plugin
This plugin integrates GIT with Jenkins.
MSBuild Plugin
This plugin makes it possible to build a Visual Studio project (.proj) and solution files (.sln).
SCM API Plugin
This plugin provides a new enhanced API for interacting with SCM systems.
Credentials Plugin
This plugin allows you to store credentials in Jenkins.
插件可以在这儿找到 https://wiki.jenkins-ci.org/display/JENKINS/Plugins
3. Install Git从官网下载安装
4. Install .net Framework 4.5.2官网下载安装 ?id=42642
5. Install 微软Build Tools 2013官网下载安装 ?id=40760
6. 假设本地已安装VS2013, 复制本地 C:\Program Files (x86)\MSBuild\Microsoft 下所有文件到服务器相同位置上笔者是看到是这些文件
打包放置到服务器上面对应路径。
7. Install Web Deploy v3.0官网下载安装
8. Install Artifact Deployer PluginThis artifact allows you to choose which directories you will like to deploy to the target destination
https://wiki.jenkins-ci.org/display/JENKINS/ArtifactDeployer+Plugin
Git配置
MsBuild配置
邮件
其它问题 1. 编译时转换Web.config文件
例如, 我们需要在Release模式下,替换Web错误显示机制,数据库连接字符串, 日志文件输出级别或目录等配置都可以。
If you add the following xml to the bottom of the .csproj file for your web application, you‘ll ensure that the config transformation occurs before every build:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> <Target Name="BeforeBuild"> <TransformXml Source="Web.Base.config" Transform="Web.$(Configuration).config" Destination="Web.config" /> </Target>Edit: In response to your comment, you should be able to use Web.config as the source parameter in the TransformXml task (see step #2). If you only want to perform the config transform in the build script, follow these instructions:
1) Import WebApplication.targets in your build script like so:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />2) Execute the TransformXml build task in your build script target:
<Target Name="MyBuildScriptTarget"> <TransformXml Source="Web.config" Transform="Web.$(Configuration).config" Destination="Web.config" /> ...other build tasks... </Target>转换NLog.config,也可以参考Web.config,实现NLog.Debug.config与Nlog.Release.config, 如下示例的NLog.Release.config文件:
<?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="" xmlns:xsi="" xmlns:xdt=""> <targets async="true"> <target xdt:Transform="Insert" name="elastic" xsi:type="ElasticSearch" uri=":9200/" index="WebAppInit" documentType="logevent"> <field name="logger" layout="${logger}" layoutType="System.String" /> </target> </targets> <rules> <logger xdt:Transform="Insert" name="*" minlevel="Trace" writeTo="elastic" /> </rules> </nlog> 上面我们在Release模式下,增加了NLog输出到ElasticSearch的配置节。 2. Microsoft.Build.Tasks.v4.0编译问题Build Failure issue:温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/67234.html