[英]MS Visual Studio: How to exclude certain Project Folders from publishing?
我有某些文件夾,我想保留在項目中,但不想將其包含在發布中。
那可能嗎?
Michael是完全正確的,通過編輯 .csproj 文件,您可以手動排除文件/文件夾的發布。
如果您不想弄亂 .csproj 文件,一種更簡單的方法是在 VS 解決方案資源管理器中突出顯示文件。 在屬性面板下,將 build to action 從“content”更改為“none”。
這樣,您不必從解決方案中卸載項目,加載 .csproj 並為您添加的每個新文件添加一行,該文件不需要發布,而是通過 3 次鼠標單擊實現相同的效果。
(假設您在發布選項卡下設置了“僅發布運行此應用程序所需的文件”)
如果它是一個網站項目,您可以排除某些文件夾和/或文件,如下所示(請參閱元素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>
您可以在 Web.cspoj 文件中執行“查找和替換”,以快速從發布/部署過程中刪除特定文件夾
像這樣;
<Content Include="Uploads/
至
<None Include="Uploads/
您可以做的另一種方法是您可以隱藏 windows 資源管理器中不需要發布的文件夾(不是最佳解決方案,但如果您有大量圖像仍需要在開發框中,則可以使用)。
<ItemGroup> <Content Update="Data\CernainFolder\*.*"> <CopyToPublishDirectory>Never</CopyToPublishDirectory> </Content> </ItemGroup>
這應該很好用
由於問題是用 ASP 標記的,因此沒有.proj
文件可以處理。 在 VS2015 中,還有另一個有用的文件: website.publishproj
。 而這篇關於排除文件和文件夾的 Asp.Net 文章提到了.wpp.targets
文件。
所有這些文件都包含<ItemGroup>
元素,其中可能包含<ExcludeFromPackageFolders>
等元素。 由於這些似乎記錄在案的功能,只需使用它們,不要因為黑客或“搞砸”而感到內疚。 對我來說,使用該鏈接的簡單說明排除目錄和website.publishproj
文件就像一個魅力!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.