首页 > 解决方案 > 本地源的 NuGet“找不到包”

问题描述

这以前有效,现在无效。可能是因为我将 Visual Studio 升级到了 15.7.4,可能是因为我完全替换了提供本地包源的项目,可能……是的,谁知道呢?

这是我的本地来源的设置。(我暂时取消选择 nuget.org 以试图减少混乱 - 徒劳无功。)

在此处输入图像描述

本地 NuGet 包的路径必须正确,因为当我选择本地包源时,包会显示正确的版本信息。

在此处输入图像描述

但是当我选择一个项目并单击Install它时,会显示以下输出:

Restoring packages for E:\Roslyn\35607\Current\src\Compilers\Core\Portable\CodeAnalysis.csproj...
  GET https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-coreclr/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  GET https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-core/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-coreclr/nuget/v3/flatcontainer/merlinia.yackscore/index.json 826ms
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-core/nuget/v3/flatcontainer/merlinia.yackscore/index.json 772ms
  GET https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-corefxtestdata/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  GET https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-buildtools/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-corefxtestdata/nuget/v3/flatcontainer/merlinia.yackscore/index.json 799ms
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-buildtools/nuget/v3/flatcontainer/merlinia.yackscore/index.json 810ms
  GET https://dotnetmyget.blob.core.windows.net/artifacts/symreader/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  GET https://dotnetmyget.blob.core.windows.net/artifacts/symreader-portable/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/symreader/nuget/v3/flatcontainer/merlinia.yackscore/index.json 1000ms
  GET https://dotnetmyget.blob.core.windows.net/artifacts/symreader-converter/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/symreader-portable/nuget/v3/flatcontainer/merlinia.yackscore/index.json 893ms
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/symreader-converter/nuget/v3/flatcontainer/merlinia.yackscore/index.json 798ms
  GET https://dotnetmyget.blob.core.windows.net/artifacts/symreader-native/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/symreader-native/nuget/v3/flatcontainer/merlinia.yackscore/index.json 791ms
  GET https://dotnetmyget.blob.core.windows.net/artifacts/metadata-tools/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/metadata-tools/nuget/v3/flatcontainer/merlinia.yackscore/index.json 869ms
  GET https://dotnetmyget.blob.core.windows.net/artifacts/interactive-window/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  GET https://dotnetmyget.blob.core.windows.net/artifacts/roslyn-master-nightly/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/interactive-window/nuget/v3/flatcontainer/merlinia.yackscore/index.json 851ms
  GET https://dotnetmyget.blob.core.windows.net/artifacts/roslyn-tools/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/roslyn-master-nightly/nuget/v3/flatcontainer/merlinia.yackscore/index.json 1016ms
  GET https://dotnetmyget.blob.core.windows.net/artifacts/roslyn-analyzers/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/roslyn-tools/nuget/v3/flatcontainer/merlinia.yackscore/index.json 798ms
  GET https://dotnetmyget.blob.core.windows.net/artifacts/roslyn/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/roslyn-analyzers/nuget/v3/flatcontainer/merlinia.yackscore/index.json 858ms
  GET https://www.myget.org/F/vs-devcore/api/v3/flatcontainer/merlinia.yackscore/index.json
  GET https://www.myget.org/F/vs-editor/api/v3/flatcontainer/merlinia.yackscore/index.json
  NotFound https://www.myget.org/F/vs-devcore/api/v3/flatcontainer/merlinia.yackscore/index.json 161ms
  NotFound https://www.myget.org/F/vs-editor/api/v3/flatcontainer/merlinia.yackscore/index.json 125ms
  NotFound https://dotnetmyget.blob.core.windows.net/artifacts/roslyn/nuget/v3/flatcontainer/merlinia.yackscore/index.json 763ms
  GET https://ddmygetsg2.blob.core.windows.net/artifacts/vssdk/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  GET https://ddmygetsg2.blob.core.windows.net/artifacts/vs-impl/nuget/v3/flatcontainer/merlinia.yackscore/index.json
  NotFound https://ddmygetsg2.blob.core.windows.net/artifacts/vssdk/nuget/v3/flatcontainer/merlinia.yackscore/index.json 823ms
  GET https://api.nuget.org/v3-flatcontainer/merlinia.yackscore/index.json
  NotFound https://api.nuget.org/v3-flatcontainer/merlinia.yackscore/index.json 754ms
  NotFound https://ddmygetsg2.blob.core.windows.net/artifacts/vs-impl/nuget/v3/flatcontainer/merlinia.yackscore/index.json 996ms
NU1101: Unable to find package Merlinia.YacksCore. No packages exist with this id in source(s): https://api.nuget.org/v3/index.json, https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json, https://dotnet.myget.org/F/dotnet-core/api/v3/index.json, https://dotnet.myget.org/F/dotnet-coreclr/api/v3/index.json, https://dotnet.myget.org/F/dotnet-corefxtestdata/api/v3/index.json, https://dotnet.myget.org/F/interactive-window/api/v3/index.json, https://dotnet.myget.org/F/metadata-tools/api/v3/index.json, https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json, https://dotnet.myget.org/F/roslyn-master-nightly/api/v3/index.json, https://dotnet.myget.org/F/roslyn-tools/api/v3/index.json, https://dotnet.myget.org/F/roslyn/api/v3/index.json, https://dotnet.myget.org/F/symreader-converter/api/v3/index.json, https://dotnet.myget.org/F/symreader-native/api/v3/index.json, https://dotnet.myget.org/F/symreader-portable/api/v3/index.json, https://dotnet.myget.org/F/symreader/api/v3/index.json, https://myget.org/F/vs-devcore/api/v3/index.json, https://myget.org/F/vs-editor/api/v3/index.json, https://vside.myget.org/F/vs-impl/api/v3/index.json, https://vside.myget.org/F/vssdk/api/v3/index.json
Package restore failed. Rolling back package changes for 'CodeAnalysis'.
Time Elapsed: 00:00:15.5163462
========== Finished ==========

我不明白为什么 NuGet 会在这么多奇怪的地方寻找我的包,我不明白为什么它不在它所在的本地文件夹中寻找它。(正如我上面提到的,这一直有效到今天。)

顺便说一句,我已经尝试过使用"Clear All NuGet Cache(s)",并且我已经重新启动了我的电脑。

编辑:

如果我使用Package Manager Console并输入以下命令:

install-package merlinia.yackscore -source "E:\Yacks\YacksCore\YacksCore\bin\Debug\"

我收到此错误消息:

The 'Source' parameter is not respected for the transitive package management based project(s) CodeAnalysis. The enabled sources in your NuGet configuration will be used.

当我查看文件时,C:\Users\rp\AppData\Roaming\NuGet\NuGet.Config我看到了这个,这对我来说是正确的:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="YacksCore" value="E:\Yacks\YacksCore\YacksCore\bin\Debug\" />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
  <disabledPackageSources>
    <add key="nuget.org" value="true" />
    <add key="Microsoft Visual Studio Offline Packages" value="true" />
    <add key="Microsoft and .NET" value="true" />
  </disabledPackageSources>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <bindingRedirects>
    <add key="skip" value="False" />
  </bindingRedirects>
  <packageManagement>
    <add key="format" value="1" />
    <add key="disabled" value="False" />
  </packageManagement>
</configuration>

我真的希望有人能告诉我出了什么问题。

编辑2:

这是我无法让它接受我的本地 NuGet 包的项目之一的 .csproj 文件,以防万一这有帮助。

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c)  Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information. -->
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <Platform Condition="'$(Platform)' == ''">AnyCPU</Platform>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <OutputType>Library</OutputType>
    <RootNamespace>Microsoft.CodeAnalysis</RootNamespace>
    <AssemblyName>Microsoft.CodeAnalysis</AssemblyName>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <TargetFramework>netstandard1.3</TargetFramework>
    <ServiceablePackage>true</ServiceablePackage>
    <DefineConstants>$(DefineConstants);COMPILERCORE</DefineConstants>
    <CodeAnalysisRuleSet>..\CodeAnalysisRules.ruleset</CodeAnalysisRuleSet>
    <NoStdLib>true</NoStdLib>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
    <LangVersion>7.2</LangVersion>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" />
  <ItemGroup>
    <Content Include="$(NuGetPackageRoot)\microsoft.diasymreader.native\$(MicrosoftDiaSymReaderNativeVersion)\runtimes\win\native\Microsoft.DiaSymReader.Native.x86.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Visible>false</Visible>
    </Content>
    <Content Include="$(NuGetPackageRoot)\microsoft.diasymreader.native\$(MicrosoftDiaSymReaderNativeVersion)\runtimes\win\native\Microsoft.DiaSymReader.Native.amd64.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="..\..\Shared\CoreClrShim.cs" Link="InternalUtilities\CoreClrShim.cs" />
    <Compile Include="..\..\Shared\DesktopShim.cs">
      <Link>DesktopShim.cs</Link>
    </Compile>
    <Compile Update="CodeAnalysisResources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>CodeAnalysisResources.resx</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="LiteDB" Version="4.1.3" />
    <PackageReference Include="Microsoft.DiaSymReader.Native" Version="$(MicrosoftDiaSymReaderNativeVersion)" />
    <PackageReference Include="System.Diagnostics.FileVersionInfo" Version="$(SystemDiagnosticsFileVersionInfoVersion)" />
    <PackageReference Include="System.Threading.Thread" Version="4.3.0" />
    <PackageReference Include="System.Xml.XmlDocument" Version="$(SystemXmlXmlDocumentVersion)" />
    <PackageReference Include="System.Xml.XPath.XDocument" Version="$(SystemXmlXPathXDocumentVersion)" />
    <PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" />
    <PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" />
    <PackageReference Include="System.Text.Encoding.CodePages" Version="$(SystemTextEncodingCodePagesVersion)" />
    <PackageReference Include="System.Threading.Tasks.Extensions" Version="$(SystemThreadingTasksExtensionsVersion)" />
    <PackageReference Include="System.ValueTuple" Version="$(SystemValueTupleVersion)" />
  </ItemGroup>
  <ItemGroup>
    <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp" />
    <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic" />
    <InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler" />
    <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler" />
    <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ExpressionCompiler" />
    <InternalsVisibleTo Include="csc" />
    <InternalsVisibleTo Include="csi" />
    <InternalsVisibleTo Include="Microsoft.CodeAnalysis.Scripting" />
    <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.Scripting" />
    <InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.Scripting" />
    <InternalsVisibleTo Include="vbc" />
    <InternalsVisibleTo Include="vbi" />
    <InternalsVisibleTo Include="Microsoft.CodeAnalysis.CompilerServer" />
    <InternalsVisibleTo Include="Microsoft.Build.Tasks.CodeAnalysis" />
    <InternalsVisibleTo Include="VBCSCompiler" />
    <InternalsVisibleTo Include="VBCSCompilerPortable" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.CommandLine.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.Emit.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.WinRT.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.EnC.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.Semantic.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.Symbol.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.Syntax.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.Test.Utilities" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.Test.Utilities.Desktop" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.VisualBasic.CommandLine.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.VisualBasic.Emit.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.VisualBasic.EnC.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.VisualBasic.Semantic.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.VisualBasic.Symbol.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.VisualBasic.Syntax.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.VisualBasic.Test.Utilities" />
    <InternalsVisibleToTest Include="Roslyn.DebuggerVisualizers" />
    <InternalsVisibleToTest Include="Roslyn.Diagnostics.Analyzers.FxCop.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Diagnostics.Analyzers.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Diagnostics.Test.Utilities" />
    <InternalsVisibleToTest Include="Roslyn.ExpressionEvaluator.CSharp.ExpressionCompiler.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.ExpressionEvaluator.VisualBasic.ExpressionCompiler.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.ExpressionEvaluator.ExpressionCompiler.Test.Utilities" />
    <InternalsVisibleToTest Include="Roslyn.InteractiveHost.UnitTests" />
    <InternalsVisibleToTest Include="Microsoft.CodeAnalysis.Scripting.UnitTests" />
    <InternalsVisibleToTest Include="Microsoft.CodeAnalysis.Scripting.Desktop.UnitTests" />
    <InternalsVisibleToTest Include="Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests" />
    <InternalsVisibleToTest Include="Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests" />
    <InternalsVisibleToTest Include="Microsoft.CodeAnalysis.VisualBasic.Scripting.UnitTests" />
    <InternalsVisibleToTest Include="Microsoft.CodeAnalysis.VisualBasic.Scripting.Desktop.UnitTests" />
    <InternalsVisibleToTest Include="Roslyn.Test.Utilities.CoreClr" />
    <InternalsVisibleToTest Include="Roslyn.Test.Utilities.Desktop" />
    <InternalsVisibleToTest Include="Roslyn.Test.Utilities.FX45" />
    <InternalsVisibleToTest Include="Roslyn.Test.Utilities" />
    <InternalsVisibleToTest Include="Roslyn.Test.PdbUtilities" />
    <InternalsVisibleToTest Include="Roslyn.Compilers.CompilerServer.UnitTests" />
    <InternalsVisibleToMoq Include="DynamicProxyGenAssembly2" />
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Update="CodeAnalysisResources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <SubType>Designer</SubType>
      <LastGenOutput>CodeAnalysisResources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    <EmbeddedResource Include="Resources\default.win32manifest" />
  </ItemGroup>
  <ItemGroup>
    <None Include="..\CodeAnalysisRules.ruleset">
      <SubType>Designer</SubType>
    </None>
    <None Include="RuleSet\RuleSetSchema.xsd">
      <SubType>Designer</SubType>
    </None>
    <PublicAPI Include="PublicAPI.Shipped.txt" />
    <PublicAPI Include="PublicAPI.Unshipped.txt" />
  </ItemGroup>
  <Import Project="..\AnalyzerDriver\AnalyzerDriver.projitems" Label="Shared" />
  <Import Project="..\..\..\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems" Label="Shared" />
  <Import Project="..\..\..\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems" Label="Shared" />
</Project>

编辑 3:

在评论中@MattWard 表明我的问题与我试图将我的 NuGet 包添加到的 Visual Studio 项目是编译 Roslyn 部分的项目有关。但是我的 Roslyn 源文件不受版本控制,也没有链接到 GitHub 存储库 - 它们被下载为 .zip 文件,专门用于避免将它们链接到 GitHub 产生任何副作用。并且下载的文件不包含任何nuget.config文件。

但是在下载的 Roslyn 源文件中搜索nuget.config文件时,我注意到有两个NuGet.Configuration.dll文件。它们分别为 E:\Roslyn\35607\Current\Binaries\Tools\dotnet\sdk\2.1.300-rtm-008866(198 KB) 和E:\Roslyn\35607\Current\Binaries\Tools\dotnet\sdk\2.1.300-rtm-008866\Sdks\Microsoft.NET.Sdk\tools\net46(86 KB)。

Roslyn 文件于 6 月 9 日下载,当时在 GitHub 上有 35607 次向 Roslyn 提交。

标签: nuget

解决方案


我在 Visual Studio for Mac 上遇到了这个错误。在我完全关闭 VS 并重新打开它之后,恢复它就没有问题了。


推荐阅读