I'm trying to set up a gulp task for publishing, similar to the Habitat model and the Sitecore development book. One suggestion people have had is to exclude things like the Sitecore DLLs, Coveo DLLs, etc, that aren't needed to be included in a deployment. I've been able to set this up in a publish profile, where it looks like this:


In the gulp task properties, I was able to add the ExcludeFilesFromDeployment property to the properties node, but it doesn't seem to recognize/accept it. Also, if I use the semicolon-delimited list, it throws an error. I'd like to add this in at the task level, rather than have a publish profile in every project...using a property to tell the task to use a profile works, if the excluded files are specified there, but that's a lot of extra overhead.

  • If you just set Copy Local property to false for desired dlls in References of your project? This is solving all these kind of problems for me – Peter Procházka Apr 27 '18 at 22:02
  • Yes, but the goal is to make it so that devs don't need to remember to do that each time, the publishing task takes care of it. It might come down to just taking the set of publish profiles from one project and copying them into a new project, and the publish task in gulp can specify a publish profile. I was trying to wrap it all in gulp to make it easier. – Ken McAndrew Apr 28 '18 at 0:15
  • also, removing copy local had negative impact on developer time experience with intellisense in the past. We generally want to rely on publishing to remove any unneeded artifacts and avoid any clobbering. – Roman Oct 29 '18 at 20:30

I was able to exclude the Sitecore DLLs from the Deployment when adding ExcludeFilesFromDeployment: 'bin\\Sitecore.*.dll' to my properties object used in gulp-msbuild. The same is probably possible using ExcludeFoldersFromDeployment.

I could not exclude multiple files with the proposed semicolon notation. But when using MSBuild directly in command line, adding a compile switch like this worked for me: /p:ExcludeFilesFromDeployment:"bin\Sitecore.Kernel.dll; bin\Sitecore.Logging.dll".

Maybe someone else is able to clarify the last part.

  • This does seem to work for me. Thanks! Adding: overrideParams.push('/p:ExcludeFilesFromDeployment=bin\\Sitecore.*.dll'); – MikeD Jan 25 at 21:57

I have tried to achieve the same in the past. Even after several Google searches and personal attempts, I couldn't find anything to exclude files from deployment. The Gulp task is trying to pass the ExcludeFileFromDeployment as parameter to the msbuild.exe. I'm afraid the msbuild.exe doesn't recognize any parameter named ExcludeFileFromDeployment.

To work this around, I created a task for deleting files after publishing them. e.g.

var del = require('del');

[...] code here [...]

gulp.task("03-Clean-Transform-Files", function () {

  var removableBuildConfiguration = "";
  if(config.buildConfiguration == "Release") {
      removableBuildConfiguration = ".Debug.deploytransform";
  } else if(config.buildConfiguration == "Debug") {
      removableBuildConfiguration = ".Release.deploytransform";

  return del([config.websiteRoot + '\\*\\*' + removableBuildConfiguration, 
              config.websiteRoot + '\\*' + removableBuildConfiguration], {force: true}).then(paths => {
    util.log('Deleted files and folders:\n', paths.join('\n'));


My Gulp script is going to delete every file that matches the pattern *.Debug.deploytransform or *.Release.deploytransform in the name.

  • 1
    This is good for your specific case, but in this case the DLLs I want to exclude can't be deleted after the fact. They already exist in the base Sitecore site, and this seems like it'd delete them from the destination, no? – Ken McAndrew Apr 28 '18 at 0:16
  • Indeed. It doesn't apply for your case. Perhaps another solution would be deploying to an intermediate repository, having the dlls deleted and them copying the rest to the final repository. Altough, I think it is too overkill and perhaps not worth it. – João Neto Apr 29 '18 at 10:18
  • I'm thinking so as well. End of the day, it only becomes a problem if someone's NuGet calls are out-of-sync or if there's a patched version of a Sitecore NuGet assembly that you don't want to override. – Ken McAndrew Apr 30 '18 at 13:33

You could try using this to exclude these files in Gulp

gulp.task("CI-Prepare-Package-Files, function (callback) {
    var excludeList = [
      config.websiteRoot + "\\bin\\{Sitecore,Lucene,Newtonsoft,System,Microsoft.Web.Infrastructure}*dll",
      config.websiteRoot + "\\compilerconfig.json.defaults",
      config.websiteRoot + "\\packages.config",
      config.websiteRoot + "\\App_Config\\Include\\{Feature,Foundation,Project}\\*Serialization.config",
      config.websiteRoot + "\\App_Config\\Include\\{Feature,Foundation,Project}\\z.*DevSettings.config",
      "!" + config.websiteRoot + "\\bin\\Sitecore.Support*dll",
      "!" + config.websiteRoot + "\\bin\\Sitecore.{Feature,Foundation,Habitat,Demo,Common}*dll"

    return gulp.src(excludeList, { read: false }).pipe(rimraf({ force: true }));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.