MSDeploy所有配置在一个封装[.config文件]文件、MSDeploy、config

由网友(青灯沽酒)分享简介:我们有4个不同的环境的时刻(实验室测试,舞台,现场),我们已经实现了自动化部署中使用南特/ CC.Net。我调查和做一些研究,以什么可以更有效地与新MSDeploy工具来完成。We have 4 different environments at the moment (Lab, Test, Stage, LIVE)...

我们有4个不同的环境的时刻(实验室测试,舞台,现场),我们已经实现了自动化部署中使用南特/ CC.Net。我调查和做一些研究,以什么可以更有效地与新MSDeploy工具来完成。

We have 4 different environments at the moment (Lab, Test, Stage, LIVE) and we have implemented automatic deployment using Nant/CC.Net. I am investigating and doing some research as to what can be done more efficiently with new MSDeploy tool.

我想实现的是创建一个包的配置文件夹内,我们将所有的不同的配置文件为所有可能的环境(基本上将所有的配置转换文件)

What I want to achieve is to create a package with a Configuration folder inside which we will have all the different configuration files for all the possible environments (basically adding all config transform files)

我想实现自动部署,我们在那里的开发团队还没有得到任何访问该服务器在那里将要部署的企业环境。我们只需要交出部署包predefined指令如何安装包。

What I want to achieve is automatic deployment in our enterprise environment where development team hasn't got any access to the server where it is going to be deployed. We just need to hand over the deployment package with predefined instruction to how to install the package.

什么是你能想到的最好的办法。我们不使用TFS,不想自动构建过程依赖于任何过程,这样除了MSDeploy什么这是很容易更换。使用的MSBuild过的思考。

What's the best approach you can think of. WE ARE NOT USING TFS and don't want the automatic build process to be dependent on any process as such except MSDeploy or something which is easy to replace. Thinking of using MSBuild too.

推荐答案

您可以使用下面的解决方案实现它。在这期间,我的最好的书我读过的很长很长时间的一个得到了指导。书是里面的微软构建引擎写的赛义德·易卜拉欣·哈希米和威廉·巴塞洛缪。本书经过了详细的极佳方式。

You can achieve it using below solution. In between, I got the guidance from ONE OF THE BEST BOOK I HAVE READ IN LONG LONG TIME. Book is "Inside the Microsoft Build Engine" written by Sayed Ibrahim Hashimi and William Bartholomew. Book goes through the detail in excellent way.

创建的MSBuild凸出文件,如下所示

Create a msbuild proj file as shown below

<?xml version="1.0" encoding="utf-8"?>

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" DefaultTargets="TransformAll">

  <UsingTask TaskName="TransformXml"  AssemblyFile="$(MSBuildExtensionsPath)MicrosoftVisualStudiov10.0WebMicrosoft.Web.Publishing.Tasks.dll"/>

  <PropertyGroup>
    <DestDirectory>C:TempDeployPackageTRANSFORM_CONFIGS</DestDirectory>
  </PropertyGroup>

  <ItemGroup>
    <TransformFiles Include="$(FilesToTransform)"/>
  </ItemGroup>

  <Target Name="TransformAll" DependsOnTargets="ValidateSettings">
    <MakeDir Directories="$(DestDirectory)"/>
    <TransformXml Source="..web.config"
                  Transform="%(TransformFiles.Identity)"
                  Destination="@(TransformFiles->'$(DestDirectory)%(Filename).transformed.config')" />
  </Target>

  <Target Name="ValidateSettings">
    <Error Text="FilesToTransform cannot be empty"
           Condition=" '$(FilesToTransform)'=='' "/>
    <Error Text="Couldn't find transform file at [%(TransformFiles.Fullpath)]"
           Condition =" !Exists('%(TransformFiles.Fullpath)') "/>
  </Target>

</Project>

将上述PROJ文件并添加你的环境特定的文件夹中后,只需通过访问的MSBuild命令行运行以下

After adding the above proj file and adding your environment specific files in a folder, simply run the below through msbuild accessible command line

msbuild transform.proj /t:TransformAll /p:FilesToTransform="Lab.config;Test.config;Live.config"

希望这有助于。不要忘了买/参照内部格兰微软构建引擎一书。

Hope this helps. Don't forget to buy/refer "Inside teh Microsoft Build Engine" book.

阅读全文

相关推荐

最新文章