簡體   English   中英

Microsoft.Build.CPPTasks.Common找不到Microsoft.Build.Tasks.Core

[英]Microsoft.Build.CPPTasks.Common cannot find Microsoft.Build.Tasks.Core

我剛剛將一個項目從Visual C ++ 2012升級到Visual C ++ 2017,我從MSBuild得到了構建失敗:

C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ Professional \\ Common7 \\ IDE \\ VC \\ VCTargets \\ Microsoft.Cpp.Current.targets(64,5):錯誤MSB4062:無法加載“SetEnv”任務從程序集C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ Professional \\ Common7 \\ IDE \\ VC \\ VCTargets \\ Microsoft.Build.CppTasks.Common.dll。 無法加載文件或程序集'Microsoft.Build.Utilities.Core,Version = 15.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或其依賴項之一。 該系統找不到指定的文件。 確認聲明是否正確,程序集及其所有依賴項是否可用,以及該任務是否包含實現Microsoft.Build.Framework.ITask的公共類。 [C:\\ SRC \\ MY-project.vcxproj]

Fusion日志顯示不好的事情:

*** Assembly Binder Log Entry  (2/12/2018 @ 1:44:29 PM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Build.Utilities.Core, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 (Fully-specified)
LOG: Appbase = file:///C:/windows/Microsoft.NET/Framework/v4.0.30319/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = msbuild.exe
Calling assembly : Microsoft.Build.CPPTasks.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Build.Utilities.Core, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/windows/Microsoft.NET/Framework/v4.0.30319/Microsoft.Build.Utilities.Core.DLL.
LOG: Attempting download of new URL file:///C:/windows/Microsoft.NET/Framework/v4.0.30319/Microsoft.Build.Utilities.Core/Microsoft.Build.Utilities.Core.DLL.
LOG: Attempting download of new URL file:///C:/windows/Microsoft.NET/Framework/v4.0.30319/Microsoft.Build.Utilities.Core.EXE.
LOG: Attempting download of new URL file:///C:/windows/Microsoft.NET/Framework/v4.0.30319/Microsoft.Build.Utilities.Core/Microsoft.Build.Utilities.Core.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/VC/VCTargets/Microsoft.Build.Utilities.Core.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/VC/VCTargets/Microsoft.Build.Utilities.Core/Microsoft.Build.Utilities.Core.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/VC/VCTargets/Microsoft.Build.Utilities.Core.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/VC/VCTargets/Microsoft.Build.Utilities.Core/Microsoft.Build.Utilities.Core.EXE.
LOG: All probing URLs attempted and failed.

剛剛在Visual Studio社區發布了這個,但在另一個幾乎相同的錯誤報告中,他們將其關閉為“Not a Bug”,原因是我無法理解。 我希望StackOverflow會更有幫助。 :)

Microsoft.Build.CPPTasks.Common找不到Microsoft.Build.Tasks.Core

您似乎正在使用.NET框架中的舊MSBuild.exe。 將項目從VS2012升級到VS2017后,應從以下位置使用MSBuild.exe:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe

那是因為MSBuild現在是Visual Studio的一部分!

從Visual Studio 2013開始,2013版本的MSBuild將作為Visual Studio的一部分而非.NET Framework發布。 這種轉變使我們能夠更快地發展MSBuild。

希望這可以幫助。

您必須編輯此目錄中的文件:

C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ Community \\ Common7 \\ IDE \\ VC \\ VCTargets

所謂的:

Microsoft.Cpp.Clang.targets

將第17行編輯為:

<UsingTask TaskName="ClangCompile" AssemblyFile="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.Build.CppTasks.Common.dll"/>

如果這確實產生了您可能需要安裝正確的MSBuild的其他問題,請注意。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM