MsBuild和MsDeploy问题

3

当我通过GUI(VS2010)发布Web项目(右键单击项目并选择“发布”菜单项,发布方法 - Web Deploy)时,一切都很顺利。

当我尝试通过命令行进行发布:MSBUILD或MsDeploy时,就会出现问题。

使用MSBuild创建的包没有发布(只创建了包):

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSbuild.exe" Project.sln /p:DeployOnBuild=true /p:DeployTraget=MSDeployPublish /p:MSDeployPublishMethod=WMSVC /p:MSDeployServiceUrl=https://[ip]/msdeploy.axd /p:AllowUntrustedCertificate=true  /p:DeployIisAppPath=NlbTestSite /p:UserName=M\DeployUser /p:Password=qwerty

使用MsDeploy时,我遇到了一个错误:ERROR_USER_UNAUTHORIZED。
E:\Work\OutDir\MSDeploy\Package.deploy.cmd" /Y /M:"https://[ip]:8172/msdeploy.axd" /U:"M\DeployUser" /P:"qwerty" -allowUntrusted /A:Basic

我的目标是使用其中一种方法自动化部署过程。
我想找出Visual Studio如何发布我的项目(使用什么命令和参数)?
更新19.10.2012 14:52:
当我添加 /p:UseMsDeployExe=true 时,msdeploy.exe 被执行,但没有复制任何内容。
执行命令:
C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe -source:manifest='E:\[Path]\obj\Debug\Package\[Project].SourceManifest.xml' -dest:package='E:\[Path]\[Project]\obj\Debug\Package\[Project].zip',IncludeAcls='False' -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -declareParam:name='IIS Web Application Name',kind='ProviderPath',scope='IisApp',match='^E:\\[Path]\\obj\\Debug\\Package\\PackageTmp$',defaultvalue='[SiteName]',tags='IisApp' -declareParam:name='IIS Web Application Name',kind='ProviderPath',scope='setAcl',match='^E:\\[Path]\\obj\\Debug\\Package\\PackageTmp$' -declareParam:name='Add write permission to App_Data Folder',kind='ProviderPath',scope='setAcl',match='^E:\\[Path]\\obj\\Debug\\Package\\PackageTmp\\App_Data$',description='Add write permission to App_Data folder',defaultvalue='{IIS Web Application Name}/App_Data',tags='Hidden' -declareParam:name='MainModelContainer-Web.config Connection String',kind='XmlFile',scope='E:\\[Path]\\OutDir\\temp\\Web\.config$',match="/configuration/connectionStrings/add[@name='MainModelContainer']/@connectionString",description='MainModelContainer Connection String used in web.config by the application to access the database.',defaultvalue='metadata=[ConnectionString]"',tags='SqlConnectionString' -declareParam:name='SimpleConnection-Web.config Connection String',kind='XmlFile',scope='E:\\[Path]\\OutDir\\temp\\Web\.config$',match="/configuration/connectionStrings/add[@name='SimpleConnection']/@connectionString",description='SimpleConnection Connection String used in web.config by the application to access the database.',defaultvalue='[ConnectionString]',tags='SqlConnectionString' -declareParam:name='ElmahDB-Web.config Connection String',kind='XmlFile',scope='E:\\[Path]\\OutDir\\temp\\Web\.config$',match="/configuration/connectionStrings/add[@name='ElmahDB']/@connectionString",description='ElmahDB Connection String used in web.config by the application to access the database.',defaultvalue='[ConnectionString]',tags='SqlConnectionString' -retryAttempts=2 

没有传递任何参数,比如计算机名称、用户或密码。有关原因的任何想法?
2个回答

2

问题已解决。 我从http://root-project.org/work/net/automated-web-deployment-with-msbuild-and-msdeploy中得到了一些想法。

我分离了msbuild和msdeploy,并显式地执行了msdeploy。 这是模板:

msdeploy.exe
-source:package=’C:\SomeWebProject\obj\Release\Package\SomeWebProject.zip‘
-dest:auto,ComputerName=’https://TargetServer:8172/MsDeploy.axd?site=TargetWebSite‘,UserName=’Username‘,Password=’Password‘,IncludeAcls=’False’,AuthType=’Basic’
-verb:sync
-disableLink:AppPoolExtension
-disableLink:ContentExtension
-disableLink:CertificateExtension
-allowUntrusted
-retryAttempts=2
-setParam:’IIS Web Application Name’=’TargetWebSite/TargetWebApp‘

但是 msbuild 仍然存在问题。

1
在你的 pubxml 文件中,声明以下内容:
<PropertyGroup>
    <UseMsDeployExe>true</UseMsDeployExe>
</PropertyGroup>

现在当您部署时,您应该在发布日志中看到对msdeploy.exe的调用。

请注意,它实际上将直接调用msdeploy.exe,而不是通过生成的deploy.cmd文件。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接