我有一些文件夹希望保留在项目中,但不想将其包含在发布版本中。
这是否可行?
我有一些文件夹希望保留在项目中,但不想将其包含在发布版本中。
这是否可行?
如果是网站项目,您可以按照以下方式排除某些文件夹和/或文件(请参见元素ExcludeFoldersFromDeployment和ExcludeFilesFromDeployment):
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>True</ExcludeApp_Data>
<publishUrl>D:\YAZILIM\Adopen.2015\PreCompiledWeb</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>True</EnableUpdateable>
<DebugSymbols>False</DebugSymbols>
<WDPMergeOption>MergeAllOutputsToASingleAssembly</WDPMergeOption>
<UseMerge>True</UseMerge>
<SingleAssemblyName>AdoIntranet</SingleAssemblyName>
<ExcludeFoldersFromDeployment>customobjects;uploads</ExcludeFoldersFromDeployment>
<ExcludeFilesFromDeployment>app.config</ExcludeFilesFromDeployment>
</PropertyGroup>
</Project>
Michael是完全正确的,通过编辑.csproj文件,您可以手动排除要发布的文件/文件夹。
如果您不想修改.csproj文件,一种更简单的方法是在VS解决方案资源管理器中选择文件,然后在属性面板中将生成操作从“内容”更改为“无”。
这样,您就不必卸载解决方案中的项目,加载.csproj并为每个新添加的不需要发布的文件添加一行,而是可以通过3次鼠标点击来实现相同的效果。
(假设您已在发布选项卡下设置了“仅发布运行此应用程序所需的文件”)
<Content Include="Uploads/
到
<None Include="Uploads/
<ItemGroup>
<Content Update="Data\CernainFolder\*.*">
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</Content>
</ItemGroup>
这应该可以很好地工作。
另一种方法是隐藏在Windows资源管理器中不需要发布的文件夹(虽然不是最佳解决方案,但如果您有大量仍需在开发环境中使用的图片,则此方法可行)。
.proj
文件。使用VS2015,有另一个有用的文件:website.publishproj
。这篇关于排除文件和文件夹的Asp.Net文章提到了.wpp.targets
文件。<ItemGroup>
元素,可能会有像<ExcludeFromPackageFolders>
的元素。由于这些似乎是有文档记录的功能,所以只需使用它们,不必感到有负罪感的黑客或“搅拌”。对我来说,使用该链接的简单说明和website.publishproj
文件排除一个目录就可以完美解决问题!