从Visual Studio进行Web部署的Gulp任务

时间:2016-07-11 11:39:32

标签: msbuild gulp webdeploy

我还没有找到一个关于如何通过Gulp任务进行发布的具体示例。有人有想法吗?

这就是我现在正在尝试的方式。

gulp.task("Deploy-To-Azure", function() {
var targets = ["Build"];
console.log("Publishing to Azure");
return gulp.src(["./src/Feature/Accounts/code"])
.pipe(foreach(function (stream, file) {
    return stream
      .pipe(debug({ title: "Building project:" }))
      .pipe(msbuild({
          targets: targets,
          configuration: "Azure",
          logCommand: false,
          verbosity: "verbose",
          stdout: true,
          errorOnFail: true,
          maxcpucount: 0,
          toolsVersion: 14.0,
          properties: {
              DeployOnBuild: "true",
              DeployDefaultTarget: "Web Deploy",
              WebPublishMethod: "FileSystem",
              DeleteExistingFiles: "false",
              _FindDependencies: "false",
              Configuration: "Release"
          }
      }))
    .pipe(debug({title: "Finished building project"}));
}));

});

但看起来项目已构建但未部署。我认为我的房产不完整。任何想法都表示赞赏。谢谢

2 个答案:

答案 0 :(得分:0)

我尝试从命令行使用这些相同的MSBuild属性,并收到以下错误:

>c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild /p:DeployOnBuild=true /p:WebPub
lishMethod=FileSystem /p:DeleteExistingFiles=false /p:DeployDefaultTarget="Web Deploy"
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.P
ublishing.targets(4449,11): error MSB4057: The target "Web Deploy" does not exi
st in the project. [c:\users\me\documents\visual studio 2015\projects\w
ebapplication12\WebApplication12.csproj]

除非您已创建名为“Web Deploy”的自定义MSBuild目标。这不起作用。

当我删除/p:DeployDefaultTarget="Web Deploy"属性时,会在/obj/[configuration]/Package文件夹中创建WebDeploy包。

答案 1 :(得分:0)

尝试DeployDefaultTarget:" WebPublish"