我使用这个
NuGet\Install-Package Microsoft.CodeAnalysis.NetAnalyzers -Version 8.0.0
命令来安装 nuget 包作为解决方案,它只是创建包文件夹,我无法在项目文件夹中看到 package.config 有什么方法可以从包管理器 cli 中执行此操作。
在 NuGet 4.0+ 中,package.config 对于包来说不再常见,而是包在项目文件中有引用,请检查您的 project.csproj,而不是在 .csproj 文件中应该有
<ItemGroup>
,您应该看到你的 <PackageReference>
它应该看起来像这样:
<ItemGroup>
<PackageReference Include="jQuery" Version="3.7.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.15" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Localization" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="6.1.0" />
<PackageReference Include="Microsoft.VisualStudio.SlowCheetah" Version="4.0.50">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MySql.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="MySqlConnector" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Select2.js" Version="4.0.13" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="toastr" Version="2.1.1" />
<PackageReference Include="ZXing.Net" Version="0.16.9" />
</ItemGroup>
您的项目也有可能包含整个文件夹以供参考,例如我的 select-2 和 toastr:
<ItemGroup>
<Folder Include="wwwroot\lib\select-2\" />
<Folder Include="wwwroot\lib\Resources\Fonts\" />
<Folder Include="wwwroot\lib\Resources\Images\" />
<Folder Include="wwwroot\lib\toastr\" />
<Folder Include="wwwroot\Resources\imgs\" />
</ItemGroup>
我相信如果你的包安装正确,你的 .csproj 中应该有这样一行
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />