Skip to content

Instantly share code, notes, and snippets.

@cassidydotdk
Last active January 31, 2023 15:49
Show Gist options
  • Save cassidydotdk/d2c72096ee0a1b5cf1e542ee108ce024 to your computer and use it in GitHub Desktop.
Save cassidydotdk/d2c72096ee0a1b5cf1e542ee108ce024 to your computer and use it in GitHub Desktop.
Task to build and publish a .SLN file from gulp using "msbuild" instead of "gulp-msbuild". Version 16.0 for VS2019, use 15.0 for VS2017.
module.exports = function () {
var config = {
websiteRoot: "C:\\inetpub\\wwwroot\\sc911.sc",
sitecoreLibraries: "C:\\inetpub\\wwwroot\\sc911.sc\\bin",
hostName: "http://sc911.sc",
solutionName: "sc911",
buildConfiguration: "Debug",
runCleanBuilds: false,
toolsVersion: "16.0"
}
return config;
}
var _msbuild = require("msbuild");
...
gulp.task("Publish-Solution", function (callback) {
var msbuild = new _msbuild(callback);
msbuild.solutionName = config.solutionName;
var overrideParams = [];
overrideParams.push('/p:Configuration=' + config.buildConfiguration);
overrideParams.push('/p:DeployOnBuild=true');
overrideParams.push('/p:DeployDefaultTarget=WebPublish');
overrideParams.push('/p:WebPublishMethod=FileSystem');
overrideParams.push('/p:DeleteExistingFiles=false');
overrideParams.push('/p:publishUrl=' + config.websiteRoot);
msbuild.config('overrideParams',overrideParams);
msbuild.config('version', config.toolsVersion);
// msbuild.targets = ["Build"];
msbuild.build(); // calls (callback) when done
});
@aleksandartraja
Copy link

@Antonytm, unfortunately, your suggestion didn't work for me. Do you have any suggestions or ideas about what might be wrong? I'm using gulp task in teamcity to do the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment