Visual Studio 2017 csproj .NET CORE netstandard2.0 not build



>我刚刚安装了VS2017,并将我的.NET核心项目从project.json格式单向迁移到新的csproj格式。我想要的是针对多个框架,以便我可以使用较小的占用空间构建框架设计部署和独立部署。我遵循了 MS 文档中的说明,但是当我在 TargetFramework 中包含 netstandard1.6 或 netstandard2.0 时,当我尝试构建项目时,我会得到一大堆Predefined type System.Object is not definedThe type of namespace System could not be found等等。当它使用 project.json 文件时,这有效。我的csproj是

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <VersionPrefix>1.0.0.0</VersionPrefix>
    <TargetFrameworks>netcoreapp1.2;netstandard2.0</TargetFrameworks>
    <AssemblyName>App</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageId>App</PackageId>
    <RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.2' ">1.1.1</RuntimeFrameworkVersion>-->
    <NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard2.0' ">1.6.1</NetStandardImplicitPackageVersion>
    <RuntimeIdentifiers>win10-x64;android.21;android21-arm64;osx.10.12;rhel7.4;centos.7-x64;debian8-x64;ubuntu16.10-x64;fedora.26-x64;opensuse.42.1-x64</RuntimeIdentifiers>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute
  </PropertyGroup>
  <ItemGroup>
    <None Remove="App.csproj.vspscc" />
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
    <PackageReference Include="System.Threading.Thread" Version="4.3.0" />
    <PackageReference Include="Microsoft.NETCore.Runtime.CoreCLR" Version="1.1.0" />
  </ItemGroup>
</Project>

我的原始项目.json

{
  "version": "1.0.0.0",
  "buildOptions": {
    "emitEntryPoint": true
  },
  "frameworks": {
    "netcoreapp1.2": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.1.0"
        }
      }
    },
    "netstandard2.0": {
      "dependencies": {
        "NETStandard.Library": {
          "version": "1.6.1"
        },
        "System.Threading.Thread": "4.3.0",
        "Microsoft.NETCore.Runtime.CoreCLR": "1.1.0"
      }
    }
  },
  "runtimes": {
    "win10-x64": {}
    "ubuntu.16.10-x64": {},
    "centos.7-x64": {},
    "debian.8-x64": {},
    "fedora.24-x64": {},
    "opensuse.42.1-x64": {},
    "osx10.12-x64" : {}
  }
}

不知道问题是什么。我是否正在尝试做一些不受支持的事情?如果我只有netcoreapp1.2,当我做dotnet publish -c Release -r win10-x64时,我仍然得到FDD输出,而不是独立的可执行文件。我觉得使用 json 文件这更容易......我做错了什么?

当Nuget包未还原时,我收到相同的错误消息。是否已确保包已正确还原,并且在运行"dotnet 还原"时不会出现任何错误?

最新更新