我认为问题标题已经说明了一切,但为了清楚起见,我试图:
I think the question title pretty much said it all, but for clarity, I am trying to:
我已经尝试通过 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 转换)并输出到文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!