开发者

WebConfig Replacement CruiseControl.Net

I have to deploy my solutions in many environnement (dev,staging,..)

2 Options: replace the whole file of just sections. Solution on either of them would be appreciated

I made 4 differents files: appSettings.Staging.config, appSettings.Dev.config, connectStrings.Dev.config, connectStrings.Staging.config.

I want to replace those section in the web.config during deplo开发者_如何学JAVAyment.

My msBuild Section looks like this

  <msbuild>
    <executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
    <workingDirectory>C:\Travail\erp.visual.webapp.erpportal</workingDirectory>
    <projectFile>erp.visual.webapp.erpportal.sln</projectFile>
    <buildArgs>/p:ProjectFile=$SolutionFile$ /t:TransformWebConfig /p:Configuration=Staging</buildArgs>
    <targets>Build</targets>
    <timeout>900</timeout>
    <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
  </msbuild>

How can i retrieve the "/p:Configuration=Staging" argument ? i try the folowing

    <ItemGroup Condition=" '$(Configuration)' == 'Staging' ">

      <WebConfigReplacementFiles Include="appSettings.Staging.config">
      <Section>appSettings</Section>  
      </WebConfigReplacementFiles>

      <WebConfigReplacementFiles Include="connectionStrings.Staging.config">
        <Section>connectionStrings</Section>
      </WebConfigReplacementFiles>

    </ItemGroup>          

But where do I place this section into the ccnet.config ?


Found a way to do this. i have a web.config per environnement. web.staging.config, web.test.config. web.uat.config and so on

In my ccnet.config file

  <nant>
    <executable>C:\nant\bin\nant.exe</executable>
    <baseDirectory>C:\Travail\erp.visual.webapp.erpportal</baseDirectory>
    <nologo>false</nologo>
    <buildFile>C:\Program Files\CruiseControl.NET\server\build.xml</buildFile>
    <targetList>
     <target>buildAll</target>
    </targetList>
    <buildTimeoutSeconds>60000</buildTimeoutSeconds>
  </nant>

In my build.xml file i use the copy file tag from Nant in a target tag

<copy file="${root.dir}\erp.visual.webapp.erpportal\web.staging.config"
      tofile="${deploy.web.dir}\Web.config" 
      overwrite="true"
      inputencoding="latin1"
      outputencoding="utf-8">
</copy>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜