【问题标题】:NuGet "Unable to find package" for local source本地源的 NuGet“找不到包”
【发布时间】:2022-04-16 08:03:55
【问题描述】:

这以前有效,现在无效。可能是因为我将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:

在 cmets 中,@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 上对 Roslyn 进行了 35607 次提交。

【问题讨论】:

  • 还原使用的包源似乎与 Visual Studio 中定义的不匹配。您的项目/解决方案是否定义了自己的 NuGet.Config 文件?或者它是否在其 .csproj 文件中自己定义了包源?
  • @MattWard 感谢您的评论。我根本不知道到底发生了什么。该项目是 Roslyn 编译器中的项目之一。我使用 NuGet 的唯一原因是对 .dll 的简单老式引用不起作用 - 请参见此处:stackoverflow.com/a/49101751/253938 因此,将 NuGet 与本地源一起使用是过去 3 个月有效的解决方法左右,现在这也行不通。如果包含一些线索,我会将 .csproj 文件添加到我的问题中。
  • dotnet/roslyn GitHub 存储库有自己的 NuGet.config 文件,用于清除所有全局包源 - github.com/dotnet/roslyn/blob/master/NuGet.Config#L12
  • @MattWard 再次感谢 - 我认为您正在做某事。但我仍然不明白,仍然看不到我能做些什么来解决我的问题。我的 Roslyn 文件不受版本控制,也没有链接到 GitHub 存储库 - 它们被下载为 .zip 文件,专门用于避免将它们链接到 GitHub 产生任何副作用。并且下载的文件不包含任何 nuget.config 文件。我的评论空间不足,所以我将发布一些附加信息作为对我的问题的编辑。
  • 你从哪里下载的文件?如果您的源代码中没有 NuGet.Config 文件,那么我不知道问题出在哪里。似乎您的全局 ~/.config/NuGet/NuGet.Config 文件被忽略了,并且包还原输出表明 NuGet.Config 文件在某处进行了清理,删除了您的源并添加了一组额外的源.

标签: nuget


【解决方案1】:

我在 Visual Studio for Mac 上遇到此错误。在我完全关闭 VS 并重新打开它后,它在还原时没有问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-26
    • 2016-12-08
    • 1970-01-01
    • 2013-06-13
    • 1970-01-01
    • 2019-06-25
    • 1970-01-01
    相关资源
    最近更新 更多