Skip to content

Instantly share code, notes, and snippets.

@GeorgDangl
Last active March 6, 2018 13:31
Show Gist options
  • Save GeorgDangl/d69fd27941f563848d4d06f215fe3063 to your computer and use it in GitHub Desktop.
Save GeorgDangl/d69fd27941f563848d4d06f215fe3063 to your computer and use it in GitHub Desktop.
Using Microsoft WebDeploy with NUKE build, see https://blog.dangl.me/archive/using-webdeploy-via-nuke-build-scripts/
class Build : NukeBuild
{
[Parameter] readonly string Environment;
[Parameter] readonly string WebDeployUsername;
[Parameter] readonly string WebDeployPassword;
[Parameter] readonly string WebDeployPublishUrl;
[Parameter] readonly string WebDeploySiteName;
Target Publish => _ => _
.Requires(() => Environment)
.DependsOn(FrontendRestore)
.DependsOn(BackendRestore)
.DependsOn(FrontendCompile)
.Executes(() =>
{
DotNetPublish(p =>
{
return p.SetWorkingDirectory(SourceDirectory / "project_name")
.SetConfiguration(Environment)
.SetOutput(OutputDirectory);
});
});
Target Deploy => _ => _
.DependsOn(Publish)
.Requires(() => WebDeployUsername)
.Requires(() => WebDeployPassword)
.Requires(() => WebDeployPublishUrl)
.Requires(() => WebDeploySiteName)
.Executes(() =>
{
WebDeploy(s =>
{
return s.SetSourcePath(OutputDirectory)
.SetUsername(WebDeployUsername)
.SetPassword(WebDeployPassword)
.SetEnableAppOfflineRule(true)
.SetPublishUrl(WebDeployPublishUrl)
.SetSiteName(WebDeploySiteName);
});
});
}
./build.ps1 -target Deploy `
-Environment 'Staging' `
-WebDeployUsername '$appname' `
-WebDeployPassword 'password' `
-WebDeployPublishUrl 'https://appname.scm.azurewebsites.net:443/msdeploy.axd?site=appname' `
-WebDeploySiteName 'appname'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment