ExcludeFilesFromDeployment not working in Visual Studio 2013 Publish Web
Asked Answered
G

2

5

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?

Gamelan answered 31/10, 2014 at 21:51 Comment(0)
K
8

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>

'''                '''' 
Klug answered 8/2, 2015 at 12:0 Comment(2)
Finally had a chance to test. Worked with bin\Library-that-is-not-good-for-server.dll when referring to the library in the bin directory off the root of the site.Gamelan
It's not obvious that you need to do bin\some.dll, but otherwise it won't workStonyhearted
G
0

You probably need to have the following definition also in the 'profileName'.pubxml file:

<DeleteExistingFiles>False</DeleteExistingFiles>

Please remove all files from your Temp publish location(normally obj\Release\Package\PackageTmp) after excluding some files or directories.

Gwenni answered 29/5, 2015 at 7:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.