简体   繁体   English

如何正确配置依赖项

[英]How to configure dependencies correctly

What I would basically like to know is if there is a way of knowing which versions of all the NuGet packages my project depends on/requires, so that I can configure each one accordingly. 我基本上想知道的是,是否有一种方法可以知道我的项目依赖/需要的所有NuGet软件包的哪个版本,以便我可以相应地配置每个版本。 A PowerShell command that would provide the above would be great. 可以提供上述功能的PowerShell命令会很棒。

I receive the below error when I build my solution: 构建解决方案时,我收到以下错误:

Severity Code Description Project File Line Suppression State Error The "Csc" task failed unexpectedly. 严重性代码说明项目文件行抑制状态错误“ Csc”任务意外失败。 System.TypeLoadException: Could not load type 'System.ValueTuple`3' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. System.TypeLoadException:无法从程序集“ mscorlib,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b77a5c561934e089”中加载类型“ System.ValueTuple`3”。
at Microsoft.CodeAnalysis.BuildTasks.ManagedToolTask.GenerateCommandLineCommands() at Microsoft.Build.Utilities.ToolTask.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() NBC.CMS.Cms 在Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()在Microsoft.Code.Analysis.BuildTasks.ManagedToolTask​​.GenerateCommandLineCommands()在.TaskBuilder.d__26.MoveNext()NBC.CMS.Cms

If you are using Visual Studio, you can quickly see the Dependencies and what version they are expected by the following: 如果您使用的是Visual Studio,则可以通过以下方式快速查看依赖关系以及所需的版本:

.NET-Framework Solutions .NET框架解决方案

  1. Your App.config file will show you all NuGet downloaded dependencies 您的App.config文件将向您显示所有NuGet下载的依赖项
  2. Follow Solution->Project->References for all NuGet and System dependencies 遵循解决方案->项目->所有NuGet和系统依赖项的参考

.NET-Core .NET核心

  1. Solution->Dependencies->NuGet 解决方案->依赖项-> NuGet

If you are looking for a CLI solution, try the following solutions. 如果您正在寻找CLI解决方案,请尝试以下解决方案。

Visual Studio 视觉工作室

  1. Click Tools->NuGet Package Manager->Package Manager Console 单击工具-> NuGet软件包管理器->软件包管理器控制台
  2. Once the terminal opens, type in "Get-Package" 打开终端后,输入“ Get-Package”

PowerShell (outside of Visual Studio) PowerShell(Visual Studio外部)

  1. dotnet list package YourSln.sln dotnet列表包YourSln.sln

Some answers referenced here: 这里引用了一些答案:

Get a list of all NuGet packages used in a solution 获取解决方案中使用的所有NuGet软件包的列表

How to list all installed NuGet Packages? 如何列出所有已安装的NuGet软件包?

Get-Module -listavailable

然后找到版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Visual Studio-.NET中正确配置依赖项 - How to correctly configure dependencies in Visual Studio - .NET 使用 AddHttpClient 时如何配置其他依赖 - How to configure other dependencies when using AddHttpClient 如何使用选项模式在启动时配置依赖项? - How to configure dependencies in startup using the options pattern? 如何使用 Autofac 正确配置 InstancePerTenant? - How to correctly configure InstancePerTenant using Autofac? 如何正确配置WCF REST服务终结点? - How to correctly configure a WCF REST service endpoint? 如何使用OpenCover为MSBuild正确配置SonarQube扫描仪 - How to correctly configure SonarQube Scanner for MSBuild with OpenCover 正确配置后如何解决此路由问题? - How to resolve this routing problem when configure it correctly? 在运行时确定子依赖项时如何配置容器 - How to configure container when sub dependencies are determined at runtime 如何配置EF Core连接上下文以解耦程序包依赖关系? - How to configure EF Core connection context to decouple packages dependencies? 温莎:如何配置容器时,运行时依赖参与 - Windsor: how to configure the container when runtime dependencies are involved
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM