0
votes

Question

I have a Windows Runtime solution with some C++ projects and C# projects. Visual Studio builds the solution fine. However, MSBuild does not work well with the solution and always ends in Error MSB4096.

Does anyone have idea how to solve it so that MSBuild can build as well as Visual Studio.

Command

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /t:Rebuild /p:VisualStudioVersion=12.0;Platform=x86;Configuration=Debug;VCTargetsPath="C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120";OutDir=C:\Temp1\ /m /verbosity:minimal /nologo C:\Stash\Windows\xxx.sln > C:\Temp1\Log.txt

Error

Creating library ...\OutPut\M.WindowsPhone\M.WindowsPhone.lib and object ...\OutPut\M.WindowsPhone\M.WindowsPhone.exp M.WindowsPhone.vcxproj -> ...\OutPut\M.WindowsPhone\M.WindowsPhone.dll C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(1893,5): error MSB4096: The item "...\SDK\M\M\M.Shared......\BlackboardMobile\businessLogic\student\AutoSavingObserver.cpp" in item list "ClCompile" does not define a value for metadata "DefiningProjectDirectory". In order to use this metadata, either qualify it by specifying %(ClCompile.DefiningProjectDirectory), or ensure that all items in this list define a value for this metadata. [...\SDK\M\M\M.WindowsPhone\M.WindowsPhone.vcxproj] Done Building Project "...\SDK\M\M\M.WindowsPhone\M.WindowsPhone.vcxproj" (Rebuild target(s)) -- FAILED. Done Building Project "...\Student.sln" (Rebuild target(s)) -- FAILED.

1
Have you tried compiling with MSBuild 12.0 (%C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe)? Because that is what VS 2013 (12.0) uses. – Christian.K
@Christian.K Cool, it works. Please kindly reply as an answer for me to accept it. – Dante May Code

1 Answers

2
votes

You seem to use Visual Studio 2013, but on the command line use MSBuild 4.0. To use MSBuild 12.0 here as well (as does VS2013 internally), use:

%Program Files(x86)%\MSBuild\12.0\Bin\MSBuild.exe