.NET Core 2.0新项目无法识别已安装的AspNetCore.Http.Extensions包
Hey Diego, I’ve run into similar NuGet package scope issues before—let’s walk through how to get your new projects recognizing that namespace properly:
Verify you’re installing the package to the new project
When you runPM> Install-Package AspNetCore.Http.Extensions -Version 1.0.0in the Package Manager Console, it only installs the package to the currently selected project in the console’s dropdown. If you added a new project after the initial install, you need to target it explicitly:PM> Install-Package AspNetCore.Http.Extensions -Version 1.0.0 -ProjectName YourNewProjectNameReplace
YourNewProjectNamewith the exact name of your newly added project.Check the new project’s target framework
Make sure your new project is targeting a framework compatible with AspNetCore.Http.Extensions 1.0.0. For .NET Core 2.0 solutions:- Console projects should target
netcoreapp2.0 - Class libraries should target
netstandard2.0
You can confirm this by right-clicking the project → Properties → Application → Target Framework.
- Console projects should target
Manually add the package reference if needed
If the install command still isn’t working, open your new project’s.csprojfile and add this line inside the<ItemGroup>section that contains other package references:<PackageReference Include="AspNetCore.Http.Extensions" Version="1.0.0" />Save the file, then right-click the project → Reload Project.
Clean and restore NuGet packages
Sometimes cached package data causes recognition issues. Try these steps:- Right-click your solution → Clean Solution
- Right-click your solution → Restore NuGet Packages
- Rebuild the entire solution
If you run into a specific error message when re-running the install command, feel free to share it and we can narrow things down further!
内容的提问来源于stack exchange,提问作者Diego

