簡體   English   中英

本機 NuGet 包安裝失敗

[英]Native NuGet package installation failure

我創建了兩個 NuGet 包:一個本機 (C++) NuGet 包和一個依賴於前者的常規 .NET NuGet 包; 並將兩者都部署到內部 NuGet 存儲庫。
然后我創建了一個測試 .NET 項目並成功安裝了主要的 .NET 包,而 PM 也安裝了本機包。

接下來,我嘗試將 .NET 包安裝到實際的消費者 .NET 項目中,安裝失敗並顯示錯誤消息:

無法安裝包“本機 1.0.0”。 您正在嘗試將此包安裝到項目目標“.NETFramework,Version=v4.7.1”中,但該包不包含任何與該框架兼容的程序集引用或內容文件。

這兩個項目(測試/成功和產品/不成功)確實針對.NET v4.7.1 ,都針對AnyCPU並且都使用相同的工具集。

<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <OutputType>Exe</OutputType>
    <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>

我不知道為什么安裝我的包會在產品項目中產生上述錯誤。

預先感謝大家的幫助。

然后我創建了一個測試 .NET 項目並成功安裝了主要的 .NET 包,而 PM 也安裝了本機包。

接下來,我嘗試將 .NET 包安裝到實際的消費者 .NET 項目中,安裝失敗並顯示錯誤消息:

對於這種消息the package does not contain any assembly references or content files that are compatible with that framework有許多解決方法,該the package does not contain any assembly references or content files that are compatible with that framework在線the package does not contain any assembly references or content files that are compatible with that framework 對於您的具體問題,由於一個成功,另一個沒有:

  1. 我建議先clean the nuget cache ,然后再做其他檢查。 因為當您安裝或恢復 nuget pakcages 時,它會首先嘗試在緩存中找到它。 類似的問題見這個

  2. 然后確保同一解決方案中的所有項目都使用相同的方式來管理 nuget 包。 (所有PackageReference 或所有packages.config)。 而對於VS217和更高,更推薦packageReference是:)類似的問題看這個

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM