Uploaded image for project: 'Qt Visual Studio Tools'
  1. Qt Visual Studio Tools
  2. QTVSADDINBUG-683

Build error with very long PATH

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 2.4.2
    • 2.4.1
    • Build-time integration
    • None
    • Visual Studio Professional 2017, Microsoft (R)-Build-Engine, Version 15.9.21+g9802d43bc3
    • Windows
    • 1aa30648add6d1a137232481f5f497c61861c85b

    Description

      Building with msbuild from command line may fail with the following error message, when the QtVars step is run:

      C:\Users\michael.denk\Desktop\QtVsAddinTest2>msbuild /verbosity:minimal
      Microsoft (R)-Build-Engine, Version 15.9.21+g9802d43bc3 für .NET Framework
      Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.  Reading Qt configuration (C:\dev17\Qt-5.12.5a\bin\qmake.exe)
      QtConsoleApplication1.vcxproj : error : Project ERROR: Cannot run compiler 'cl'. Output: [C:\Users\michael.denk\Desktop\QtVsAddinTest2\QtConsoleApplication1\QtConsoleApplication1.vcxproj]
      QtConsoleApplication1.vcxproj : error : =================== [C:\Users\michael.denk\Desktop\QtVsAddinTest2\QtConsoleApplication1\QtConsoleApplication1.vcxproj]
      QtConsoleApplication1.vcxproj : error : =================== [C:\Users\michael.denk\Desktop\QtVsAddinTest2\QtConsoleApplication1\QtConsoleApplication1.vcxproj]
      QtConsoleApplication1.vcxproj : error : Maybe you forgot to setup the environment? [C:\Users\michael.denk\Desktop\QtVsAddinTest2\QtConsoleApplication1\QtConsoleApplication1.vcxproj]
      

      I tracked it down to the PATH environment variable in connection with MSBuild task SetEnv: 

          <!--// Run qmake && nmake: append output to .props (XML) file -->
          <SetEnv Name="PATH" Prefix="true" Value="$(ExecutablePath)"/>
          <PropertyGroup>
            <Cmd><![CDATA[("$(QtToolsPath)\qmake.exe" && nmake qtvars) 1> qtvars.log 2>&1]]></Cmd>
          </PropertyGroup>
          <Exec WorkingDirectory="$(QtVarsWorkDir)" IgnoreExitCode="true" Command="$(Cmd)">
            <Output TaskParameter="ExitCode" PropertyName="ErrorLevel"/>
          </Exec>
      

      When PATH is very long, the SetEnv prepends $(ExecutablePath). Apparently there is [a limit of x characters (os dependent)|https://support.microsoft.com/en-us/help/830473/command-prompt-cmd-exe-command-line-string-limitation, which is different for cmd and "Windows in general".|https://support.microsoft.com/en-us/help/830473/command-prompt-cmd-exe-command-line-string-limitation].]

      Steps to reproduce:

      Create a new Console Application Project in VS, delete the intermediate directories Debug and Release. Start a cmd prompt and run your vcvarsall.bat a couple of times to let your PATH environment variable grow. Then try to run msbuild in your project directory.

      I don't really understand what the SetEnv task is good for. In my experience it basically just did "set PATH=%PATH%;%PATH%"

       

      Attachments

        1. msbuild_fail.log
          453 kB
        2. msbuild_works.log
          894 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mecfc Miguel Costa
            m.denk Michael Denk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes