找不到Microsoft.NETCore.Native.targets

时间:2017-05-19 10:37:04

标签: .net-core visual-studio-2017 .net-core-rc2

我正在尝试“Compiling source to native code using the ILCompiler”。

我做了:

  1. dotnet new console
  2. dotnet build
  3. 将csproj更改为

    <PropertyGroup>
      <OutputType>Exe</OutputType>
      <TargetFramework>netcoreapp1.0</TargetFramework>
    </PropertyGroup>
    
    <Import Project="$(MSBuildSDKsPath)\Microsoft.NET.Sdk\Sdk\Sdk.targets" />
    <Import Project="$(IlcPath)\Microsoft.NETCore.Native.targets" />
    

    1. set IlcPath=C:\Users\Documents\Visual Studio 2017\Projects\testproject\bin\Debug\netcoreapp1.0
    2. dotnet build
  4. Microsoft (R) Build Engine version 15.3.117.23532
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    C:\Users\Documents\Visual Studio 2017\Projects\testproject\testproject.csproj(9,3): error MSB4019: The imported project "C:\Users\Documents\Visual Studio 2017\Projects\testproject\bin\Debug\netcoreapp1.0\Microsoft.NETCore.Native.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
    
    Build FAILED.
    
    C:\Users\Documents\Visual Studio 2017\Projects\testproject\testproject.csproj(9,3): error MSB4019: The imported project "C:\Users\Documents\Visual Studio 2017\Projects\testproject\bin\Debug\netcoreapp1.0\Microsoft.NETCore.Native.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
        0 Warning(s)
        1 Error(s)
    
    Time Elapsed 00:00:00.17
    

    我使用x64 NAtive Tools Command PRompt for VS 2017

    我的设置:

      

    dotnet --info .NET命令行工具(2.0.0-preview2-006080)

         

    产品信息:版本:2.0.0-preview2-006080   提交SHA-1哈希:0a89053574

         

    运行时环境:操作系统名称:Windows操作系统版本:10.0.15063   操作系统平台:Windows RID:win10-x64基本路径:C:\ Program   文件\ DOTNET \ SDK \ 2.0.0-preview2-006080 \

         

    Microsoft .NET核心共享框架主机

         

    版本:2.0.0-preview2-25309-07构建:   41f5fc94eedc889f086800c23f35bf14a8c75a9f

    关于这个Microsoft.NETCore.Native.targets的问题?它似乎是一种特殊的占位符。如何修复上述错误?

1 个答案:

答案 0 :(得分:0)

IlcPath意味着要设置为CoreRT(C:\path_to_your\corert\bin\Product\Windows_NT.x64.Debug\packaging\publish1)版本的输出,而不是您自己的应用。您需要克隆并构建CoreRT才能使其正常工作。