请参考以下步骤:
第 1 步:创建 Asp.net Web 应用程序(名称:SalesDemo)
步骤 2.1:创建嵌套配置(例如 web.SalesDemoQA.config、web.SalesDemoStag.config、web.SalesDemoProd.config),复制到输出目录:始终)
Sept 2. 2 在文本编辑器中打开您的 csproj 文件并检查以下内容
<None Include="web.SalesDemoQA.config">
<DependentUpon>web.config</DependentUpon>
</None>
把上面的代码改成下面的代码
<Content Include="web.SalesDemoQA.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content >
步骤 2.3 web.SalesDemoQA.config 中的示例代码
<connectionStrings>
<add name="SalesDemo" connectionString="Data Source=ReleaseSQLServer;Initial Catalog=SalesDemoDBQA;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
第 3 步:登录 Azure DevOPS 站点
第 4 步:创建构建管道
步骤 4.1:选择存储库
步骤 4.2:选择模板(Asp.net 模板)
9 月 4.3 日msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:TransformWebConfigEnabled=False /p:AutoParameterizationWebConfigConnectionStrings=False /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
注意:我在 msBuildArgs 中添加了以下附加参数
/p:TransformWebConfigEnabled=False /p:AutoParameterizationWebConfigConnectionStrings=False
步骤 4.4:发布构建工件
第 5 步创建发布管道
步骤 5.1:创建阶段名称:(SalesDemoQA)
步骤 5.2:创建 IIS Web App 管理任务
步骤 5.3:创建 IIS Web App 部署任务
步骤5.4:设置(包或文件夹:$(System.DefaultWorkingDirectory)/_SalesDemo/drop/SalesDemo.zip;
第 5.5 步:检查 XML 转换选项
假设 web.SalesDemoQA.config 文件将转换为 web.config 文件。
注意:阶段名称与配置名称匹配(www.salesDemo.config)