我有一个网站(不是网络应用程序),我想每晚从同一目录中的命令提示符发布它。
我不想使用像TeamCity,TFS或第三方工具(如Nant)这样的构建自动化工具 - 它应该使用MSBuild
来完成。我怎么能这样做?
更新:应选中的唯一选项是Use Fixed naming and single page assemblies
。
答案 0 :(得分:21)
根据您的评论,您的网络项目是一个网站项目,而不是一个Web应用程序项目。
在这种情况下,“发布”目标不是选项,但“AspNetCompiler”是解决方案。
创建一个包含以下内容的xml文件,并从MSBuild调用它。
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="PrecompileWeb">
<AspNetCompiler
VirtualPath="/MyWebSite"
PhysicalPath="c:\inetpub\wwwroot\MyWebSite\"
TargetPath="c:\precompiledweb\MyWebSite\"
Force="true"
Debug="true"
FixedNames="True"
/>
</Target>
</Project>
此任务的参考是here,您可以配置所有取消/检查选项。
FixedName =“True”等于“使用固定命名和单页...”选项的检查。
然后从MSBuild而不是解决方案文件中调用此文件。
MSBuild your.xml /p:Configuration=<Debug/Release>
只要您的网站项目引用了您的类库,它们就会一起构建。
答案 1 :(得分:6)
MSBuild.exe **MYPROJ**.sln
/p:outdir="Z:\output\\",OutputPath="Z:\output\\",webprojectoutputdir="Z:\output\\",configuration=RELEASE
/t:Clean;Build
/flp1:logfile=Z:\output\\\Log_msbuild.log;verbosity=detailed
/flp2:logfile=Z:\output\\\Log_warnings.log;warningsonly;verbosity=detailed
/flp3:logfile=Z:\output\\\Log_errors.log;errorsonly;verbosity=detailed
/nologo
/noconlog
可以编译所有类型的项目(Web,webservice,desktop,..),它可以创建日志文件(buildlog,error和warnings)。
答案 2 :(得分:1)
对于迟到的回复感到抱歉,感谢输入alan。不幸的是你的建议没有用,所以我最终做了以下事情:
This build does not copy output files to a drop folder
AsConfigured
作为“处理”标签下Output location
下2. Build
的值使用此MSBuild参数字符串:
/p:DeployOnBuild=True;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;PackageTempRootDir="\\192.168.x.x\Nightly\MainBranch";AutoParameterizationWebConfigConnectionStrings=false
此结果是我用作测试站点的webroot的以下文件夹:\\192.168.x.x\Nightly\MainBranch\PackageTmp
。
这显然不是最优的,因为我不想拥有PackageTmp
文件夹,而且我还没有测试当同一个解决方案中有多个Web应用程序时会发生什么,但我不能在此使用更多时间问题。
我真的不明白为什么微软这么简单的任务如此复杂。