How to disable TDS file deployment in a Gulp task

How to disable TDS file deployment in a Gulp task

If you are using a Helix-based solution with TDS for serialization and have the TDS file deployment enabled, every time you run a Gulp task for building and publishing the solution, TDS will deploy files and items in the process. How do you disable that?

By default, Habitat uses Unicorn for Sitecore item serialization. You have the option to use TDS, though. TDS stands for Team Development for Sitecore and is a product maintained by the Hedgehog company. This same company gives you an alternative to use Habitat with TDS. You may find it at the Hedgehog GitHub repository .

Habitat uses a NodeJS module named Gulp . Gulp is a toolkit for automating tasks in your development workflow such as bundling and minifying libraries and stylesheets, refreshing your browser when you save a file, running unit tests, copying modified files to an output directory, and etc.

One of the automated tasks that Habitat uses is the build and publishing of the Habitat solution. How does it work? Gulp uses another NodeJS module named ms-build which basically interacts with the Microsoft Build Engine (MSBuild).aspx) . MSBuild is the build platform for Microsoft and Visual Studio. In other words, when you do a build in your Visual Studio, MSBuild Engine comes into action and do all the magic for you. Both build and publishing processes rely on MSBuild Engine.

TDS offers you a feature for file deployment, which can be found in the properties of the TDS project. Essentially, it deploys files to the directory specified in the Sitecore Deploy Folder property. It is useful for both development and deployment stages. The build in Visual Studio triggers the TDS file deployment feature. The same happens when you run a Gulp task that uses the ms-build module.

You might have a scenario where you do not want TDS to do the file deployment when you run a Gulp task, but you do not want to disable the TDS file deployment feature. How is that possible?

There are two arguments that you can pass to MSBuild command line that stops TDS deploying files and Sitecore items. These arguments are SitecoreWebUrl and SitecoreDeployFolder. These arguments expect the URL and Folder of the target Sitecore installation you want to deploy you solution. TDS will NOT deploy it if you explicitly leave these arguments blank.

The ms-build module has a property named “properties” where you can pass additional parameters for the MSBuild Engine. You can use this property to pass the SitecoreWebUrl and SitecoreDeployFolder parameters.

Solution

gulp.task("Build-Solution", function () {

  var targets = ["Build"];
  if (config.runCleanBuilds) {
    targets = ["Clean", "Build"];
  }

  var solution = "./" + config.solutionName + ".sln";
  return gulp.src(solution)
      .pipe(msbuild({
          targets: targets,
          configuration: config.buildConfiguration,
          logCommand: false,
          verbosity: config.buildVerbosity,
          stdout: true,
          errorOnFail: true,
          maxcpucount: config.buildMaxCpuCount,
          nodeReuse: false,
          toolsVersion: config.buildToolsVersion,
          properties: {
            Platform: config.buildPlatform,
            SitecoreWebUrl: "",
            SitecoreDeployFolder: ""
          }
        }));
});

With the code above, you stop TDS doing the deployment when you run a gulp task for building and publishing your solution.

comments powered by Disqus

Read more