最近下載nlog的源碼學習,打開解決方案以后無法編譯。
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets
<NETSdkError Condition="'$(_TargetFrameworkVersionWithoutV)' >= '$(NETStandardMaximumVersionExclusive)'"
ResourceName="UnsupportedTargetFrameworkVersion"
FormatArguments=".NET Standard;$(_TargetFrameworkVersionWithoutV);$(NETStandardMaximumVersionHumanReadable)"
/>
126行報錯。
the current .NET SDK does not support targeting .NET Standard 2.0. Either target .NET Standard 1.6 or lower, or use a version of the .NET SDK that supports .NET Standard 2.0
通過這句英文一直以為是 .net framework 2.0未安裝。
安裝以后引用不報錯(沒有黃色感嘆號),編譯的時候卻還是報錯。
最終谷歌找到了。
原文地址
https://stackoverflow.com/questions/45732236/the-current-net-sdk-does-not-support-targeting-net-standard-2-0-error-in-visua
安裝 .net core 2.0可以解決。
https://www.microsoft.com/net/download/core
百度很久沒答案,所以用中文記錄一下,避免大家后續繼續踩微軟的坑。