NuGet 錯誤 NU1105

Unable to read project information for 'ProjectFile'. The project file may be invalid or missing targets required for restore.

問題

項目檔存在,但未提供還原資訊。 請確定您使用 新的項目系統或舊版專案系統開啟專案。

解決方案

命令列

從命令行中,這可能表示檔案已損毀或 NuGet.targets 未匯入。 若要匯 NuGet.targets入 ,通常建議匯入 Microsoft.Common.targets。 若要使用 .NET Core CLI 還原方案中的專案,請使用:

dotnet restore MySolution.sln

Visual Studio

在 Visual Studio 中,錯誤可能表示目標不會匯入類似命令行案例。

錯誤也可能表示專案已卸除。

  • 如果您使用 Visual Studio 2019 或更新版本,NuGet 就能夠針對卸除的項目重複使用先前還原中的成品。 為了讓此案例能夠運作,您必須確定解決方案中目前的所有專案在 Visual Studio 中載入之前,已從命令行還原。

  • 或者,重載專案。