Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude folders from publish/deployment of Visual Studio 2013 Web Application

I'm publishing a Web Application from Visual Studio 2013. I need include folders that are not a part of the project, and exclude some folders (some apart of the project, some not apart of the project). So I went into my project's properties and set Items To Deploy field to All files in this project folder as you can see below:

enter image description here

Then I began looking for a way to exclude folders from All files in this project folder. I found this page, which specifically states

The Visual Studio UI does not expose all of the deployment settings that you can configure. For example, you can't use the UI to exclude an individual folder from deployment. However, you can do this by editing the files that store configuration settings. For each publish profile there is a .pubxml file that you can edit directly.

This page links to another that explains how to edit the file, but doesn't explain how to exclude specific folders.

I found other sites (this one included) that explained how to exclude folders in older versions of Visual Studio using the following tag in the csproj file:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> 
  ... 
  <ExcludeFilesFromDeployment>File1.aspx;File2.aspx</ExcludeFilesFromDeployment> 
  <ExcludeFoldersFromDeployment>Folder1;Folder2</ExcludeFoldersFromDeployment> 
</PropertyGroup>

But it appears the XML elements for the csproj file are no longer relevant in VS2013. I read somewhere (can't remember where now) a suggestion that this element had been moved to the [PublishProfileName].pubxml file, but trying this failed to work.

I'm sure that there is a way to do this in Visual Studio 2013, but for the life of me, I can't figure out how. I've found dozen of related question here on Stackoverflow, as well as other forums, but none of the solutions work for me in VS2013. Any help is much appreciated.

like image 771
Trevor Avatar asked Sep 14 '15 16:09

Trevor


1 Answers

These elements have indeed been moved to the .pubxml file in Visual Studio 2012 and later. Here's the relevant documentation in MSDN about excluding files and folders from deployment.

Locate the relevant .pubxml file under Properties / Publish Profiles in the Visual Studio Solution Explorer, and add a new element ExcludeFilesFromDeployment or ExcludeFoldersFromDeployment under the PropertyGroup element listing the files or folders to be excluded, delimited by a semi-colon.

I note these elements didn't appear as options in the IntelliSense selection when I typed them into Visual Studio 2015 - but the project compiled and the exclusion still worked.

like image 97
John Trenwith Avatar answered Sep 27 '22 20:09

John Trenwith