Visual Studio 工作正常时 MSBuild 中出现错误 MSB4096
Error MSB4096 in MSBuild when Visual Studio works fine
问题
我有一个 Windows 运行时解决方案,其中包含一些 C++ 项目和 C# 项目。 Visual Studio 可以很好地构建解决方案。但是,MSBuild 不能很好地与该解决方案配合使用,并且总是以错误 MSB4096 结束。
有没有人知道如何解决它以便 MSBuild 可以像 Visual Studio 一样构建。
命令
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
错误
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.
您似乎使用 Visual Studio 2013,但在命令行上使用 MSBuild 4.0。要在此处也使用 MSBuild 12.0(内部使用 VS2013),请使用:
%Program Files(x86)%\MSBuild.0\Bin\MSBuild.exe
问题
我有一个 Windows 运行时解决方案,其中包含一些 C++ 项目和 C# 项目。 Visual Studio 可以很好地构建解决方案。但是,MSBuild 不能很好地与该解决方案配合使用,并且总是以错误 MSB4096 结束。
有没有人知道如何解决它以便 MSBuild 可以像 Visual Studio 一样构建。
命令
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
错误
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.
您似乎使用 Visual Studio 2013,但在命令行上使用 MSBuild 4.0。要在此处也使用 MSBuild 12.0(内部使用 VS2013),请使用:
%Program Files(x86)%\MSBuild.0\Bin\MSBuild.exe