我在 Visual Studio 2013 ASP.NET Web API 2 项目中有以下设置。
- Web.Develop.config Web 转换以设置应用程序设置键值
- Web.Release.config Web 转换以删除应用设置键
- Develop.pubxml 映射到 Web.Develop.config 转换
- Release.pubxml 映射到 Web.Release.config 转换
每个细节都在下面找到。
<!-- Web.Develop.config (Web Config Transform) -->
<appSettings>
<add key="ReportInputPath"
value="DevelopPath"
xdt:Transform="SetAttributes"
xdt:Locator="Match(key)" />
</appSettings>
<!-- Web.Release.config (Web Config Transform) -->
<appSettings xdt:Transform="Remove" />
<!-- **Develop.pubxml (Publish Profile) -->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>x64</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>True</ExcludeApp_Data>
<publishUrl>Path</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles
<ExcludeFilesFromDeployment>packages.config</ExcludeFilesFromDeployment>
</PropertyGroup>
</Project>
<!-- Release.pubxml (Publish Profile) -->
<!-- Contents are identical to Develop.pubxml.
This is used to target the Web.Release.Config transform. -->
每当我通过发布发布配置文件发布应用程序时,我的<appSettings/>
元素都会成功删除。但是,<appSettings/>
当开发发布配置文件也运行时,元素也会被删除。
我想了解的是:
为什么<appSettings/>
在我运行开发发布配置文件而不是设置 ReportInputPath 值时会删除元素?
解决方案/项目配置、发布配置文件和 web.config 转换之间的关系是什么?