在 Visual Studio 2015 ASP.NET MVC 项目中,我使用“文件系统”发布方法进行项目发布。此外,我想在发布过程中包含自定义 JSON 配置文件(settings_dev.conf)。默认情况下,此文件不发布到文件系统。
- 是否可以在发布配置文件配置中包含单个文件?
- 是否可以更改已发布文件的名称?从“settings_dev.conf”到“settings.conf”。
以下是我尝试过的配置。
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Dev</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<DeleteExistingFiles>False</DeleteExistingFiles>
<CopyAllFilesToSingleFolderForPackageDependsOn>
Settings;
<!--$(CopyAllFilesToSingleFolderForPackageDependsOn);-->
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="Settings">
<ItemGroup>
<_CustomFiles Include="$(MSBuildProjectDirectory)\settings_dev.conf" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>%(RecursiveDir)settings.conf</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
</Project>
使用此配置,所有文件都会被发布。我有其他用于不同环境的 settings.conf 文件。