MSBuild任务 - 构建失败,因为一个解决方案,正在兴建中的释放,而不是调试而不是、解决方案、任务、MSBuild

2023-09-03 06:46:52 作者:此乃特长

我打一个奇怪的问题,的MSBuild ,我想这可能只是是一个环境问题。我们使用的MSBuild建设一批独立的解决方案,它似乎工作,我的机器上。但在几个其他的机器,它不工作。

我已经找到了这个问题,它看起来像的解决方案之一(或在该解决方案中的项目之一),当一切正在建设中的调试正在建设中释放。这会导致一些引用是缺少 - 这样的解决方案,正在兴建中的释放构建失败。我希望所有的解决方案要建在调试。下面是我们目前TFSBuild.proj文件 - 什么是我们做错了

 < XML版本=1.0编码=UTF-8&GT?;
<项目DefaultTargets =DesktopBuild的xmlns =htt​​p://schemas.microsoft.com/developer/msbuild/2003>
    <! - 要编辑生成类型定义

        编辑构建类型,您将需要编辑
        其通过创建新生成的该文件
        建立Type向导。该文件是在源
        控制和需要被检查出来之前
        在进行任何更改。

        该文件可在 - 

            $ / {TeamProjectName} / TeamBuildTypes / {BuildTypeName}

        在那里你将需要更换TeamProjectName
        和BuildTypeName与您的团队项目和
        建立你创建的类型名称

        检出文件

          1.打开源代码管理资源管理器中选择
             查看 - >其他窗口 - >源代码控制管理

          2.确保当前工作区有一个映射
             在$ / {TeamProjectName} / TeamBuildTypes文件夹,
             你已经上做了获取最新版本
             夹

          通过文件夹3.浏览
             {TeamProjectName}  - > TeamBuildTypes-> {BuildTypeName}文件夹

          4.从该文件夹,在可用的文件列表,右键
             点击TfsBuild.Proj。选择检查出编辑...

        进行必要的更改到该文件并保存

        签入文件
          1.右键单击TfsBuild.Proj文件
             在步骤3中选择上面,并选择
             签入挂起的更改

          2.使用挂起的签入对话框,以节省您
             更改源代码控制

        一旦文件被选中与
        修改,用这一切的未来构建
        构建类型将使用修改后的设置
     - >

    <! - 请不要修改此 - >
    <进口Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\TeamBuild\Microsoft.TeamFoundation.Build.targets" />
    < ProjectExtensions>

        &所述;! - 说明
            该描述与生成关联
            类型。编辑更改值。
         - >
        <描述>
        < /说明>

        <! - 构建机
            机器的名称将被用来
            建立所选择的解决方案。
         - >
        < BuildMachine> XXXX-测试< / BuildMachine>
    < / ProjectExtensions>
    <的PropertyGroup>

      <! - 团队项目
          该团队项目,该项目将通过建设
          此版本类型。
       - >
      < TeamProject> CFAST< / TeamProject>

      <! -  build目录
          在构建机上即会在目录
          可用于构建选定的解决方案。该
          目录必须构建一个本地路径
          机器(例如C:\版本)。
       - >
      < BuildDirectoryPath> C:\建立\ brtcn< / BuildDirectoryPath>
      <!$(IsDesktopBuild)'='真'SolutionRoot条件=
      > $(BuildDirectoryPath)\ W< / SolutionRoot>

      <! - 放置位置
          位置下降(复制)生成的二进制文件
          和构建后的日志文件是完整的。
          此位置必须是一个有效的UNC路径
          格式为\\服务器\共享。构建机
          服务帐户和应用程序层的帐户
          需要对这个读写权限
          分享。
       - >
      < D​​ropLocation> \\我的档案\ XX-文件\生成放置\ XX< / DropLocation>

      <! - 测试
          设置该标志来启用/禁用运行测试
          作为后生成步骤。
       - >
      <的runTest>假< /的runTest>
      &所述;! -  WorkItemFieldValues
          添加/编辑键值对,为设置的值
          在过程中产生的工作项字段
          构建过程。请确保字段
          名称是适用于工作项目类型为
          使用。
       - >
      < WorkItemFieldValues​​>症状=打造突破;要重现=使用团队构建和LT启动建设; / WorkItemFieldValues​​>
      <  - !code解析
          要改变codeAnalysis行为编辑本
          值。该有效值可以是
          默认情况下,总是或从不。

          默认 - 要执行code分析,按照单个项目设置
          始终 - 要始终履行无关的项目设置code分析
          从不 - 从不进行项目设置code分析,不论
        - >
      <运行codeAnalysis>决不< /运行codeAnalysis>

      <! - 更新相关联的工作项目
       设置该标志以创建成功启用/禁用更新相关的工作项
       - >
      < UpdateAssociatedWorkItems>真< / UpdateAssociatedWorkItems>
      <! - 标题上生成失败创建工作项目 - >
      < WorkItemTitle>建立失败编译:LT; / WorkItemTitle>
      <! - 说明关于构建失败创建工作项目 - >
      < descriptiontext描述>这个工作项目是由团队创造建立在构建失败< / descriptiontext描述>
      <! - 文本指向在构建失败日志文件的位置 - >
      < BuildlogText>将生成日志文件是:LT; / BuildlogText>
      <! - 文本指向误差对构建失败/警告文件的位置 - >
      < ErrorWarningLogText>将错误/警告日志文件是:LT; / ErrorWarningLogText>
    < /的PropertyGroup>
    < ItemGroup>
        &所述;! - 解
            构建解决方案的路径。至
            添加/删除解决方案,修改这个值。对于
            例如,要添加的溶液MySolution.sln,
            添加以下行 - 
             < SolutionToBuild包括=C:\项目文件\路径\ MySolution.sln/>

            要改变的顺序的溶液构建,修改的顺序
            低于该解决方案出现。
         - >
        < SolutionToBuild包括=.. \ .. \ XX1 \ XXX \解决方案\ XXX Solution.sln/>
        < SolutionToBuild包括=.. \ .. \ XX2 \构建解决方案\ xx月xx XX建设\数据端口通用Build.sln/>
        < SolutionToBuild包括=.. \ .. \ XX3 \构建解决方案\ XXX编译\ XXX Build.sln/>
    < / ItemGroup>
    < ItemGroup>
        &所述;! - 构
            配置列表建立。至
            添加/删除配置,编辑该值。
            例如,以添加新的配置,加
            如下 - 
                < ConfigurationToBuild包括=调试| 86>
                    < FlavorToBuild>调试和LT; / FlavorToBuild>
                    < PlatformToBuild> 86< / PlatformToBuild>
                < / ConfigurationToBuild>

            在包含属性值应该是唯一的
            每个ConfigurationToBuild节点。
         - >
        < ConfigurationToBuild包括=调试|任何CPU>
            < FlavorToBuild>调试和LT; / FlavorToBuild>
            < PlatformToBuild>任何CPU< / PlatformToBuild>
        < / ConfigurationToBuild>
    < / ItemGroup>
    < ItemGroup>
        &所述;! - 试验自变量
            如果的runTest设置为true,那么
            以下测试参数将被用于运行
            试验。

            要添加/删除新testlist或选择
            元数据文件(.vsmdi)文件,编辑此
            值。对于如运行BVT1和BVT2类型
            在Helloworld.vsmdi提到的测试
            文件,添加以下 - 

            < MetaDataFile包括=C:\项目文件\的HelloWorld \ HelloWorld.vsmdi>
                < TestList> BVT1; BVT2< / TestList>
            < / MetaDataFile>

            凡BVT1和BVT2是有效的测试类型
            在HelloWorld.vsmdi文件中定义。

                MetaDataFile  - 完整路径测试元数据文件。
                TestList  - 在选定的元数据文件运行测试名单。

            请注意,您需要指定
            相对于$ vsmdi文件(SolutionRoot)
         - >
        < MetaDataFile包括=>
            < TestList> < / TestList>
        < / MetaDataFile>
    < / ItemGroup>
    < ItemGroup>
      <  - !附加参考路径
          额外的参考路径的列表中使用
          同时解析引用。

          例如,
              < AdditionalReferencePath包括=C:\ MyFolder的\/>
              < AdditionalReferencePath包括=C:\ MyFolder2 \/>
       - >
      < AdditionalReferencePath包括=.. \ .. \ XXXX \参考文件/>
      < AdditionalReferencePath包括=.. \ .. \ XXXX \构建支持\ SomeCoolLibrary/>
      < AdditionalReferencePath包括=.. \ .. \ xxxx1.1 \参考文件/>
    < / ItemGroup>
< /项目>
 

解决方案

请确保您所有的构建脚本有这样的内容:

 < ConfigurationToBuild包括=调试|任何CPU>
  < FlavorToBuild>调试和LT; / FlavorToBuild>
  < PlatformToBuild>任何CPU< / PlatformToBuild>
< / ConfigurationToBuild>
 
浙江新一轮放心消费建设工作怎么做 方案来了

和它被设置为调试

I'm hitting a weird issue with MSBuild, and I'm thinking it might just be an environment issue. We're using MSBuild to build a number of separate solutions, and it seems to work on my machine. But on a couple of other machines, it's not working.

I've tracked down the issue, and it looks like one of the solutions (or one of the projects in that solution) is being built in "Release" when everything else is being built in "Debug". This causes some of the references to be missing - so the solution being built in "Release" fails to build. I want all solutions to be built in "Debug". In the following is our current TFSBuild.proj file - what are we doing wrong?

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="DesktopBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <!-- TO EDIT BUILD TYPE DEFINITION

        To edit the build type, you will need to edit
        this file which was generated by the Create New
        Build Type wizard.  This file is under source
        control and needs to be checked out before
        making any changes.

        The file is available at -

            $/{TeamProjectName}/TeamBuildTypes/{BuildTypeName}

        where you will need to replace TeamProjectName
        and BuildTypeName with your Team Project and
        Build Type name that you created

        Checkout the file

          1. Open Source Control Explorer by selecting
             View -> Other Windows -> Source Control Explorer

          2. Ensure that your current workspace has a mapping for
             the $/{TeamProjectName}/TeamBuildTypes folder and
             that you have done a "Get Latest Version" on that
             folder

          3. Browse through the folders to
             {TeamProjectName}->TeamBuildTypes->{BuildTypeName} folder

          4. From the list of files available in this folder, right
             click on TfsBuild.Proj. Select 'Check Out For Edit...'

        Make the required changes to the file and save

        Checkin the file
          1. Right click on the TfsBuild.Proj file
             selected in Step 3 above and select
             'Checkin Pending Changes'

          2. Use the pending checkin dialog to save your
             changes to the source control

        Once the file is checked in with the
        modifications, all future builds using this
        build type will use the modified settings
    -->

    <!-- Do not edit this -->
    <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\TeamBuild\Microsoft.TeamFoundation.Build.targets" />
    <ProjectExtensions>

        <!--  DESCRIPTION
            The description is associated with a build
            type. Edit the value for making changes.
        -->
        <Description>
        </Description>

        <!--  BUILD MACHINE
            Name of the machine which will be used to
            build the solutions selected.
        -->
        <BuildMachine>xxxx-test</BuildMachine>
    </ProjectExtensions>
    <PropertyGroup>

      <!--  TEAM PROJECT
          The team project which will be built using
          this build type.
      -->
      <TeamProject>CFAST</TeamProject>

      <!--  BUILD DIRECTORY
          The directory on the build machine that will
          be used to build the selected solutions. The
          directory must be a local path on the build
          machine (e.g. c:\build).
      -->
      <BuildDirectoryPath>C:\Build\brtcn</BuildDirectoryPath>
      <SolutionRoot Condition=" '$(IsDesktopBuild)'!='true' "
      >$(BuildDirectoryPath)\w</SolutionRoot>

      <!--  DROP LOCATION
          The location to drop (copy) the built binaries
          and the log files after the build is complete.
          This location has to be a valid UNC path of
          the form \\Server\Share. The build machine
          service account and application tier account
          need to have read write permission on this
          share.
      -->
      <DropLocation>\\my-files\xx-files\Build Drop\xx</DropLocation>

      <!--  TESTING
          Set this flag to enable/disable running tests
          as a post build step.
      -->
      <RunTest>false</RunTest>
      <!--  WorkItemFieldValues
          Add/edit key value pairs to set values for
          fields in the work item created during the
          build process. Please make sure the field
          names are valid for the work item type being
          used.
      -->
      <WorkItemFieldValues>Symptom=build break;Steps To Reproduce=Start the build using Team Build</WorkItemFieldValues>
      <!--  CODE ANALYSIS
          To change CodeAnalysis behavior edit this
          value. Valid values for this can be
          Default,Always or Never.

          Default - To perform code analysis as per the individual project settings
          Always  - To always perform code analysis irrespective of project settings
          Never   - To never perform code analysis irrespective of project settings
       -->
      <RunCodeAnalysis>Never</RunCodeAnalysis>

      <!--  UPDATE ASSOCIATED WORK ITEMS
       Set this flag to enable/disable updating associated workitems on a successful build
      -->
      <UpdateAssociatedWorkItems>true</UpdateAssociatedWorkItems>
      <!-- Title for the work item created on build failure -->
      <WorkItemTitle>Build failure in build:</WorkItemTitle>
      <!-- Description for the work item created on build failure -->
      <DescriptionText>This work item was created by Team Build on a build failure.</DescriptionText>
      <!-- Text pointing to log file location on build failure -->
      <BuildlogText>The build log file is at:</BuildlogText>
      <!-- Text pointing to error/warnings file location on build failure -->
      <ErrorWarningLogText>The errors/warnings log file is at:</ErrorWarningLogText>
    </PropertyGroup>
    <ItemGroup>
        <!--  SOLUTIONS
            The path of the solutions to build. To
            add/delete solutions, edit this value. For
            example, to add a solution MySolution.sln,
            add following line -
             <SolutionToBuild Include="C:\Project Files\path\MySolution.sln" />

            To change the order in which the solutions are build, modify the order in
            which the solutions appear below.
        -->
        <SolutionToBuild Include="..\..\xx1\xxx\Solution\xxx Solution.sln" />
        <SolutionToBuild Include="..\..\xx2\Build Solutions\xx xx xx Build\Data Port Common Build.sln" />
        <SolutionToBuild Include="..\..\xx3\Build Solutions\xxx Build\xxx Build.sln" />
    </ItemGroup>
    <ItemGroup>
        <!--  CONFIGURATIONS
            The list of configurations to build. To
            add/delete configurations, edit this value.
            For example, to add a new configuration, add
            following lines -
                <ConfigurationToBuild Include="Debug|x86">
                    <FlavorToBuild>Debug</FlavorToBuild>
                    <PlatformToBuild>x86</PlatformToBuild>
                </ConfigurationToBuild>

            The Include attribute value should be unique
            for each ConfigurationToBuild node.
        -->
        <ConfigurationToBuild Include="Debug|Any CPU">
            <FlavorToBuild>Debug</FlavorToBuild>
            <PlatformToBuild>Any CPU</PlatformToBuild>
        </ConfigurationToBuild>
    </ItemGroup>
    <ItemGroup>
        <!--  TEST ARGUMENTS
            If the RunTest is set to true then the
            following test arguments will be used to run
            tests.

            To add/delete new testlist or to choose a
            metadata file (.vsmdi) file, edit this
            value. For e.g. to run BVT1 and BVT2 type
            tests mentioned in the Helloworld.vsmdi
            file, add the following -

            <MetaDataFile Include="C:\Project Files\HelloWorld\HelloWorld.vsmdi">
                <TestList>BVT1;BVT2</TestList>
            </MetaDataFile>

            Where BVT1 and BVT2 are valid test types
            defined in the HelloWorld.vsmdi file.

                MetaDataFile - Full path to test metadata file.
                TestList - The test list in the selected metadata file to run.

            Please note that you need to specify the
            vsmdi file relative to $(SolutionRoot)
        -->
        <MetaDataFile Include=" ">
            <TestList> </TestList>
        </MetaDataFile>
    </ItemGroup>
    <ItemGroup>
      <!--  ADDITIONAL REFERENCE PATH
          The list of additional reference paths to use
          while resolving references.

          For example,
              <AdditionalReferencePath Include="C:\MyFolder\" />
              <AdditionalReferencePath Include="C:\MyFolder2\" />
      -->
      <AdditionalReferencePath Include="..\..\xxxx\Reference Files" />
      <AdditionalReferencePath Include="..\..\xxxx\Build Support\SomeCoolLibrary" />
      <AdditionalReferencePath Include="..\..\xxxx1.1\Reference Files " />
    </ItemGroup>
</Project>

解决方案

Make sure that all your build scripts have this section:

<ConfigurationToBuild Include="Debug|Any CPU">
  <FlavorToBuild>Debug</FlavorToBuild>
  <PlatformToBuild>Any CPU</PlatformToBuild>
</ConfigurationToBuild>

and that it is set to "Debug".