Exclude files from website deployment using msbuild

I have a website project that I am deploying with msbuild. There are several files and folders in the project that are necessary for the assembly (for example, replacement files for the web.config part), but I do not want to deploy them to the target site.

The best I could think of is a post build that deletes these files, but I would like to know if there is a way to prevent these files from being copied to the output folder.

+5
source share
5 answers

You can select files and set their "Build Action" to "ExcludeFromPackageFiles". Thus, the visual studio will edit csproj xml and you won’t have to.

+8
source

Hi, this blog post , it saved my day,

I tried to exclude an underdeveloped version of javascripts and use only the published shortened version (I remove large javascripts and chirp.config), which are only needed for debugging.

just put this in the project file as indicated in the link.

<ItemGroup>
    <ExcludeFromPackageFolders Include="Scripts\large">
      <FromTarget>Project</FromTarget>
    </ExcludeFromPackageFolders> 


    <ExcludeFromPackageFiles Include="Scripts\mash.js.chirp.config" />  
    <ExcludeFromPackageFiles Include="Content\mash.js.chirp.config" />
  </ItemGroup>

A published site will not include the following:

  • Scripts \ large
  • mash.js.chirp.config
+4
source

" " "

enter image description here

+3

MSDeploy - Pipeline, , . - , , , App_Data

<Target Name="ExcludeApp_Data" DependsOnTarget="$(ExcludeApp_DataDependsOn)" Condition="$(ExcludeApp_Data)" > 
  <ItemGroup>
    <ExcludeFromPackageFolders Include="App_Data">
      <FromTarget>ExcludeApp_Data</FromTarget>
    </ExcludeFromPackageFolders>
  </ItemGroup>
</Target>

- . proj - Package/Publish. , .

, \jquery , ExcludeScriptFiles.wpp.targets,

<ItemGroup> 
  <ExcludeFromPackageFolders Include="Internal">
    <FromTarget>ExcludeScriptFiles.wpp.targets</FromTarget>         
  </ExcludeFromPackageFolders>
  <ExcludeFromPackageFiles Include="Scripts\jquery.js;xyz.js">
    <FromTarget>ExcludeScriptFiles.wpp.targets </FromTarget> 
  </ExcludeFromPackageFiles>
</ItemGroup>

, .

,

+2

I am using Visual Studio 2012 with Jenkins, and the only work that worked for me changed "Build Action" to "None:"

enter image description here

Internally, it sets the XML tag in the PROJECT.csproj file from "Content" to "No:"

<None Include="form.coffee" />

I closed the project and then manually edited the file using another editor to exclude all my coffee files in bulk.

(All my coffee files are still transcribed in js files.)

0
source

All Articles