When building, from a dockerfile, I get this:
/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.
A more readable version is this:
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.
This is a WORKING dockerfile:
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"]
the project Test.fsproj has dependencies to other projects, but I simplified it here to show what doesn't work:
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"]
this version doesn't work. What I am trying to do is to make a restore, by copying the main project and its dependencies, matching the folders layout, so that docker can make one layer that stays in the cache and doesn't constantly restore nuget packages. being in a lockout area, I depend on sim cards for internet right now and re-downloading nuget packages at every build is a complete waste.
I do not understand the nuget error I am getting. The restore works and then the build, right after fails.
One is stored in C:\Program Files\dotnet\sdk\NuGetFallbackFolder , while the other is in C:\Users\user\. dotnet\NuGetFallbackFolder . Each folder weighs about 2 GB, and they contain about the same files.
The location of the default global packages folder. The default is %userprofile%\. nuget\packages (Windows) or ~/. nuget/packages (Mac/Linux).
NuGetFallbackFolder stores a cache of NuGet packages used by an SDK during the restore operation, such as when running dotnet restore or dotnet build . This folder is only used prior to . NET Core 3.0. It can't be built from source, because it contains prebuilt binary assets from nuget.org.
Had the same issue. After some Googling I found this nice issue: https://github.com/dotnet/dotnet-docker/issues/2050
To recap the answer there: if you have already built the project outside of Docker, then you will have output folders which will get copied into the Docker build environment causing this problem.
The solution is then to add a .dockerignore
file which prevents this from happening. Something small like this should do the trick:
# directories
**/bin/
**/obj/
**/out/
# files
Dockerfile*
**/*.md
I downloaded a ZIP project and on building it faced the same issue. This issue was resolved by checking the source of nuget packages- Tools->Nuget Package Manager-> Package Manager Settings-> Nuget Package Manager-> Package Sources
Check the sources of the packages. This might be causing the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With