Reputation: 91
dotnet workload install android
Unhandled exception: System.IO.IOException: Read-only file system : '/snap/dotnet-sdk/216/metadata'
at System.IO.FileSystem.CreateDirectory(String fullPath, UnixFileMode unixCreateMode)
at System.IO.Directory.CreateDirectory(String path)
at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallerFactory.CanWriteToDotnetRoot(String dotnetDir)
at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallerFactory.GetWorkloadInstaller(IReporter reporter, SdkFeatureBand sdkFeatureBand, IWorkloadResolver workloadResolver, VerbosityOptions verbosity, String userProfileDir, Boolean verifySignatures, INuGetPackageDownloader nugetPackageDownloader, String dotnetDir, String tempDirPath, PackageSourceLocation packageSourceLocation, RestoreActionConfig restoreActionConfig, Boolean elevationRequired)
at Microsoft.DotNet.Workloads.Workload.Install.WorkloadInstallCommand..ctor(ParseResult parseResult, IReporter reporter, IWorkloadResolver workloadResolver, IInstaller workloadInstaller, INuGetPackageDownloader nugetPackageDownloader, IWorkloadManifestUpdater workloadManifestUpdater, String dotnetDir, String userProfileDir, String tempDirPath, String version, IReadOnlyCollection`1 workloadIds, String installedFeatureBand)
at Microsoft.DotNet.Cli.WorkloadInstallCommandParser.<>c.<ConstructCommand>b__6_0(ParseResult parseResult)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.DotNet.Cli.Parser.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__17_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass15_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass7_0.<<UseExceptionHandler>b__0>d.MoveNext()
I ran the following command to install the dot net sdk : "sudo snap install dotnet-sdk --classic" , which installed dot net sdk version 7 .I then tried running the above command : ".Net workload install android"and found the above error as a result .I am using the Rider IDE.Any help on the same will be much appreciated.Thanks.
Upvotes: 4
Views: 4550
Reputation: 34053
That is because the Snap package manager creates read-only images of the things you install so it can't be tampered with. Also see here: https://askubuntu.com/a/919098
What worked better for me is installing .NET through the install script as described here: https://learn.microsoft.com/dotnet/core/install/linux-scripted-manual#scripted-install
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh --version latest
This will install the latest version which might not be the LTS version. If you want the current LTS version, don't include any parameter.
Don't forget to add the path to your DOTNET_ROOT
and PATH
environment variables. See here.
Assuming you're using Bash, open ~/.bashrc
and add
export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
You might need to execute touch ~/.bashrc
or start a new terminal window. Then you can now do dotnet --info
and it should give you the .NET info.
To install the .NET MAUI workload run: dotnet workload install maui-android
.
At the time of writing the out-of-the-box .NET MAUI project template doesn't build on Linux. This is because it tries to build the iOS and macOS targets as well. Fix it like this:
Open your csproj file and search for the <TargetFrameworks>
tag. It will have 3 entries like net7.0-android;net7.0-ios;net7.0-maccatalyst
. There is also one that has a Condition
attribute on it for Windows, you can leave that one as is.
Change the <TargetFrameworks>
tags to look like this:
<TargetFrameworks>net7.0-android</TargetFrameworks>
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
Note that where it says net7.0 it could also say net6.0 or net8.0 depending on the version that you're running.
Upvotes: 7