Search code examples
.net.net-corenugetnuget-package

How can I change the user path for .NET?


After changing my username and user path (e.g. /Users/) in OSX settings, when I try to use the dotnet command to install a package like dotnet new --install CelesteMod.Templates I get the following error:

[2023-01-18 16:09:16.528] [Debug] [Microsoft.TemplateEngine.Edge.Installers.NuGet.NuGetInstaller] => [Execute]: Uninstalling CelesteMod.Templates::1.0.2 failed. Details:System.IO.DirectoryNotFoundException: Could not find a part of the path '/Users/<old username>/.templateengine/packages/CelesteMod.Templates.1.0.2.nupkg'.
   at System.IO.FileSystem.DeleteFile(String fullPath)
   at Microsoft.TemplateEngine.Edge.Installers.NuGet.NuGetInstaller.UninstallAsync(IManagedTemplatePackage templatePackage, IManagedTemplatePackageProvider provider, CancellationToken cancellationToken)
Failed to install CelesteMod.Templates::1.0.2, the template package is invalid.

Solution

  • It seems like the issue lies within the .NET/NuGet template engine cache since it doesn't automatically update for some reason. I just deleted the ~/.templateengine/ folder recursively and re-downloaded all my templates using dotnet new from the CLI.