简体   繁体   English

dotnet还原不会提取与Visual Studio 2017相同的软件包

[英]dotnet restore doesn't pull same packages as Visual Studio 2017

I've been searching for the answer to this but so far haven't found one that has the same situation I'm having. 我一直在寻找答案,但是到目前为止,还没有找到与我一样的情况。

I have a DotNet Core 1.1.4 project and when I open the .sln project file in Visual Studio 2017 it pulls down the correct packages as soon as I open it. 我有一个DotNet Core 1.1.4项目,当我在Visual Studio 2017中打开.sln项目文件时,一旦打开它就会下拉正确的包。 However for the command line if I run the commmand 但是对于命令行,如果我运行命令

dotnet restore --force

it is not pulling down packages. 它没有拉下包裹。 Strangely enough if I pull down packages using 如果我使用

dotnet restore --packages .\packages\

it will pull down several, but it appears to be the wrong packages. 它将拉下几个,但似乎是错误的软件包。 For example, in one of the .csproj files in this solution there's a reference to System.Interactive.Async 3.0.3 but the package that downloads is 3.0.0. 例如,在此解决方案中的.csproj文件之一中,有对System.Interactive.Async 3.0.3的引用,但下载的软件包是3.0.0。 Even if I run this 即使我运行这个

dotnet restore .\folder\project.csproj

it will not pull down this package that it later complains is missing when I go to build it. 它不会删除此程序包,以后我去构建它时会抱怨它丢失了。

This behavior is very confusing because as far as I can tell dotnet restore is supposed to do the same job Visual Studio 2017 is doing when it restores packages. 这种行为非常令人困惑,因为据我所知,dotnet还原应该在还原包时执行Visual Studio 2017所做的相同工作。 The project folders do have a packages.config file but my understanding from prior searches is that dotnet restore ignores those. 项目文件夹中确实有一个packages.config文件,但是根据我以前的搜索,我了解到dotnet restore会忽略这些文件。 I've verified this reference is in the .csproj file as well the app.config file (not sure if that matters). 我已验证此引用位于.csproj文件以及app.config文件中(不确定是否重要)。

If I delete the contents of the .\\packages\\ folder and perform the dotnet restore .\\folder\\project.csproj command nothing appears in the .\\packages\\ folder even though when I open it in Visual Studio 2017 it populates there. 如果我删除。\\ packages \\文件夹的内容并执行dotnet restore。\\ folder \\ project.csproj命令,即使在Visual Studio 2017中打开它,也不会在。\\ packages \\文件夹中显示任何内容。

Why is this behavior different, and what do I need to do to get the dotnet restore command to restore the correct packages to the correct location? 为什么这种行为有所不同,我该怎么做才能获得dotnet restore命令将正确的软件包还原到正确的位置?

If it helps here's the result of my dotnet --info command: 如果有帮助,这是我的dotnet --info命令的结果:

.NET Command Line Tools (1.1.5) .NET命令行工具(1.1.5)

Product Information: 产品信息:
Version: 1.1.5 版本:1.1.5
Commit SHA-1 hash: 2b517ddd29 提交SHA-1哈希值:2b517ddd29

Runtime Environment: 运行环境:
OS Name: Windows 操作系统名称:Windows
OS Version: 6.1.7601 OS Platform: Windows 操作系统版本:6.1.7601操作系统平台:Windows
RID: win7-x64 RID:win7-x64
Base Path: C:\\Program Files\\dotnet\\sdk\\1.1.5 基本路径:C:\\ Program Files \\ dotnet \\ sdk \\ 1.1.5

Found the answer to this. 找到了答案。 I downloaded NuGet.exe from here: 我从这里下载了NuGet.exe:

https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools

Using the command 使用命令

nuget restore

installs the correct packages where dotnet restore did not. 在没有dotnet restore的地方安装正确的软件包。 I'm not sure why but it did fix my issue. 我不知道为什么,但是确实解决了我的问题。

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

相关问题 Visual Studio 2017-无法还原Nuget程序包 - Visual studio 2017 - Not able to restore Nuget packages 在Microsoft Visual Studio 2017安装程序项目中无法创建依赖于NuGet包的安装文件 - Creating installation files depended on NuGet packages doesn’t work in Microsoft Visual Studio 2017 Installer Projects Visual Studio 2017没有看到SDK - Visual Studio 2017 doesn't see SDK 无法在具有缓慢(玻利维亚)互联网的 Visual Studio for Mac 和 dotnet 核心中恢复 nuget 包 - Unable to restore nuget packages in Visual Studio for Mac & dotnet core with slow (Bolivian) internet 无法在Visual Studio 2017中使用Team Explorer进行拉取或推送 - Can't pull or push with Team Explorer in Visual Studio 2017 相同的代码不适用于 Visual Studio 2017 中我自己的项目 (strcpy) - same code doesn't work on my own project (strcpy) in visual studio 2017 Visual Studio 2017 Live Visual Tree不起作用 - Visual Studio 2017 Live Visual Tree doesn't work 如何在Visual Studio 2017中拉/合并请求? - How to pull/merge request in Visual Studio 2017? 没有安装某些程序包的Visual Studio 2017 - Visual Studio 2017 installed without some packages Visual Studio 2017不会为新项目安装软件包 - Visual Studio 2017 not installing packages for new projects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM