如何使用MsBuild MsDeployPublish来定位本地文件系统?

Duc*_*tro 38 msbuild asp.net-mvc msdeploy

我正在尝试复制Visual Studio 2010"发布..."命令(适用于Web应用程序项目),我将在UI中选择发布方法:"文件系统".

我的尝试是......

%msbuild%/ t:MsDeployPublish/property:MsDeployServiceUrl ="file:/// d:\ MyDeploymentFolder"; MsDeployPublishMethod ="File System""d:\ MySourceFolder\Project.csproj"

...并尝试过"FileSystem","File System","Local"等方法.

我得到的错误暗示MsDeploy仍在尝试推送到IIS服务器:

"D:\MySourceFolder\Project.csproj" (MsDeployPub
lish target) (1) ->
(MSDeployPublish target) ->
  C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web
.Publishing.targets(3847,5): error : Web deployment task failed.(The metabase k
ey '/lm/w3svc' could not be found.) [D:\MySourceFolder\Project.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.P
ublishing.targets(3847,5): error : \r [D:\MySourceFolder\Project.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.P
ublishing.targets(3847,5): error : The metabase key '/lm/w3svc' could not be fo
und.\r [D:\MySourceFolder\Project.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.P
ublishing.targets(3847,5): error : Unable to access the IIS configuration syste
m. Please make sure you have IIS 7 (or later) installed.\r [D:\MySourceFolder\Project.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.P
ublishing.targets(3847,5): error : Retrieving the COM class factory for compone
nt with CLSID {2B72133B-3F5B-4602-8952-803546CE3344} failed due to the followin
g error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REG
DB_E_CLASSNOTREG)). [D:\MySourceFolder\Project.csproj]
Run Code Online (Sandbox Code Playgroud)

我如何定位文件系统进行部署,因为Visual Studio通常会让我进入GUI?

Ric*_*lay 132

根据我使用MSBuild的答案,如何从命令行构建MVC4解决方案(在此过程中应用Web.config转换)并输出到文件夹?

msbuild ProjectFile.csproj /p:Configuration=Release ^
                           /p:Platform=AnyCPU ^
                           /t:WebPublish ^
                           /p:WebPublishMethod=FileSystem ^
                           /p:DeleteExistingFiles=True ^
                           /p:publishUrl=c:\output
Run Code Online (Sandbox Code Playgroud)

或者,如果您正在构建解决方案文件:

msbuild Solution.sln /p:Configuration=Release ^ 
                     /p:DeployOnBuild=True ^
                     /p:DeployDefaultTarget=WebPublish ^
                     /p:WebPublishMethod=FileSystem ^
                     /p:DeleteExistingFiles=True ^
                     /p:publishUrl=c:\output
Run Code Online (Sandbox Code Playgroud)

  • 这是构建web csproj文件的圣杯. (13认同)
  • 在 msbuild 上进行了大量搜索和尝试不同的组合,最终得出了这个答案。 (2认同)
  • 使用这个我的项目进行编译,但是没有生成输出。我的构建服务器不会在publishUrl目录上生成任何内容 (2认同)

Jes*_*sse 0

我认为您对 msbuild 的描述不够具体。

从我关于该主题的书签之一中拉出此内容,希望它会有所帮助:http://www.digitallycreated.net/Blog/59/locally-publishing-a-vs2010-asp.net-web-application-using-msbuild