How do I exclude files and folders from the build in Visual Studio 2017?

Viewed 4515

In some older versions you could easily right click on the folders and exclude from build.

This function seems to be gone in VS 2017 Community. How do I achieve the same?

Update: it seems the function is not completely gone, it's possible to exclude files from the project when the Solution Explorer is not in folder view. This is not a solution anyway, since I need to exclude a whole folder that's got plenty of files, excluding them one by one is not at all a practical solution. It's something I can do in an emergency scenario, but not a reliable way of doing it.

3 Answers

Press right-click on the file you want to exclude, and click on properties. In General->Excluded from build, select Yes.

This answer may not be what you are looking for, but since "Publish Web App" is under the build tab, it fits and may help someone else.

In your "App_Data" folder there should be a "PublishProfiles" folder with a [projectname].pubxml file in it.

Add:

<ExcludeFoldersFromDeployment>
  foldername;otherfoldername
</ExcludeFoldersFromDeployment>

This will exclude listed folders from being published.

Expanding on that, for files:

<ExcludeFilesFromDeployment>
   gulpfile.js;PrecompiledApp.config
</ExcludeFilesFromDeployment>
Related