Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
2.4.1
-
None
-
Visual Studio Professional 2017, Microsoft (R)-Build-Engine, Version 15.9.21+g9802d43bc3
-
-
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
For Gerrit Dashboard: QTVSADDINBUG-683 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
278630,2 | Ensure compiler in PATH before running qmake | dev | qt-labs/vstools | Status: MERGED | +2 | 0 |