必须建立2个解决方案,每个项目一个
我们必须在TFS服务器上建立两个解决方案。一种解决方案是框架,另一种解决方案包括服务,应该为每个项目单独构建服务,以便稍后通过脚本部署它们。必须建立2个解决方案,每个项目一个
此外,框架程序集复制到框架解决方案中的(基础)项目。第二个解决方案的所有项目都涉及这个“基础”项目。
我的问题是,我不知道如何配置解决方案,项目和构建以执行上述请求。
请帮忙。
注意:我不想将每个服务项目放入msi中以便安装它。我只想将服务从TFS服务器上的中央下拉文件夹中部署出来。
一种选择是举办自己的NuGet饲料:http://docs.nuget.org/create/hosting-your-own-nuget-feeds
通过托管自己的饲料,您可以执行自定义生成您的构建过程,更新您的饲料内的活动。
请参阅本文档定制TFS共建活动:http://nakedalm.com/creating-a-custom-activity-for-team-foundation-build/
添加PowerShell来构建过程请参见本文档:http://blogs.technet.com/b/heyscriptingguy/archive/2014/04/21/powershell-and-tfs-the-basics-and-beyond.aspx
通过托管自己的NuGet饲料,你必须有你的消费解决方案的能力利用你的私人矿块饲料和包来处理依赖管理和版本。通过利用自定义构建活动,您可以通过.net或PowerShell更新您的nuget feed。您还可以通过PowerShell脚本自动执行部署。
Team Build可以在构建过程模板中构建多个解决方案。只需点击Projects to Build后面的
[...]
按钮并添加两个解决方案。TFS重定向你的项目的输出目录,这可能会破坏你的脚本,复制从A到B的“基础工程”的输出。为了把这个重定向设置输出位置到AsConfigured 。
现在TFS将不知道如何将输出复制到Binaries文件夹,该文件夹用作复制到放置位置操作的源。为了解决这个问题,你需要编写一个powershell脚本和configure this as a post-build script。
创建一个脚本下降的过程是clearly documented on MSDN和sample script is available from CodePlex。
##-----------------------------------------------------------------------
## <copyright file="GatherItemsForDrop.ps1">(c) http://TfsBuildExtensions.codeplex.com/. This source is subject to the Microsoft Permissive License. See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. All other rights reserved.</copyright>
##-----------------------------------------------------------------------
# Copy the binaries to the bin directory
# so that the build server can drop them
# to the staging location specified on the Build Defaults tab
#
# See
# http://msdn.microsoft.com/en-us/library/bb778394(v=vs.120).aspx
# http://msdn.microsoft.com/en-us/library/dd647547(v=vs.120).aspx#scripts
# Enable -Verbose option
[CmdletBinding()]
# Disable parameter
# Convenience option so you can debug this script or disable it in
# your build definition without having to remove it from
# the 'Post-build script path' build process parameter.
param([switch]$Disable)
if ($PSBoundParameters.ContainsKey('Disable'))
{
Write-Verbose "Script disabled; no actions will be taken on the files."
}
# This script copies the basic file types for managed code projects.
# You can change this list to meet your needs.
$FileTypes = $("*.exe","*.dll","*.exe.config","*.pdb")
# Specify the sub-folders to include
$SourceSubFolders = $("*bin*","*obj*")
# If this script is not running on a build server, remind user to
# set environment variables so that this script can be debugged
if(-not $Env:TF_BUILD -and -not ($Env:TF_BUILD_SOURCESDIRECTORY -and $Env:TF_BUILD_BINARIESDIRECTORY))
{
Write-Error "You must set the following environment variables"
Write-Error "to test this script interactively."
Write-Host '$Env:TF_BUILD_SOURCESDIRECTORY - For example, enter something like:'
Write-Host '$Env:TF_BUILD_SOURCESDIRECTORY = "C:\code\FabrikamTFVC\HelloWorld"'
Write-Host '$Env:TF_BUILD_BINARIESDIRECTORY - For example, enter something like:'
Write-Host '$Env:TF_BUILD_BINARIESDIRECTORY = "C:\code\bin"'
exit 1
}
# Make sure path to source code directory is available
if (-not $Env:TF_BUILD_SOURCESDIRECTORY)
{
Write-Error ("TF_BUILD_SOURCESDIRECTORY environment variable is missing.")
exit 1
}
elseif (-not (Test-Path $Env:TF_BUILD_SOURCESDIRECTORY))
{
Write-Error "TF_BUILD_SOURCESDIRECTORY does not exist: $Env:TF_BUILD_SOURCESDIRECTORY"
exit 1
}
Write-Verbose "TF_BUILD_SOURCESDIRECTORY: $Env:TF_BUILD_SOURCESDIRECTORY"
# Make sure path to binary output directory is available
if (-not $Env:TF_BUILD_BINARIESDIRECTORY)
{
Write-Error ("TF_BUILD_BINARIESDIRECTORY environment variable is missing.")
exit 1
}
if ([IO.File]::Exists($Env:TF_BUILD_BINARIESDIRECTORY))
{
Write-Error "Cannot create output directory."
Write-Error "File with name $Env:TF_BUILD_BINARIESDIRECTORY already exists."
exit 1
}
Write-Verbose "TF_BUILD_BINARIESDIRECTORY: $Env:TF_BUILD_BINARIESDIRECTORY"
# Tell user what script is about to do
Write-Verbose "Will look for and then gather "
Write-Verbose "$FileTypes files from"
Write-Verbose "$Env:TF_BUILD_SOURCESDIRECTORY and copy them to "
Write-Verbose $Env:TF_BUILD_BINARIESDIRECTORY
# Find the files
$files = gci $Env:TF_BUILD_SOURCESDIRECTORY -recurse -include $SourceSubFolders |
?{ $_.PSIsContainer } |
foreach { gci -Path $_.FullName -Recurse -include $FileTypes }
if($files)
{
Write-Verbose "Found $($files.count) files:"
foreach ($file in $files) {
Write-Verbose $file.FullName
}
}
else
{
Write-Warning "Found no files."
}
# If binary output directory exists, make sure it is empty
# If it does not exist, create one
# (this happens when 'Clean workspace' build process parameter is set to True)
if ([IO.Directory]::Exists($Env:TF_BUILD_BINARIESDIRECTORY))
{
$DeletePath = $Env:TF_BUILD_BINARIESDIRECTORY + "\*"
Write-Verbose "$Env:TF_BUILD_BINARIESDIRECTORY exists."
if(-not $Disable)
{
Write-Verbose "Ready to delete $DeletePath"
Remove-Item $DeletePath -recurse
Write-Verbose "Files deleted."
}
}
else
{
Write-Verbose "$Env:TF_BUILD_BINARIESDIRECTORY does not exist."
if(-not $Disable)
{
Write-Verbose "Ready to create it."
[IO.Directory]::CreateDirectory($Env:TF_BUILD_BINARIESDIRECTORY) | Out-Null
Write-Verbose "Directory created."
}
}
# Copy the binaries
Write-Verbose "Ready to copy files."
if(-not $Disable)
{
foreach ($file in $files)
{
Copy $file $Env:TF_BUILD_BINARIESDIRECTORY
}
Write-Verbose "Files copied."
}
更好的解决方案很可能是具有2个独立的建立,其中所述第一生成发布第二个项目作为NuGet包的依赖关系。 The Microsoft ALM Rangers have delivered a guide,解释如何设置。
感谢您的意见。 – GermanBoy
我发现“我的”解决方案:在构建配置“过程”2.5。我放了一些MSBuild参数,如:/ p:ReferenzPath =“...; ...”,以便所有解决方案都能找到所需的源。有一个名为“$(TF_BUILD_BUILDDIRECTORY)”的系统变量帮助我找到基本路径。之后,我在构建定义中放入MSBuild参数:/ p:GenerateProjectSpecificOutputFolder = true“。所有解决方案都将构建”每个项目“。现在我将编写一个后构建脚本,将一些文件夹和配置文件复制到构建输出,为此,我将使用上面的代码snipplet作为方向 – GermanBoy
您不需要创建自定义活动来执行此操作。您只需从模板中的预定义脚本位置调用一个小PowerShell。 –