且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过Bamboo根据环境动态更改.Net应用程序中的配置文件

更新时间:2022-12-05 20:49:29

我想这会起作用:

  1. 在解决方案的某些目录中以Config.ConfigurationName.xml格式创建少量配置文件,例如Config. DEV .xml,Config.测试 .xml. .
  2. 添加PreBuild事件(通过csproj属性窗口或在csproj文件中手动添加),例如:<PropertyGroup><PreBuildEvent>xcopy /y (ProjectDir)\Configs\Config.$(Configuration).xml $(ProjectDir)\CONFIG\Config.xml</PreBuildEvent></PropertyGroup> 或在VS rigth中单击项目->属性:
  3. 在VS中的Configuration Manager中为不同的配置添加一些配置,例如. DEV,测试. 我的项目配置:
  1. Create few configuration files in some directory in the solution in the format Config.ConfigurationName.xml, eg Config.DEV.xml, Config.Test.xml...
  2. Add PreBuild event (by the csproj properties window or manually in the csproj file), for example: <PropertyGroup><PreBuildEvent>xcopy /y (ProjectDir)\Configs\Config.$(Configuration).xml $(ProjectDir)\CONFIG\Config.xml</PreBuildEvent></PropertyGroup> or in VS rigth click on the project -> Properties:
  3. Add few configurations in VS in Configuration Manager for different configuration eg. DEV, Test. My project configuration:

  1. 在Bamboo msbuild中使用以下参数执行:/p:SolutionConfiguration=%CONFIGURATION%其中%CONFIGURATION%是Bamboo中的变量,其中说明了您要部署在哪个ENV上,例如 DEV,Test 等.
  1. Execute in the Bamboo msbuild with arguments: /p:SolutionConfiguration=%CONFIGURATION% where %CONFIGURATION% is a variable in Bamboo saying on which ENV you are deploying, eg DEV, Test etc.