MsBuild 和 MsDeploy 问题

标签 msbuild publish msdeploy

当我通过 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 

没有传递任何参数,例如 ComputerName、User 或 password。 关于原因有什么想法吗?

最佳答案

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

关于MsBuild 和 MsDeploy 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12960700/

相关文章:

msbuild - Visual Studio 2017 - 构建后退出,代码为 9009

windows-services - 使用 MsDeploy 通过 preSync 命令部署 Windows 服务

iis-7.5 - msdeploy将mvc转换为Windows7并获得ERROR_DESTINATION_NOT_REACHABLE和404

msbuild - csproj/msbuild 是否可以将文件作为可选内容包含在内?

eclipse - 使用 Eclipse 发布 tomcat 7.0

.net - 在 Visual Studio 2019 中将警告视为构建错误,而不是智能感知

jenkins - 适用于 Jenkins 的 SonarQube 扫描仪 - SonarQube MSBuild 集成失败 : SonarQube was unable to collect the required information about your projects

visual-studio - 如何使用单个 Visual Studio 解决方案同时构建 x86 和 x64?

javascript - 仅发布缩小版本的 JavaScript 文件 (ASPNET Core)

linux - "The directory name/app/Views/is invalid"在使用 docker 的 ASP.NET Core 部署上