简体   繁体   中英

Build error when packaging multiple nuget targets

I'm attempting to make a Nuget package for multiple framework targets (.netstandard20 and net46). I am able to build the solution and the outputs appear on disk as expected, but whenever I try to package them (Visual Studio 2019 or msbuild directly), I'm getting the following error:

error MSB4057: The target "_GetBuildOutputFilesWithTfm" does not exist in the project.

I'm not using a .nuspec file and the developer packages of my target frameworks are installed correctly.

Here's my .csproj (with nuget metadata excluded for brevity) - it's pretty basic:

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

  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
    <ReleaseVersion>1.0</ReleaseVersion>
    <PackageVersion>1.0</PackageVersion>

    ...
  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType></DebugType>
  </PropertyGroup>

  <ItemGroup Condition="'$(TargetFramework)'=='net46'">
    <PackageReference Include="NuGet.Build.Tasks.Pack" Version="5.2.0" />
  </ItemGroup>

  <ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
    <PackageReference Include="NuGet.Build.Packaging" Version="0.2.2" />
  </ItemGroup>

</Project>

Does anyone have any ideas??

Thanks

删除对NuGet.Build.Tasks.PackNuGet.Build.Packaging引用允许仅面向 .NET Standard 2.0 并获得所需的行为。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM