source

MS Visual Studio: How to exclude certain Project Folders from publishing?

nicesource 2023. 7. 13. 20:55
반응형

MS Visual Studio: How to exclude certain Project Folders from publishing?

I have certain folders which I want to keep in the project but not to include it in publishing.

Is that possible?

If it is a web-site project, you may exclude certain folders and/or files as follows (see elements ExcludeFoldersFromDeployment and 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 is totally right, through editing the .csproj file you can manually exclude files/folder from being published.

One easier way if you don't want to mess with the .csproj file is to highlight the file(s) inside the VS solution explorer. Under the properties panel, change build to action from 'content' to 'none'.

This way you don't have to unload the project from the solution, load the .csproj and add a line for each new file you add that doesn't need to be published but instead achieve the same with 3 mouse-clicks.

(assuming you've set the 'Only publish files needed to run this application' under the publishing tab)

You can do a 'Find & Replace' in the Web.cspoj file to quickly eliminate a particular folder from the publish/deployment process

Like so;

<Content Include="Uploads/

to

<None Include="Uploads/
  • Unload Project,
  • Right click Edit *.csproj,
  • Add this:
<ItemGroup>
<Content Update="Data\CernainFolder\*.*">
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</Content>
</ItemGroup>
  • Reload Project.

This should work nicely

Another way you can do is you can hide folders in windows explorer that are not needed to be get published(not the best solution but works if you have large set of images that still need to be in development box).

질문에 ASP 태그가 지정되어 있으므로 해당 항목이 없습니다..proj난도질할 파일VS2015에는 다음과 같은 유용한 파일이 있습니다.website.publishproj그리고 이 아스프.파일폴더 제외에 대한기사는 다음을 언급합니다..wpp.targets파일.

이 모든 파일은 다음을 포함합니다.<ItemGroup>다음과 같은 요소를 가질 수 있는 요소.<ExcludeFromPackageFolders>이러한 기능은 문서화된 것처럼 보이므로, 해킹이나 '메싱'에 대해 죄책감을 느끼지 말고 사용하십시오.저의 경우, 해당 링크의 간단한 지침을 사용하여 디렉토리를 제외하고website.publishproj파일이 매력적으로 작동했습니다!

ReferenceURL : https://stackoverflow.com/questions/6104818/ms-visual-studio-how-to-exclude-certain-project-folders-from-publishing

반응형