通过打开 .proj 文件并添加以下内容,我能够让它在我转换的项目中工作:
<ItemGroup>
<Content Include="Web.Staging.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</Content>
<Content Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</Content>
</ItemGroup>
然后我将现有的 web.config 两次复制到 web 根目录中并将它们重命名为 Web.Release.config 和 Web.Staging.config 在 VS 中我右键单击并将它们包含在项目中
然后我打开它们并添加
xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"
到配置节点,所以它看起来像:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
您必须具有匹配的 Release 和 Staging 配置名称(使用配置管理器)。在此 VS 将它们识别为 Web 配置转换文件之后