.NET Core中的自定义“ CoreLib”?

zez*_*000 6 .net c# csproj .net-core

试图在.NET Core项目中获取自定义CoreLib以便在VS 2017中加载。这在.NET Framework中非常容易,因为您需要的只是“ NoStdLib ”,但使用.NET Core似乎需要更多的部件。我不断收到:“项目文件不完整。预期的导入丢失了。”

<?xml version="1.0" encoding="utf-8"?>
<!--<Project Sdk="Microsoft.NET.Sdk">-->
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
        <ProjectGuid>{3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>

    <!--<TargetFramework>netcoreapp2.2</TargetFramework>-->
        <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
        <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
        <ExcludeMscorlibFacade>true</ExcludeMscorlibFacade>
        <NoStdLib>true</NoStdLib>
        <NoCompilerStandardLib>true</NoCompilerStandardLib>

        <LangVersion>latest</LangVersion>
        <RootNamespace>System</RootNamespace>
  </PropertyGroup>

    <PropertyGroup>
    <AssemblyName>System.Private.CoreLib</AssemblyName>
    <AssemblyVersion>4.0.0.0</AssemblyVersion>
    <MajorVersion>4</MajorVersion>
    <MinorVersion>6</MinorVersion>
    <ExcludeAssemblyInfoPartialFile>true</ExcludeAssemblyInfoPartialFile>
  </PropertyGroup>

</Project>
Run Code Online (Sandbox Code Playgroud)

正在关闭System.Private.CoreLib.csproj在做什么,并且不确定缺少的部分是什么?删除“ Sdk =“ Microsoft.NET.Sdk” “会导致部分问题,因为我认为自定义corelib无法使用

我基于的基础是:https : //github.com/dotnet/coreclr/blob/master/src/System.Private.CoreLib/System.Private.CoreLib.csproj

有谁知道csproj的设置是什么使它起作用?我似乎找不到任何好的信息。

zez*_*000 3

感谢@PetSerAl:这正是我所需要的。.NET Core 无法启动该库(可能是因为我的原语等未完全实现),但编译了我的项目所需的所有 IL,没有错误。

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <LangVersion>latest</LangVersion>

    <!-- Prevent .NET Core 3+ from generating exe -->
    <UseAppHost>false</UseAppHost>

    <!--Disable .NET Core SDK libs-->
    <NoStdLib>true</NoStdLib>
    <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
  </PropertyGroup>

</Project>
Run Code Online (Sandbox Code Playgroud)