【问题标题】:MsBuild and MsDeploy problemsMsBuild 和 MsDeploy 问题
【发布时间】:2012-10-18 17:52:06
【问题描述】:

当我通过 gui(VS2010) 发布 Web 项目时(右键单击项目并选择发布菜单项,发布方法 - Web 部署) - 一切正常。

当我尝试通过命令行发布时出现问题: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 

未传递任何参数,例如计算机名称、用户或密码。 有关原因的任何想法?

【问题讨论】:

    标签: msbuild publish msdeploy


    【解决方案1】:

    问题解决了。 从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 的问题仍然存在。

    【讨论】:

      【解决方案2】:

      在您的 pubxml 文件中,声明以下内容:

      <PropertyGroup>
          <UseMsDeployExe>true</UseMsDeployExe>
      </PropertyGroup>
      

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

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

      【讨论】:

        猜你喜欢
        • 2011-08-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-03-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-07-26
        相关资源
        最近更新 更多