0
votes

In VS2015 I created a test C++ console application 'Kon' (New Project->Visual C++->Win32->Win32 Console Application).

If I start MSBuild with /p:OutDir parameter, it fails all the time:

*C:\examples\Kon>msbuild /p:Configuration="Release" /p:OutDir="C:\out\"

Microsoft (R) Build Engine version 14.0.25420.1 Copyright (C) Microsoft Corporation. All rights reserved. Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. Build started 5/8/2018 4:29:00 PM. Project "C:\examples\Kon\Kon.sln" on node 1 (default targets). ValidateSolutionConfiguration: Building solution configuration "Release|x64". Project "C:\examples\Kon\Kon.sln" (1) is building "C:\examples\Kon\Kon\Kon.vcxproj" (2) on node 1 (default targets). C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(31,5): error MSB4184: The expression "[System.IO.Path]::Combine(C:\examples\Kon\Kon\, C:\out"\Kon.exe)" c annot be evaluated. Illegal characters in path. [C:\examples\Kon\Kon\Kon.vcxproj] Done Building Project "C:\examples\Kon\Kon\Kon.vcxproj" (default targets) -- FAILED. Done Building Project "C:\examples\Kon\Kon.sln" (default targets) -- FAILED. Build FAILED. "C:\examples\Kon\Kon.sln" (default target) (1) -> "C:\examples\Kon\Kon\Kon.vcxproj" (default target) (2) -> C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(31,5): error MSB4184: The expression "[System.IO.Path]::Combine(C:\examples\Kon\Kon\, C:\out"\Kon.exe)" cannot be evaluated. Illegal characters in path. [C:\examples\Kon\Kon\Kon.vcxproj] 0 Warning(s) 1 Error(s) Time Elapsed 00:00:00.12*

I am getting the same error with all kinds of C++ projects including MFC and ATL, but C# projects build fine with this option.

1
Try giving OutDir parameter without double quotes like this /p:OutDir=C:\out\Pankaj Kapare
Great! It works!Alexey Starinsky

1 Answers

0
votes

If you look at

error MSB4184: The expression "[System.IO.Path]::Combine(C:\examples\Kon\Kon\, C:\out"\Kon.exe)" cannot be evaluated. Illegal characters in path.

There is double quote in middle of path. So if you remove double quotes from OutDir parameter like this /p:OutDir=C:\out then it should work as expected.