Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 655
Oppa Gingham Style Avatar asked Oct 31 '14 21:10

Oppa Gingham Style


People also ask

How do I publish my website in Visual Studio?

On the computer where you have the ASP.NET project open in Visual Studio, right-click the project in Solution Explorer, and choose Publish. If you have previously configured any publishing profiles, the Publish pane appears. Click New or Create new profile. Select the option to import a profile.

How do I publish a Visual Studio solution from the command line?

Basic command-line publishing The default publish folder format is bin\Debug\{TARGET FRAMEWORK MONIKER}\publish\. For example, bin\Debug\netcoreapp2. 2\publish\. The dotnet publish command calls MSBuild, which invokes the Publish target.


1 Answers

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>

'''                '''' 
like image 103
qakmak Avatar answered Nov 25 '22 21:11

qakmak