Resolving Microsoft.Web.Publishing.Tasks.dll. Could not load file or assembly

One of the challenges of working at an agency like SidLee, as opposed to working for a product company, or long-project duration consultancy as I am used to, is the sheer number of projects I may find myself working on at one time.  An average week involves working on two or three different projects, all with a deep degree of complexity.  This setup leads one to run into many issues in the various idiosyncrasies in Visual Studio solution setup.

I am trying to run the project's gulp build/deploy script, and it errors out near the end at the publishing section.  This is odd, because the publish works perfectly fine from withing Visual Studio.  The error I encounter is:


[17:11:19] Applying configuration transform: C:\projects\sidlee.com\src\Foundation\SitecoreExtensions\code\web.config.xdt
C:\projects\sidlee.com\scripts\applytransform.targets(14,5): error MSB4062: The "TransformXml" task could not be loaded from the assembly C:\Program Files (x86)\Microso
ft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.Tasks.dll. Could not load file or assembly 'file:///C:\Program Files
(x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.Tasks.dll' or one of its dependencies. The system cannot
 find the file specified. Confirm that the  declaration is correct, that the assembly and all its dependencies are available, and that the task contains a pu
blic class that implements Microsoft.Build.Framework.ITask.
[17:11:19] MSBuild failed with code 1!

This appears to be a version mismatch between my version of Visual Studio 2017, and whichever was used by project team.  Since I am not able to find any reference in any .csproj file to this reference to Microsoft.Web.Publishing.Tasks.dll, nor in any gulp.js files, I need to figure out a solution.  I go with a more unorthodox approach, and simply copy the directory

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\Web

to

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0

MSBuild doesn't seem to mind and the local gulp build succeeds.  I wish I could find a more non-standard solution, but this works for now.

Comments