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

时间:2018-02-12 19:16:37

标签: msbuild visual-studio-2017 visual-c++-2017

我刚刚将一个项目从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& #34;无法从程序集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 Community发布了此消息,但在another almost identical bug report中,他们将其关闭为"不是错误"由于我无法理解的原因。我希望StackOverflow会更有帮助。 :)

2 个答案:

答案 0 :(得分:4)

  

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

您似乎正在使用.NET框架中的旧MSBuild.exe。将项目从VS2012升级到VS2017后,应从以下位置使用MSBuild.exe:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"


xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffff"
android:orientation="vertical"
android:weightSum="1"
tools:context="com.example.administrator.myapplication.CameraTestActivity">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:layout_gravity="center"
    android:layout_weight="0.11"
    android:background="@android:color/transparent"
    android:orientation="horizontal"
    android:weightSum="1">

    <TextView
        android:id="@+id/textView9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_marginEnd="170dp"
        android:layout_marginRight="170dp"
        android:padding="15dp"
        android:text="Hello! - "
        android:textSize="20sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/userid"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="76dp"
        android:layout_marginRight="76dp"
        android:padding="5dp"
        android:text="TextView"
        android:layout_alignBaseline="@+id/textView9"
        android:layout_alignBottom="@+id/textView9"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />
</RelativeLayout>

<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:background="#ffff"
    android:text="Sign-out"
    android:textColor="#000000"
    android:textSize="15sp"
    android:textStyle="italic" />

<TextView

    android:id="@+id/textView8"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0.07"
    android:text="ASEC MOBILE SCANNER"
    android:textAlignment="center"
    android:textColor="#000000"
    android:textSize="30sp"
    android:textStyle="bold"></TextView>

<TextView
    android:id="@+id/scanText"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:layout_weight="0.07"
    android:text="Scanning..."
    android:textAlignment="center"
    android:textColor="#000000"
    android:textSize="30sp"></TextView>

<RelativeLayout
    android:layout_width="245dp"
    android:layout_height="300dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_gravity="center">


    <FrameLayout
        android:id="@+id/cameraPreview"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:background="@color/gray_btn_bg_color"
        android:visibility="visible">


    </FrameLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_alignEnd="@+id/cameraPreview"
        android:layout_alignLeft="@+id/cameraPreview"
        android:layout_alignRight="@+id/cameraPreview"
        android:layout_alignStart="@+id/cameraPreview"
        android:layout_centerVertical="true"
        android:background="@color/colorAccent" />

</RelativeLayout>

那是因为MSBuild is now part of Visual Studio!

  

从Visual Studio 2013开始,2013版MSBuild将会   作为Visual Studio的一部分而不是.NET Framework。这个   转换使我们能够更快地发展MSBuild。

希望这有帮助。

答案 1 :(得分:0)

您将必须编辑此目录中的文件:

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。