我正在创建一个winform应用程序,用于使用msdeploy将网站部署到IIS 7。我的表单上有三个文本框,名为txtName,txtPort和txtSelectedFile。这两个文本框中的输入用于创建命令。 以下是字符串连接:
string command = "\"%PROGRAMFILES%\\IIS\\Microsoft Web Deploy\\msdeploy.exe\" -verb:sync
-presync:runCommand=\"md %SystemDrive%\\inetpub\\wwwroot\\" + txtName.Text.Trim() +
" & %systemroot%\\System32\\inetsrv\\appcmd add site /name:" + txtName.Text.Trim() +
" /id:22 /bindings:http/*:" + txtPort.Text.Trim() + ": /physicalPath:%SystemDrive%\\inetpub\\wwwroot\\" +
txtName.Text.Trim() + " \" -source:package=" + txtSelectedFile.Text +
" -dest:contentPath=%SystemDrive%\\inetpub\\wwwroot\\" + txtName.Text.Trim();
我正在使用ProcessStartInfo来运行命令。但是网站没有安装。 但是,如果我放置一个调试器并在名为command的变量中捕获文本并使用命令提示符手动执行它,则会部署该网站。