1

I try to publish my Sitecore project solution using a custom-made script. I run the gulp publishSitecoreSolution command (a custom-made one), and I get this output in PowerShell:

[15:55:04] Loading C:\users\USERNAME\source\repos\PROJECT_FOLDER\sitecore-training-project\gulpfile.js\tasks\publishProject.js
[15:55:04] Using gulpfile C:\users\USERNAME\source\repos\PROJECT_FOLDER\sitecore-training-project\gulpfile.js
[15:55:04] Starting 'publishSitecoreSolution'...
  publish starting
  publish starting
  publish starting
  publish starting
  publish starting
  publish starting
  publish starting
  publish starting
[15:55:08] 'publishSitecoreSolution' errored after 3.88 s
[15:55:08] Error: spawn C:\windows\microsoft.net\Framework64\v(not used)\msbuild.exe ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

There are but a few threads on the internet dealing with this, like the one here Issue while Setup Habitat 1.8.1 on Sitecore 9.2 "Error: spawn C:\Windows\microsoft.net\Framework64\v(not used)\msbuild.exe ENOENT". It's similar, but not the same.

So far I tried looking through the registry, after that looking at folder contents in the path outlined in error text (screenshot below), enter image description here

then I tried logging whatever I could in the gulpfile, such as the contents of the msbuild object, and here's what console.table(msbuild) gives

enter image description here

I'm including the code snippet where the msbuild object I'm logging is defined and where the function publishSitecoreSolution that is executed by gulp is defined:

var gulp = require("gulp");
var _msbuild = require("msbuild");
var argv = require("yargs").argv;
var glob = require("glob");

function publishProject(src, publishProfile){   
    var msbuild = new _msbuild();
    
    msbuild.sourcePath = src;
    msbuild.version = $.config.msBuildVersion;
    msbuild.overrideParams.push("/p:PublishProfile=" + publishProfile);
    msbuild.publish();
};

async function publishSitecoreProject(){
    var src = argv.layer + "/" + argv.name + "/code/*.csproj";
    var publishProfile = (argv.publishProfile === undefined) ? "Default" : argv.publishProfile;
    
    var filePath = glob.sync(src)[0];
    if(filePath != "undefined"){
        publishProject(filePath, publishProfile);
    } else{
        console.log("Project does not exist!"); 
    }
};

async function publishSitecoreLayer(){
    var src = argv.layer + "/**/code/*.csproj";
    var publishProfile = (argv.publishProfile === undefined) ? "Default" : argv.publishProfile;
    
    var filePathes = glob.sync(src);
    if(filePathes.length > 0){
        filePathes.forEach(async function(filePath){
            publishProject(filePath, publishProfile);
        });
    } else{
        console.log("Layer does not exist or empty!");
    }
};

async function publishSitecoreSolution(){
    var src = "./**/**/code/*.csproj";
    var publishProfile = (argv.publishProfile === undefined) ? "Default" : argv.publishProfile;
        
    var filePathes = glob.sync(src);
    if(filePathes.length > 0){
        filePathes.forEach(async function(filePath){
            publishProject(filePath, publishProfile);
        });
    } else{
        console.log("Layer does not exist or empty!");
    }
};

gulp.task("publishSitecoreProject", publishSitecoreProject);
gulp.task("publishSitecoreSolution", publishSitecoreSolution);
gulp.task("publishSitecoreLayer", publishSitecoreLayer);

I've the latest .NET SDK installed.

I simply don't know where to look or what to do anymore. Any help is appreciated! Thanks-

1
  • Which version of npm are you using? Can you also list your dependencies in package.json? If I recall correctly, this can happen due to version issues with npm and/or a subdependency of a module. Once you add a bit more info I should be able to help. Commented Nov 30, 2022 at 23:22

2 Answers 2

0

I had the same problem. You can see a version of MSBuild in a configuration of your custom gulp script, and the version that you have on your pc. My one was installed with Visual Studio and was 17, the version of VS was 22, so I decided to install VS 19 and problem was gone.

0

It seems like it's gone through well now. I listened to your advice and installed VS 2019 with ASP.NET development and .NET desktop development feature packages (I don't know if the latter made any impact on the resolution of the problem). Until now I've been using VS 2022, and I still am, but this gulp thing needs VS 2019 for some of it's stuff.

Since I didn't install both feature packages in the initial install, the gulp build didn't go through and I installed .NET compiler package to account for Roslyn not being there. That didn't help much, it failed again, hence I went on to install feature packages and succeed.

The build using gulp goes through and finishes, but with errors. It would be too long to post the log here. For now we can mark this as resolved! A big thanks, @Vinchik!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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