Unable to find fallback package folder with Windows path on Linux
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
### Describe the bug
The dotnet SDK is unable to run on Linux. A simple project that builds fine on Windows fails to build on Linux with a message like this:
```
/home/yves/.dotnet/sdk/8.0.303/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(266,5): error MSB4018:
The "ResolvePackageAssets" task failed unexpectedly.
NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder 'C:\Program Files (x86)\Microsoft
Visual Studio\Shared\NuGetPackages'.
at NuGet.Packaging.FallbackPackagePathResolver..ctor(String userPackageFolder, IEnumerable`1 fallbackPackageFol
ders)
at Microsoft.NET.Build.Tasks.NuGetPackageResolver.CreateResolver(IEnumerable`1 packageFolders)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter..ctor(ResolvePackageAssets task)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromDisk(ResolvePackageAssets task, B
yte[] settingsHash)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader..ctor(ResolvePackageAssets task)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups()
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore()
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggin
gContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
```
### To Reproduce
```
dotnet publish --tl -c Release -r linux-arm64 --self-contained
```
I'm not sure what other data to provide here. My solution has several projects and in the past, all of them failed with this error. After an undocumented change, it worked for a while. After more code editing, it now fails with only one of the projects.
I guess something is hard-coded to Windows here and that needs to be removed. Maybe a search for that wrong path in the source code of the SDK helps.
**Currently, I am blocked and cannot build my project anymore.**
Workarounds have been described to "simply create that directory" (here: "C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages"), but it didn't help here and it's unclear where and how this directory should be created. It's not a "rooted" directory by Linux terms, so where is it looked for, and how would it handle the backslashes which are escape characters in a Linux shell. So that's of no use.
### Exceptions (if any)
See description
### Further technical details
This is running in Windows 11 WSL "Ubuntu" (22.04). The .NET SDK was installed with the provided install script, not a package manager.
Output of `dotnet --info`:
```
.NET SDK:
Version: 8.0.303
Commit: 29ab8e3268
Workload version: 8.0.300-manifests.c915c39d
MSBuild version: 17.10.4+10fbfbf2e
Runtime Environment:
OS Name: ubuntu
OS Version: 22.04
OS Platform: Linux
RID: linux-x64
Base Path: /home/yves/.dotnet/sdk/8.0.303/
.NET workloads installed:
There are no installed workloads to display.
Host:
Version: 8.0.7
Architecture: x64
Commit: 2aade6beb0
.NET SDKs installed:
8.0.303 [/home/yves/.dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.7 [/home/yves/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.7 [/home/yves/.dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.