Causes and solutions of compilation errors in Visual Studio 2017 creating. Net standard class library

Time:2021-11-30

The official version was released last month. Since then, we often receive update tips. It is estimated that there are still many problems! Of course, what attracts me most are. Net standard and. Net core.

Just recently contacted the. Net standard project and created a new class library to compile directly, but there was an error!! I’m not in a good mood immediately. My interest in it is greatly reduced!

If it’s a novice, it will make complaints about it immediately. As an old hand, I’d better calm down and see why.

Look at the last item:

The asset file “C: \ users \ newblifs \ documents \ visual studio 2017 \ projects \ testdemo \ testdemo \ obj \ project. Assets. JSON” could not be found. Run nuget package restore to generate this file. E:\ProgramData\VS2017\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets 92

This should be because the package of. Net standard is not restored, resulting in an error that even the system namespace cannot be found.

There is no netstandard.library under dependencies, but there is no problem with the project file settings:

The first reaction is to install the netstandard.library package. As a. Net standard class library, you can’t have this package, but why can’t you restore the package automatically?

Since the newly installed visual studio 2017 has not been set up, I suddenly remembered whether it is the setting problem of visual studio package management?

The open tab is really not checked!! The original default setting has changed. Visual studio 2015 is checked by default!!

According to preferences, the settings are as follows:

Recompile the project:

The result of fulfilling one’s wish has appeared. This time, you can do things at ease.

summary

Friends who have newly installed visual studio 2017, remember to take a good look at the Settings tab and add relevant settings before using it, otherwise an error will delay a lot of effort and be confused!

You can click here for more wonderful contentVisual studio 2017 development and use tutorial, for the installation tutorial of visual studio, clickVisual studio installation manualI hope you like it.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support developpaer.