4

I bought the Professional Sitecore 8 Development book and I am following the Sitecore Helix architecture approach. And following the examples in the book and online I am using Gulp in the Task Runner Explorer window to build and deploy the solution. Often times when I run the "Publish-Site" Gulp task I see error codes in red that say MSBuild failed with code 1. I have no idea what that means or how to troubleshoot it. Can anyone help me understand what that message means and how to troubleshoot it?

Here is a screen shot:

enter image description here

Here is the code from my gulpfile.js

var gulp = require("gulp");
var msbuild = require("gulp-msbuild");
var debug = require("gulp-debug");
var foreach = require("gulp-foreach");
var gulpConfig = require("./gulp-config.js")();

module.exports.config = gulpConfig;

gulp.task("Publish-Site", function () {
    return gulp.src("./{Feature,Foundation,Project}/**/**/*.csproj")
    .pipe(foreach(function (stream, file) {
        return stream
        .pipe(debug({ title: "Publishing" }))
        .pipe(msbuild({
            targets: ["Build"],
            gulpConfiguration: gulpConfig.buildConfiguration,
            properties: {
                publishUrl: gulpConfig.webRoot,
                DeployDefaultTarget: "WebPublish",
                WebPublishMethod: "FileSystem",
                DeployOnBuild: "true",
                DeleteExistingFiles: "false",
                _FindDependencies: "false"
            }
        }));
    }));
});

EDIT: I also noticed that when I do a rebuild of the entire solution that I get a few warnings about versions of System.Web.Mvc. Below is the text of the warning in Visual Studio:

8> No way to resolve conflict between "System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Choosing "System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" arbitrarily. 8> Consider app.config remapping of assembly "System.Web.Mvc, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "3.0.0.0" [] to Version "5.2.3.0" [C:\Projects\SitecoreDev\Foundation\Ioc\SitecoreDev.Foundation.Ioc\bin\System.Web.Mvc.dll] to solve conflict and get rid of warning. 8>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: 8> SitecoreDev.Foundation.Repository -> C:\Projects\SitecoreDev\Foundation\Repository\SitecoreDev.Foundation.Repository\bin\SitecoreDev.Foundation.Repository.dll

I believe that what this is telling me is that I need to add some assembly binding redirection to the web.config of the SitecoreDev.Foundation.Repository project to resolve this. However I am not completely sure how to accomplish this in the Helix architecture. If I understand correctly I don't want to have a web.config file in any of my projects. If I do then it will overwrite the Sitecore web.config file when it copies files from the dev root to the web root. Right? So I'm not sure how to fix problems like this in a particular project in my solution.

  • Which version of Visual Studio are you using? – Mark Cassidy Apr 12 '17 at 12:47
  • Visual Studio 2015 – Corey Burnett Apr 12 '17 at 12:48
  • Does it compile ok in VS? I sometimes get this when I forget to save a file before building. When you build in VS, it auto saves all the files, but running the gulp task does not do this, so if you have saved a file that uses some code you haven't saved, the build will fail. – Richard Seal Apr 12 '17 at 12:50
  • Yes, everything compiles ok in VS. – Corey Burnett Apr 12 '17 at 12:51
  • 1
    Try setting verbosity: "minimal", to debug (in gulpfile.js) – Mark Cassidy Apr 12 '17 at 15:24
9

I'm also going through the Professional Sitecore 8 Development book and ran into the same issue. Not sure if you found the fix but thought I'd share my findings. I'm using Visual Studio 2017 Professional (toolsVersion = 15) and it turns out that gulp-msbuild doesn't support VS 2017. I made the following edits to the gulp-msbuild files to make this work:

SolutionRoot/node_modules/gulp-msbuild/lib/constants.js:

Modified the MSBUILD_VERSIONS from ...

MSBUILD_VERSIONS: {
1.0: 'v1.0.3705',
1.1: 'v1.1.4322',
2.0: 'v2.0.50727',
3.5: 'v3.5',
4.0: 'v4.0.30319',
12.0: '12.0',
14.0: '14.0'
}

to this ...

MSBUILD_VERSIONS: {
1.0: 'v1.0.3705',
1.1: 'v1.1.4322',
2.0: 'v2.0.50727',
3.5: 'v3.5',
4.0: 'v4.0.30319',
12.0: '12.0',
14.0: '14.0',
15.0: '15.0'
}

SolutionRoot/node_modules/gulp-msbuild/lib/msbuild-finder.js:

I added the following starting at line 31 ...

if (version === '15.0') {
  var env_var_dir = process.env['ProgramFiles(x86)'] || process.env['ProgramFiles'];
  var pathRoot = env_var_dir || path.join('C:', is64Bit ? 'Program Files (x86)' : 'Program Files');

  return path.join(pathRoot, 'Microsoft Visual Studio', '2017', 'Professional', 'MSBuild', version, 'Bin', 'MSBuild.exe');
}

I'm sure there are more elements in that path that could/should be parameterized but I'm just interested in getting this to work for this project. After I made these changes I had to reboot and then running the "Publish-Site" task worked as expected.

Finally, I updated my gulpfile.js to look like this:

var gulp = require("gulp");
var msbuild = require("gulp-msbuild");
var debug = require("gulp-debug");
var foreach = require("gulp-foreach");
var gulpConfig = require("./gulp-config.js")();
module.exports.config = gulpConfig;
gulp.task("Publish-Site", function () {
return gulp.src("./{Feature,Foundation,Project}/**/**/*.csproj")
    .pipe(foreach(function (stream, file) {
        return stream
            .pipe(debug({ title: "Publishing" }))
            .pipe(msbuild({
                targets: ["Build"],
                gulpConfiguration: gulpConfig.buildConfiguration,
                properties: {
                    publishUrl: gulpConfig.webRoot,
                    DeployDefaultTarget: "WebPublish",
                    WebPublishMethod: "FileSystem",
                    DeployOnBuild: "true",
                    DeleteExistingFiles: "false",
                    _FindDependencies: "false",
                    VisualStudioVersion: "15.0"
                },
                verbosity: "diagnostic",
                toolsVersion: 15.0
            }));
    }));
});

Notice the two extra parameters: VisualStudioVersion and toolsVersion.

I hope that helps.

Cheers

| improve this answer | |
  • Nice one mate! fixed my problem – JayPex Oct 1 '17 at 18:20
  • I had the same problem and used your solution but I am getting a new error with your changes. C:\Projects\Sitecore8Dev\SitecoreDev\node_modules\gulp-msbuild\lib\msbuild-finder.js:15 throw new PluginError(constants.PLUGIN_NAME, 'No MSBuild Version was supplied!'); ^ Error: No MSBuild Version was supplied! Process terminated with code 1. – Tammi Jo Gilman Mar 25 '18 at 1:52
  • Big thanks for this. One thing to note - the modifications to "SolutionRoot/node_modules/gulp-msbuild/lib/msbuild-finder.js" have changed position to line 163 in the latest gulp-msbuild. Basically to be found around the line "var version = constants.MSBUILD_VERSIONS[options.toolsVersion];". Shame the NPM package is no longer maintained - something to think about going forward with this approach I guess. – Mr Chris Mar 1 '19 at 9:23
2

Please make sure you have the Latest MS build version tools.

you can get the Latest versions from https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017

Recommended for sitecore is to use Visual Studio 2017 and Build Tools For Visual Studio 2017. You can also use offline installer by pointing to the directory and running this command.

vs_buildtools.exe --add Microsoft.VisualStudio.Workload.MSBuildTools --quiet

Then run

npm uninstall -g node-gyp

npm install -g node-gyp

Making sure that those node libs are not affected. Hope this helps!

| improve this answer | |
  • 1
    To safe yourself from troubles finding the download link to it, use chocolatey: PS> choco install visualstudio2017buildtools – Joost Apr 27 '19 at 17:08
0

I followed solution by @sitecore-sam and install build tools v2019 (current version). This installs only Roslyn build tools locally (C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\Roslyn). But gulp taks was keep looking for "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\amd64\".

Solution that worked for me was: I copied the amd64 folder from VS2017 Ent edition folders. This is not proper solution but as I could not find a way to forse to install a smd64 version of build tools I just copied the whole folder on required location.

The logicof finder explained by @ChesterC can be found here

| improve this answer | |

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.