Microsoft Developer Network > 포럼 홈 > MSBuild > MsBuild & VCBuild task setting /useenv
질문하기질문하기
 

답변됨MsBuild & VCBuild task setting /useenv

  • 2005년 4월 22일 금요일 오후 12:39Mark Conway 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    I'm replacing our Nant scripts with MSBuild for building all our projects. We rely on LIB & INCLUDE being set in the environment when building VC projects. When building these projects via the MsBuild task (i.e. building the solution), vcbuild gets invoked without the /useenv parameter, so the environment gets ignored. The VCBuild task doesn't include a Useenv property either.

    Is there a sneaky way to do this ? For now I can work around it by using the Exec task to invoke VCBuild directly, but it would be nice to write:

    <Project DefaultTargets="build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
       <ItemGroup>
          <Compile Include="project1.vcproj""/>
          <Compile
    Include="project2.csproj""/>
       </
    ItemGroup>
       <
    Target Name="build" >
          <MSBuild Projects="@(Compile)" ></MSBuild>
       </
    Target>
    </
    Project>

    ie be able to call different custom targets for a group of MsBuild files easily without worrying if they're C++, C#, etc.

답변

  • 2005년 4월 28일 목요일 오후 9:51Kieran Mockford중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    Mark,

    This is a limitation of Beta 2 (fixed for RTM). For RTM you will be able to pass the MSBuild task a property that will instruct the VCBuild task to launch with /userenv

    You'll be able to write the following (in your example):

    <MSBuild Projects="@(Compile)" Properties="VCBuildUserEnvironment=true" />

    In the mean-time, the <Exec /> task on vcbuild.exe with the /userenv switch on the command line will have to see you through until RTM.

    Hope that helps!

    Kieran
    MSBuild Team.

모든 응답

  • 2005년 4월 28일 목요일 오후 9:51Kieran Mockford중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    Mark,

    This is a limitation of Beta 2 (fixed for RTM). For RTM you will be able to pass the MSBuild task a property that will instruct the VCBuild task to launch with /userenv

    You'll be able to write the following (in your example):

    <MSBuild Projects="@(Compile)" Properties="VCBuildUserEnvironment=true" />

    In the mean-time, the <Exec /> task on vcbuild.exe with the /userenv switch on the command line will have to see you through until RTM.

    Hope that helps!

    Kieran
    MSBuild Team.
  • 2005년 4월 29일 금요일 오전 7:17Mark Conway 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Thanks Kieran. That sounds ideal.
    Look forward to RTM.
  • 2005년 10월 28일 금요일 오후 11:55MacJohnMcC 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    /userenv is an invalid command line option to vcbuild.exe It's supposed to pass /USEENV (note: no 'R').

    I had hope that the final version of Visual studio.Net 2005 would fix this. It does not.

            MSBuild.exe BEIUtilityvsn8.vcproj /t:Build /p:Configuration=Debug,Platform=Win32,VCBuildUserEnvironment=true
    Microsoft (R) Build Engine Version 2.0.50727.42
    [Microsoft .NET Framework, Version 2.0.50727.42]
    Copyright (C) Microsoft Corporation 2005. All rights reserved.

    Build started 10/28/2005 4:55:07 PM.
    __________________________________________________
    Project "H:\dev\2000\BEIUtility\BEIUtilityvsn8.vcproj" (Build target(s)):

    Target Build:
        H:\dev\2000\BEIUtility\BEIUtilityvsn8.vcproj : warning MSB4098: MSBuild is invoking VCBuild to build this project. Project-to-project references between VC++ projects (.VCPROJ) and C#/VB/VJ# proje
    cts (.CSPROJ, .VBPROJ, .VJSPROJ) are not supported by the command-line build systems when building stand-alone VC++ projects. Projects that contain such project-to-project references will fail to build. Please build the solution file containing this project instead.
        VCBuild.exe /userenv H:\dev\2000\BEIUtility\BEIUtilityvsn8.vcproj "Debug|Win32"
        vcbuild.exe : warning VCBLD6002: invalid option /userenv specified.  The option was ignored.

  • 2005년 11월 1일 화요일 오후 10:33DanMoseley - MSFT중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    MacJohnMcC,
    You're right that we shipped with this bug. It was discovered too late, unfortunately. The exact same misspelling was in the test for it, so it was passing just fine and we didn't detect it.

    Note that the VCBuild task has an AdditionalOptions property that can be used to work around this. Specifically,

    /p:VCBuildAdditionalOptions="/useenv"
    is equivalent to what
    /p:VCBuildUserEnvironment="true"
    should do.

    Dan
  • 2006년 6월 16일 금요일 오후 9:33Keith HillMVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    This bites.  I just want to let MSBuild build off the SLN file.  Is there a way to get MSBuild to build the vcproj file and inherit env vars I have exported in the parent MSBuild process?

    Ya know it would be really nice if VC project files and SLN files were also MSBuild files.  This kind of goofiness wouldn't be a problem.  The vcproj msbuild file could just use msbuild properties.