azure - 开发运营 : Build Solution task not copying Web. 配置文件

标签 azure azure-devops web-config web.config-transform

在我们的 DevOps 构建管道中,构建解决方案任务正确地将“web.base.config”文件转换为“web.config”文件,但是工件文件仅包含“web.base.config”而不包含“web.config”。

我们的 Visual Studio 项目文件/配置文件设置如下所示:

…
    <Content Include="Web.Base.config" />
    <None Include="Web.Debug.config">
      <DependentUpon>Web.Base.config</DependentUpon>
      <SubType>Designer</SubType>
    </None>
    <None Include="Web.Dev.config">
      <DependentUpon>Web.Base.config</DependentUpon>
      <SubType>Designer</SubType>
    </None>
    <None Include="Web.QA.config">
      <DependentUpon>Web.Base.config</DependentUpon>
      <SubType>Designer</SubType>
    </None>
…
  <Target Name="BeforeBuild" Condition="'$(PublishProfileName)' == '' And '$(WebPublishProfileFile)' == ''">
    <TransformXml Source="Web.Base.config" Transform="Web.$(Configuration).config" Destination="Web.config" />
  </Target>

构建解决方案任务的 msbuild 参数如下所示:

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"

在构建日志文件中,我可以看到转换成功进行。

2019-01-31T21:13:32.1186618Z BeforeBuild:
2019-01-31T21:13:32.1186784Z   Transforming Source File: Web.Base.config
2019-01-31T21:13:32.2198256Z     Applying Transform File: Web.Dev.config
2019-01-31T21:13:32.4750975Z     Output File: Web.config
2019-01-31T21:13:32.5213915Z   Transformation succeeded

我需要做什么才能将转换后的“Web.config”文件获取到工件暂存文件夹?

最佳答案

问题已解决 - Web.config 文件本身必须是 CSPROJ 文件的一部分,但事实并非如此。将其添加到项目文件后,我看到它已发布/推送到网站。我将它添加到 proj 文件中,如下所示:

...
<Content Include="Web.config" />
<Content Include="Web.Base.config" />
<None Include="Web.Debug.config">
  <DependentUpon>Web.Base.config</DependentUpon>
  <SubType>Designer</SubType>
</None>
...

关于azure - 开发运营 : Build Solution task not copying Web. 配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54469728/

相关文章:

c# - Azure DevOps 未在发布配置中构建

c# - Visual Studio 中开发人员特定的 app.config/web.config 文件

azure - Web Api 上传到 Azure 存储 - 请求实体太大

asp.net - 将 [requireSSL ="true"] 放入我的 web.config 返回垃圾页面

Azure DevOps VSTest@2 在测试 dll 中找不到任何测试

Azure blob GET 请求授权 header "x-ms-date"字段问题

asp.net - Web 部署到 Azure 不会强制 Web App 接受新的更改

asp.net - 如何在Azure中的Documentdb中编写和编译存储过程

Azure Devops - 生产部署的服务主体手动(或)服务主体自动?

tfs - NPM:仅安装丢失 - 如何加快 npm install