繁体   English   中英

TeamCity MSBuild,在部署期间重新映射文​​件夹

[英]TeamCity MSBuild, remap folders during deployment

我们有一个网站项目的解决方案,该项目托管在负载平衡的环境中。 目前没有使用CI,使用zip文件> _ <手动进行部署,但是我正在设置它,但遇到了一些困难。 该解决方案需要一个App_Config文件夹,该文件夹在根目录中包含该站点的所有配置,但是这些配置不同于每个托管服务器,其中一个是管理服务器,另一个是交付服务器。

每个单独的服务器配置都存储在/ Configs / servername /处的单独文件夹中,其中包含web.config文件和App_Config文件夹。 这些已从此文件夹手动复制到根目录,以覆盖已经存在的目录。 另外,也不希望部署/ Configs /文件夹。

最好不要对Visual Studio解决方案进行任何更改。

在TeamCity中部署之前是否可以自动执行此操作?

问候

您可能需要根据计算机名称为属性设置不同的值。 那是交易的把戏。

<Choose>
    <When Condition=" '$(Computername)'=='MyManagementServer01' ">               
        <PropertyGroup>
            <MyCustomProperty001>Red</MyCustomProperty001>
            <MyCustomProperty002>Yellow</MyCustomProperty002>
        </PropertyGroup>
    </When>

    <When Condition=" '$(Computername)'=='MyDeliveryServer01' ">

        <PropertyGroup>
            <MyCustomProperty001>Black</MyCustomProperty001>
            <MyCustomProperty002>White</MyCustomProperty002>
        </PropertyGroup>

    </When>

    <Otherwise>

        <PropertyGroup>
            <MyCustomProperty001>NoMatchMyCustomProperty001</MyCustomProperty001>
            <MyCustomProperty002>NoMatchMyCustomProperty002</MyCustomProperty002>
        </PropertyGroup>        

    </Otherwise>

</Choose>

您可以设置一个名为

<ConfigurationSourceFolder>/Configs/MyManagementServer01/</ConfigurationSourceFolder>

或设置一个“ DeploymentType”

<DeploymentType>ManagementServerType</DeploymentType>

您还可以在“目标”甚至“任务”上放置条件。

<MakeDir Directories="C:\MyCoolDirectory" Condition="('$(MyCustomProperty001)'!='')"/>

////////最好不必对Visual Studio解决方案进行任何更改。//////

因此,这里有一个“一般性”提示。 而不是在csproj文件中进行很多有时很难遵循的自定义更改。...使用基本的.msbuild文件。

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapped">
    <PropertyGroup>
        <!-- Always declare some kind of "base directory" and then work off of that in the majority of cases  -->
        <WorkingCheckout>.</WorkingCheckout>
    </PropertyGroup>

    <Target Name="AllTargetsWrapped">

        <CallTarget Targets="BuildItUp" />

    </Target>


    <Target Name="BuildItUp" >
        <MSBuild Projects="$(WorkingCheckout)\MySolution.sln" Targets="Build" Properties="Configuration=$(Configuration)">
            <Output TaskParameter="TargetOutputs" ItemName="TargetOutputsItemName"/>
        </MSBuild>
        <Message Text="BuildItUp completed" />
    </Target>

</Project>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM