• Upgrade your Internet Experience
  • Sign in
  • Microsoft.com
  • United States (English)
    Brasil (Português)Česká republika (Čeština)Deutschland (Deutsch)España (Español)France (Français)Italia (Italiano)Россия (Русский)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語)香港特别行政區 (中文)
 
 
.NET Framework Developer Center
 
 
Home
 
 
Library
 
 
Learn
 
 
Downloads
 
 
Support
 
 
Community
 
 
Forums
 
 
 
.NET Framework Developer Center > .NET Development Forums > MSBuild > MsBuild & VCBuild task setting /useenv
Ask a questionAsk a question
Search Forums:
  • Search MSBuild Forum Search MSBuild Forum
  • Search All .NET Development Forums Search All .NET Development Forums
  • Search All MSDN Forums Search All MSDN Forums
 

AnswerMsBuild & VCBuild task setting /useenv

  • Friday, April 22, 2005 12:39 PMMark Conway Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0

    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.

    • ReplyReply
    • QuoteQuote
     

Answers

  • Thursday, April 28, 2005 9:51 PMKieran MockfordModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Vote As Helpful
    0
    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.
    • ReplyReply
    • QuoteQuote
     

All Replies

  • Friday, April 29, 2005 7:17 AMMark Conway Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    Thanks Kieran. That sounds ideal.
    Look forward to RTM.
    • ReplyReply
    • QuoteQuote
     
  • Friday, October 28, 2005 11:55 PMMacJohnMcC Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    /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.

    • ReplyReply
    • QuoteQuote
     
  • Tuesday, November 01, 2005 10:33 PMDanMoseley - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    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
    • ReplyReply
    • QuoteQuote
     
  • Friday, June 16, 2006 9:33 PMKeith HillMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0

    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.

    • ReplyReply
    • QuoteQuote
     
Need Help with Forums? (FAQ)
 
© 2009 Microsoft Corporation. All rights reserved.
Terms of Use
|
Trademarks
|
Privacy Statement