Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude files from web site deployment with msbuild

I have a web site project that I deploy using msbuild. In the project there are some files and folders that are needed for the build (e.g. the web.config part replacement files) but that I don't want to deploy to the target site.

The best I could think of is a post-build target that removes these files, but I'd like to know if there is a way to have these files not copied to the output folder.

like image 755
Paolo Tedesco Avatar asked Jun 15 '11 13:06

Paolo Tedesco


People also ask

How do you exclude files from a build?

You can exclude a file from a build configuration without needing to change the code. Right-click on the file in the Project Explorer pane. Select "Resource Configurations" and "Exclude from build" and select the Release build.

How do I exclude files from Visual Studio Project?

In Visual Studio, right-click on the file to be excluded from build, choose Properties, Configuration Properties -> General -> Excluded From Build -> Yes -> OK. In Eclipse, right-click on the file to be excluded from build, choose Properties, C/C++ Build -> Excluded from build -> OK.

How do I ignore a folder in Visual Studio?

You can use Visual Studio to exclude a file from a solution by context-clicking the file in Solution Explorer and selecting Exclude from Project in the context menu.


1 Answers

Hi Check this blog post out it saved my day,

I was trying to exclude the un-minified version of the javascripts, and use only the minified version when published (I'm removing large javascripts and chirp.config) its only needed for debug.

just put this on the Project file as stated on 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>

The published site will not include the following:

  • Scripts\large
  • mash.js.chirp.config
like image 52
bherto39 Avatar answered Oct 05 '22 05:10

bherto39