[英]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-x64RID: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.