Dante May Code
Dante May Code

Reputation: 11247

Error MSB4096 in MSBuild when Visual Studio works fine

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.

Upvotes: 0

Views: 2658

Answers (1)

Christian.K
Christian.K

Reputation: 49220

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

Upvotes: 2

Related Questions