在构建时,从一个dockerfile中,我得到了这个:
/usr/share/dotnet/sdk/3.1.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error MSB4018: The "ResolvePackageAssets" task failed unexpectedly. [/src/test/test.fsproj]
/usr/share/dotnet/sdk/3.1.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error MSB4018: NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder '/usr/local/share/dotnet/sdk/NuGetFallbackFolder'. [/src/test/test.fsproj]
/usr/share/dotnet/sdk/3.1.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error MSB4018: at NuGet.Packaging.FallbackPackagePathResolver..ctor(String userPackageFolder, IEnumerable`1 fallbackPackageFolders) [/src/test/test.fsproj]
/usr/share/dotnet/sdk/3.1.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error MSB4018: at Microsoft.NET.Build.Tasks.NuGetPackageResolver.CreateResolver(IEnumerable`1 packageFolders) [/src/test/test.fsproj]
/usr/share/dotnet/sdk/3.1.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error MSB4018: at Microsoft.NET.Build.Tasks.NuGetPackageResolver.CreateResolver(LockFile lockFile) [/src/test/test.fsproj]
/usr/share/dotnet/sdk/3.1.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter..ctor(ResolvePackageAssets task) [/src/test/test.fsproj]
/usr/share/dotnet/sdk/3.1.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromDisk(ResolvePackageAssets task, Byte[] settingsHash) [/src/test/test.fsproj]
/usr/share/dotnet/sdk/3.1.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader..ctor(ResolvePackageAssets task) [/src/test/test.fsproj]
/usr/share/dotnet/sdk/3.1.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups() [/src/test/test.fsproj]
/usr/share/dotnet/sdk/3.1.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore() [/src/test/test.fsproj]
/usr/share/dotnet/sdk/3.1.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute() [/src/test/test.fsproj]
/usr/share/dotnet/sdk/3.1.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/src/test/test.fsproj]
/usr/share/dotnet/sdk/3.1.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/src/test/test.fsproj]
Build FAILED.
更易读的版本是:
The "ResolvePackageAssets" task failed unexpectedly. [/src/test/test.fsproj]
NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder '/usr/local/share/dotnet/sdk/NuGetFallbackFolder'. [/src/test/test.fsproj]
at NuGet.Packaging.FallbackPackagePathResolver..ctor(String userPackageFolder, IEnumerable`1 fallbackPackageFolders) [/src/test/test.fsproj]
at Microsoft.NET.Build.Tasks.NuGetPackageResolver.CreateResolver(IEnumerable`1 packageFolders) [/src/test/test.fsproj]
at Microsoft.NET.Build.Tasks.NuGetPackageResolver.CreateResolver(LockFile lockFile) [/src/test/test.fsproj]
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter..ctor(ResolvePackageAssets task) [/src/test/test.fsproj]
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromDisk(ResolvePackageAssets task, Byte[] settingsHash) [/src/test/test.fsproj]
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader..ctor(ResolvePackageAssets task) [/src/test/test.fsproj]
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups() [/src/test/test.fsproj]
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore() [/src/test/test.fsproj]
at Microsoft.NET.Build.Tasks.TaskBase.Execute() [/src/test/test.fsproj]
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/src/test/test.fsproj]
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/src/test/test.fsproj]
Build FAILED.
这是一个正在工作的文档文件:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 as build
WORKDIR /src/
COPY . /src/
RUN dotnet build -c Release -o /app test/test.fsproj
FROM build AS publish
RUN dotnet publish -c Release -o /app --no-restore test/test.fsproj
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 as final
WORKDIR /app
COPY --from=publish /app .
CMD ["dotnet", "test.dll"]
项目Test.fsproj依赖于其他项目,但我在这里对其进行了简化,以显示哪些项目不起作用:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 as build
WORKDIR /src/
COPY test/test.fsproj ./test/
COPY test/common/libraries/mathematics/mathematics.fsproj ./test/common/libraries/mathematics/
RUN dotnet restore test/test.fsproj
COPY . /src/
RUN dotnet build -c Release -o /app test/test.fsproj
FROM build AS publish
RUN dotnet publish -c Release -o /app --no-restore test/test.fsproj
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 as final
WORKDIR /app
COPY --from=publish /app .
CMD ["dotnet", "test.dll"]
这个版本不工作。我正在尝试做的是使一个恢复,通过复制主项目和它的依赖关系,匹配文件夹布局,使docker可以使一个层留在该高速缓存中,并不经常恢复nuget包。在一个锁定区,我依赖于sim卡的互联网现在和重新下载nuget包在每一个建设是一个完全的浪费。
我不明白我得到的nuget错误。恢复工作,然后构建,就在失败之后。
5条答案
按热度按时间gopyfrb31#
有同样的问题。经过一些谷歌搜索,我发现这个很好的问题:https://github.com/dotnet/dotnet-docker/issues/2050
简单地说,答案是:如果您已经在Docker之外构建了项目,那么您将有输出文件夹,这些文件夹将被复制到Docker构建环境中,从而导致此问题。
解决方案是添加一个
.dockerignore
文件来防止这种情况发生。plicqrtu2#
我下载了一个ZIP项目,在构建它时遇到了同样的问题。这个问题通过检查nuget包的源代码-工具-〉Nuget包管理器-〉包管理器设置-〉Nuget包管理器-〉包源代码来解决
请检查套件的来源。这可能是造成问题的原因。
2nc8po8w3#
我的脑海中浮现出许多事情。
1:使用以下标记编辑csproj:
2:更新停靠文件。
dotnet sdk没有错误文件夹。
在FROM下添加RUN命令:
dw1jzc5e4#
要解决“找不到回退软件包文件夹”错误,您需要在该目录中创建一个空文件夹,如下所示:/usr/本地/共享/dotnet/sdk/新获取回退文件夹
agyaoht75#
TL;DR
我遇到了同样的问题。而且花了我2天的时间才解决。
在Visual Studio中
Tools-> Nuget Package Manager->Package Manager Setting->Package source
存在脱机包源位置。如果未找到定义为脱机包源的文件夹,则会遇到此错误。
若要解决此错误,您有两个选择:
1.创建缺少的文件夹,其中包含其脱机包,或者
1.删除脱机位置引用。
要删除脱机位置引用,请转到
C:\Program Files (x86)\NuGet\Config\
并删除软件包源配置文件,然后一切都将正常