[NUGET] Error NU1012: Some dependency group TFMs are missing a platform version: net5.0-windows

สำหรับ Error ตัวนี้ ผมมาเจอตอนที่ลอง pack DevExpress22 Lib จากไฟล์ .nuspec ที่ DevExpress ได้เก็บไว้ใน Office Package เพื่อเตรียมลอง Build WinApp และ WebApp ที่ใช้งาน Lib อยู่ครับ

Problem

  • เมื่อลองรันคำสั่ง dotnet pack จะเจอ Error
error MSB4068: The element <package> is unrecognized, or not supported in this context.
Error NU1012: Some dependency group TFMs are missing a platform version: net5.0-windows

Solution

.\nuget.exe pack  "C:\DevExpress22.1.3\Offline Packages\devexpress.win.design\22.1.3\devexpress.win.design.nuspec" -OutputDirectory "C:\DevExpress22.1.3\Offline Packages\nugetpk"
  • สำเร็จครับ จากรูปจะเห็นชื่อ exe เป็น nuget581.exe อันนี้ ผม rename เพื่อกันสับสนครับ
  • แถม ถ้าจะ Publish ขึ้น Package Manage ในองค์กรใช้คำสั่งประมาณนี้ได้ครับ
dotnet nuget push "*.nupkg" --api-key <<YOUR-API-KEY>> --source <YOUR-URL>

--Example
dotnet nuget push "*.nupkg" --api-key ssdsds-test-api3-key6-367514c71d8b --source http://dev.local:8081/repository/nuget-hosted/

Reference


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts to your email.