代码之家  ›  专栏  ›  技术社区  ›  Yair Halberstadt

在.NetStandard 2.0项目中生成System.ValueTuple时出错

  •  0
  • Yair Halberstadt  · 技术社区  · 7 年前

    我有一个.NetStandard项目,它使用System.ValueTuple。

    无论我是否包含System.ValueTuple nuget包,它都可以在visualstudio中正常构建。

    error CS8137: Cannot define a class or member that utilizes tuples because the compiler required type 'System.Runtime.CompilerServices.TupleElementNamesAttribute' cannot be found. Are you missing a reference?
    

    Teamcity托管在具有最新.Net核心SDK和最新.NetFramework SDK的环境中。

    以下是我的csproj供参考:

    <Project Sdk="Microsoft.NET.Sdk">
    
    <PropertyGroup>
        <TargetFrameworks>netstandard2.0</TargetFrameworks>
        <Version>$(VersionSuffix)</Version>
        <Authors>**********</Authors>
        <Product>**********</Product>
        <Description>**********</Description>
        <PackageTags>**********</PackageTags>
        <GeneratePackageOnBuild>false</GeneratePackageOnBuild>
        <Copyright>**********</Copyright>
        <PackageProjectUrl>http://**********</PackageProjectUrl>
        <PackageLicenseUrl>http://**********</PackageLicenseUrl>
        <PackageIconUrl>http://**********</PackageIconUrl>
    </PropertyGroup>
    
    <ItemGroup>
        <PackageReference Include="Google.Protobuf" Version="3.4.1" />
        <PackageReference Include="RabbitMQ.Client" Version="5.0.1" />
    </ItemGroup>
    
    <ItemGroup>
      <Folder Include="**********" />
    </ItemGroup>
    
    <ItemGroup>
      <ProjectReference Include="..\**********" />
    </ItemGroup>
    

    2 回复  |  直到 7 年前
        1
  •  1
  •   Yair Halberstadt    7 年前

    当我开始使用DotNet Restore而不是Nuget Restore时,错误消失了。

        2
  •  -1
  •   Markus Dresch    7 年前

    您很可能需要添加对System.ValueTuple.dll的引用。您可以通过从nuget安装System.ValueTuple包来实现这一点。

    推荐文章