在Visual Studio 2015 ASP.NET MVC项目中,我使用“文件系统”发布方法进行项目发布。另外,我想在发布过程中包含自定义JSON配置文件(settings_dev.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文件。