由 Github 抓回開源專案研究,用 Visual Studio 2017 編譯出現錯誤,貌似還原 NuGet Package 出錯導致,錯誤訊息為 "The given key was not present in the dictionary":

Restoring NuGet packages...
To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages during build.'
Error occurred while restoring NuGet packages: The given key was not present in the dictionary.
1>------ Build started: Project: mvp-api, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\2.0.2\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(323,5): error : Assets file 'C:\WorkRoom\blah\src\mvp-api\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
1>C:\Program Files\dotnet\sdk\2.0.2\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(165,5): error : Assets file 'C:\WorkRoom\blah\src\mvp-api\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
1>Done building project "someapi.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

錯誤訊息看到 dotnet sdk project.assets.json 等字眼,推測與 .NET Standard 有關。很好,又被迫要玩新東西了。爬文很快找到是 VS2017 15.4.3 之前版本的 Bug,我的 VS 2017 版本還停在 15.4.0,中標不意外。將 VS2017 升級到 15.5.2,錯誤隨風而逝~

解完問題有些感慨:隨著開源風氣日益蓬勃,這年頭想置身潮流之外是愈來愈難了。軟體開發總要站在巨人的肩膀上,免不了要參考 Github 專案、引用第三方元件,而開源社群的腳步何其快速,一不小心就被逼著更新開發工具、學習新技術。

熱血小新肝們開源社群向來不介意擁抱改變,甚至就是技術不斷翻新的動力來源。這年頭想不碰新東西只靠舊玩意兒度日,比起擁抱新工具新技術還需要強大的心理素質。依我看,內心深處得坐著慈禧太后才頂得住... Orz


Comments

Be the first to post a comment

Post a comment