Microsoft.NETCore.Native.targets 未找到

Microsoft.NETCore.Native.targets was not found

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

我做到了:

  1. dotnet 新控制台
  2. dotnet 构建
  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 构建
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

我使用了 VS 2017 的 x64 Native 工具命令提示

我的设置:

dotnet --info .NET Command Line Tools (2.0.0-preview2-006080)

Product Information: Version: 2.0.0-preview2-006080 Commit SHA-1 hash: 0a89053574

Runtime Environment: OS Name: Windows OS Version: 10.0.15063 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk.0.0-preview2-006080\

Microsoft .NET Core Shared Framework Host

Version : 2.0.0-preview2-25309-07 Build : 41f5fc94eedc889f086800c23f35bf14a8c75a9f

这个Microsoft.NETCore.Native.targets是怎么回事?它似乎是一种特殊的占位符。我该如何解决上述错误?

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