如何通过命令提示符调用 MSBuild?
我有一个网站(不是 Web 应用程序),我想每天晚上从同一目录中的命令提示符发布它。
我不想使用 TeamCity、TFS 等构建自动化工具或 Nant 等第三方工具 - 应该使用 MSBuild
来完成。我该怎么做?
更新:在“发布”窗口中,唯一应检查的选项是使用固定命名和单页程序集
。
I have a website (not a web application) and I want to publish it from the command prompt in the same directory every night.
I don't want to use build automation tools like TeamCity, TFS, or third-party tools like Nant - it should be done with MSBuild
. How can I do this?
Update: in the Publish window the only option that should be checked is Use Fixed naming and single page assemblies
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据您的评论,您的 Web 项目是一个网站项目,而不是一个 Web 应用程序项目。
在这种情况下,“Publish”目标不能作为选项,但“AspNetCompiler”是解决方案。
创建一个包含以下内容的 xml 文件并从 MSBuild 调用它。
此任务的参考位于此处,您可以配置所有取消/检查选项。
FixedName="True" 等于检查“使用固定命名和单页...”选项。
然后,您从 MSBuild 调用此文件而不是解决方案文件。
只要您的网站项目引用了您的类库,它们就会一起构建。
From your comment, your web project is a web site project and not a web application project.
In this case, 'Publish' target can not be the option but 'AspNetCompiler' is the solution.
Create an xml file with below content and call it from MSBuild.
Reference to this task is here and you can configure all your un/check options.
FixedName="True" equals the checking of 'use fixed naming and single page...' option.
Then you call this file from MSBuild instead of the solution file.
As long as your class libraries are referenced by your web site project, they'll be built together.
它可以编译所有类型的项目(Web、Web服务、桌面......),并且可以创建日志文件(构建日志、错误和警告)。
İt can compile all Types of projects(Web,webservice,desktop,..) and it can create log files as(buildlog,error and warnings).
抱歉回复晚了,感谢艾伦的输入。不幸的是,您的建议不起作用,因此我最终执行了以下操作:
此构建不会将输出文件复制到放置文件夹
AsConfigured
作为2 下
输出位置
的值。在“进程”选项卡下构建使用此 MSBuild 参数字符串:
/p:DeployOnBuild=True;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;PackageTempRootDir="\\192.168.xx\Nightly\MainBranch";AutoParameterizationWebConfigConnectionStrings=false
此结果是我用作测试的 webroot 的以下文件夹地点:
\\192.168.xx\Nightly\MainBranch\PackageTmp
。这显然不是最佳选择,因为我不想拥有
PackageTmp
文件夹,而且我也没有测试当同一解决方案中有多个 Web 应用程序时会发生什么,但我不能使用更多时间在这个问题上。我真的不明白为什么微软要把这么简单的任务搞得这么复杂。
Sorry for the late reply, and thanks for the input alan. Unfortunately your suggestion did not work so I ended up doing the following:
This build does not copy output files to a drop folder
under the Build defaults tabAsConfigured
as the value for theOutput location
under2. Build
under the Process tabUse this MSBuild argument string:
/p:DeployOnBuild=True;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;PackageTempRootDir="\\192.168.x.x\Nightly\MainBranch";AutoParameterizationWebConfigConnectionStrings=false
This result is the following folder which I use as the webroot for the test site:
\\192.168.x.x\Nightly\MainBranch\PackageTmp
.This obviously isn't optimal since I would prefer not to have the
PackageTmp
folder and I also haven't tested what happens when there are multiple web applications in the same solution, but I can't use more time on this issue.I really don't understand why Microsoft have made such a simple task so complicated.