Last active
January 31, 2023 15:49
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); |
If you have few solution files in source folder, you will get error: 'MSBUILD : error MSB1050: Specify which project or solution file to use because the folder "..........." contains more than one project or solution file.'
You need to set sourcePath, instead of solutionName (line 7). Probably in some version it was solutionName, but not now.
msbuild.sourcePath = config.solutionName + '.sln'
@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
Made a minor update to how (callback) is treated. I misunderstood (or didn't fully understand) how chained NPM tasks really hook up; so the task ran asynchronous. This is now solved.