在我们的 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/