默认情况下,使用MSBuild / Visual Studio发布Web项目时,将应用配置转换。
我想在输出中包括配置转换。
输入
web.config
web.Debug.config
web.Release.config
默认输出
web.config
所需的输出
web.config
web.Debug.config
web.Release.config
在Web Deploy输出中包括web.release.config
默认情况下,发布网站时,VS不会打包web.debug.config
和web.release.config
,而只打包web.config
。
要实现所需的功能,可以在publishprofile.pubxml
中添加自定义目标以包括这些额外的文件。
请尝试这个:
<Target Name="CustomCollectFiles">
<ItemGroup>
<AdditionFiles Include="xxxxxxxxxxx\Web.Debug.config;xxxxxxxxx\WebApplication25\Web.Release.config">
</AdditionFiles>
<FilesForPackagingFromProject Include="%(AdditionFiles.Identity)">
<DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForMsdeployDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
然后完成发布步骤后,您将在发布文件夹中找到这些文件。
希望它可以帮助您。