的MSBuild - 如何建立从pre-写命令行命令的.NET解决方案文件(在XML任务脚本) [英] MSBuild - How to build a .NET solution file (in an XML task script) from pre-written command line commands

查看:127
本文介绍了的MSBuild - 如何建立从pre-写命令行命令的.NET解决方案文件(在XML任务脚本)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习的MSBuild,因为我有需要我的自动化发展店铺的建立。我能够很容易地编写调用VS命令提示符,然后通过我的MSBuild命令它.bat文件。这个工程相当好,并且还挺漂亮的。

I have been studying MSBuild as I have the need to automate my development shop's builds. I was able to easily write a .BAT file that invokes the VS command prompt and passes my MSBuild commands to it. This works rather well and is kinda nifty.

下面是我的.BAT构建文件的内容:

Here is the contents of my .BAT build file:

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文件的命令?任何想法?

^ This works well but I now have the need to use the MSBuild task for TeamCity CI. I have tried to write a few MSBuild scripts but I cannot get them to work the same. What is the equivalent build script to the command I am using in my .BAT file? Any ideas?

我使用这样的事情都尝试过,但没有成功(我知道这是不对的):

I have tried using something like this, but no success (I know this is wrong):

<?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的XML构建脚本编译为发布模式,以指定的输出目录的单一解决方案。任何帮助?

推荐答案

使用的MSBuild任务来构建传递您所需要的性能解决方案。

Use the MSBuild task to build the solution passing the properties you need.

<?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>

这篇关于的MSBuild - 如何建立从pre-写命令行命令的.NET解决方案文件(在XML任务脚本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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