使用 MSBuild,我如何从命令行构建 MVC4 解决方案(在过程中应用 Web.config 转换)并输出到文件夹? [英] Using MSBuild, how do I build an MVC4 solution from the command line (applying Web.config transformations in the process) and output to a folder?

查看:20
本文介绍了使用 MSBuild,我如何从命令行构建 MVC4 解决方案(在过程中应用 Web.config 转换)并输出到文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为问题标题已经说明了一切,但为了清楚起见,我试图:

I think the question title pretty much said it all, but for clarity, I am trying to:

  1. 从命令行 (MSBuild) 构建 VS2010 ASP.NET MVC4 解决方案,指定解决方案配置(例如发布)
  2. 在此过程中为该配置应用任何 Web.config 转换
  3. 将结果输出到本地机器上的一个文件夹中(没有 IIS、代理、zip 文件、FTP、包等,只是 一个文件夹 包含运行该网站所需的所有文件)
  1. Build a VS2010 ASP.NET MVC4 solution from the command line (MSBuild), specifying a solution configuration (e.g. Release)
  2. Apply any Web.config transformations for that configuration during the process
  3. Output the results into a folder on the local machine (no IIS, agents, zip files, FTP, packages etc, just a folder containing all the files required to run that web site)

我已经尝试通过 Microsoft 文档(非常无用)、关于 SO 和一般谷歌搜索的其他答案来解决这个问题将近一周.我不知道我是否只是没有得到它(这完全有可能),或者 MSBuild/MSDeploy 是否真的是它目前看起来的神秘混乱.

I've been trying to figure this out for almost a week now, through the Microsoft docs (which are spectacularly unhelpful), other answers on SO and general Googling. I don't know if I'm just not getting it (which is entirely possible), or if MSBuild/MSDeploy really is the cryptic mess it currently appears to be.

有没有一种相当简单的方法来实现这一点?请帮忙!

Is there a reasonably simple way to achieve this? Help, please!

推荐答案

如果您运行的是 VS2010:请确保您已安装 Azure 1.7+ SDK(即使您没有发布到 Azure,它也会将 VS2012 发布功能添加到VS2010)

If you are running VS2010: ensure you have the Azure 1.7+ SDK installed (even if you're not publishing to Azure, it adds the VS2012 publishing features to VS2010)

VS2012+ 内置了这些功能

VS2012+ have these featured built in

msbuild ProjectFile.csproj /p:Configuration=Release ^
                           /p:Platform=AnyCPU ^
                           /t:WebPublish ^
                           /p:WebPublishMethod=FileSystem ^
                           /p:DeleteExistingFiles=True ^
                           /p:publishUrl=c:output

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

Or if you are building the solution file:

msbuild Solution.sln /p:Configuration=Release ^ 
                     /p:DeployOnBuild=True ^
                     /p:DeployDefaultTarget=WebPublish ^
                     /p:WebPublishMethod=FileSystem ^
                     /p:DeleteExistingFiles=True ^
                     /p:publishUrl=c:output

无论哪种方式,您也可以设置 /p:PrecompileBeforePublish=true 并且输出将是网站的预编译版本.

Either way, you can also set /p:PrecompileBeforePublish=true and the output will be a precompiled version of the site.

安装 Azure SDK 后,您通常会创建一个发布配置文件并简单地使用 /p:PublishProfile=DeployToFolder 但我已经为您提供了手动命令行以防您不感兴趣全力投入新的出版内容.

Once you have the Azure SDK installed you would usually create a publish profile and simply use /p:PublishProfile=DeployToFolder but I've given you the manual command line in case you're not interested in going all-in with the new publishing stuff.

这篇关于使用 MSBuild,我如何从命令行构建 MVC4 解决方案(在过程中应用 Web.config 转换)并输出到文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆