我一直在研究MSBuild,因为我需要自动化我的开发店的构建。我能够轻松地编写一个调用VS命令提示符的.BAT文件,并将我的MSBuild命令传递给它。这工作比较好,有点漂亮。
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat" cd C:\SandBox\Solution msbuild MyTopSecretApplication.sln /p:OutputPath=c:\TESTMSBUILDOUTPUT /p:Configuration=Release,Platform=x86 pause
^这样做很好,但是现在我需要使用MSBuild任务给TeamCity CI。我试图写几个MSBuild脚本,但我不能让他们工作相同。我在.BAT文件中使用的命令的等效生成脚本是什么?有任何想法吗?
我试过使用这样的东西,但没有成功(我知道这是错误的):
<?xml version="1.0"?> <project name="Hello Build World" default="run" basedir="."> <target name="build"> <mkdir dir="mybin" /> <echo>Made mybin directory!</echo> <csc target="exe" output="c:\TESTMSBUILDOUTPUT"> <sources> <include name="MyTopSecretApplication.sln"/> </sources> </csc> <echo>MyTopSecretApplication.exe was built!</echo> </target> <target name="clean"> <delete dir="mybin" failonerror="false"/> </target> <target name="run" depends="build"> <exec program="mybin\MyTopSecretApplication.exe"/> </target>
使用MSBuild任务构建传递所需属性的解决方案。
原文链接:https://www.f2er.com/xml/293216.html<?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" DefaultTargets="Build"> <PropertyGroup> <OutputDir>c:\TESTMSBUILDOUTPUT</OutputDir> </PropertyGroup> <ItemGroup> <ProjectToBuild Include="MySecretApplication.sln"> <Properties>OutputPath=$(OutputDir);Configuration=Release</Properties> </ProjectToBuild> </ItemGroup> <Target Name="Build"> <MSBuild Projects="@(ProjectToBuild)"/> </Target> </Project>