Search code examples
visual-studio-2013msdeploywebdeploy

ExcludeFilesFromDeployment not working in Visual Studio 2013 Publish Web


I have a fairly straightforward MVC 5 project in Visual Studio 2013. I have successfully set up publishing via Web Deploy to the server. I want to exclude a certain file from deployment without having to preview/uncheck it every time I publish (I am publishing the Release build).

I have edited the .csproj file for the project to include the <ExcludeFilesFromDeployment> tag.

<Project...>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    ...
    <ExcludeFilesFromDeployment>Library-that-is-not-good-for-server.dll</ExcludeFilesFromDeployment>
  </PropertyGroup>

But nothing changes/the file still needs to be unchecked for addition when I go to publish in VS2013.

I have also tried adding a bin\ in front of the library, just in case. Not to mention, a warning pops up for the element that says "The element 'PropertyGroup' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003' has invalid child element 'ExcludeFilesFromDeployment' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003'. ..."

Microsoft's documentation that I was able to find in searches regarding excluding files from deployment, and the ExcludeFilesFromDeployment tag, http://msdn.microsoft.com/en-us/library/ee942158(v=vs.110).aspx, claim that the instructions only apply to VS2012 and partially to VS2010. Does anyone know what has changed for VS2013 or what I am doing wrong?


Solution

  • You need to add it in the profileName.pubxml file. profileName.pubxml file position is:

    my project ----> Properties ----> PublishProfiles ---> profileName.pubxml
    

    Example:

    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <ExcludeFilesFromDeployment>
        Library-that-is-not-good-for-server.dll
      </ExcludeFilesFromDeployment>
    
    '''                ''''