打包多个 nuget 目标时构建错误
Build error when packaging multiple nuget targets
我正在尝试为多个框架目标(.netstandard20 和 net46)制作一个 Nuget 包。我能够构建解决方案并且输出按预期出现在磁盘上,但是每当我尝试打包它们时(Visual Studio 2019 或直接使用 msbuild),我都会收到以下错误:
error MSB4057: The target "_GetBuildOutputFilesWithTfm" does not exist in the project.
我没有使用 .nuspec 文件,并且我的目标框架的开发包已正确安装。
这是我的 .csproj(为简洁起见,排除了 nuget 元数据)- 它非常基本:
<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>
有没有人有什么想法??
谢谢
删除对 NuGet.Build.Tasks.Pack
和 NuGet.Build.Packaging
的引用允许仅针对 .NET Standard 2.0 并获得所需的行为。
我正在尝试为多个框架目标(.netstandard20 和 net46)制作一个 Nuget 包。我能够构建解决方案并且输出按预期出现在磁盘上,但是每当我尝试打包它们时(Visual Studio 2019 或直接使用 msbuild),我都会收到以下错误:
error MSB4057: The target "_GetBuildOutputFilesWithTfm" does not exist in the project.
我没有使用 .nuspec 文件,并且我的目标框架的开发包已正确安装。
这是我的 .csproj(为简洁起见,排除了 nuget 元数据)- 它非常基本:
<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>
有没有人有什么想法??
谢谢
删除对 NuGet.Build.Tasks.Pack
和 NuGet.Build.Packaging
的引用允许仅针对 .NET Standard 2.0 并获得所需的行为。