2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

macOSをCatalinaにしたらdotnet new出来なくなったのを解決した

Posted at

初投稿です。

発生した環境

  • macOS Mojave --> Catalinaにアップデートした
  • ルートディレクトリに、dotnet newで使用するテンプレートを置いている
  • dotnet CLIを使用している

goal

dotnet newを実行して、exceptionが発生しなくなること

起きる条件

  • macのルートディレクトリ配下に、dotnet new --installでインストール出来るテンプレートを置いてた
  • macOSをCatalinaにアップデートする(今回はMojaveからアップデートした)
  • アップデートの影響で、ルートディレクトリ配下に置いてたテンプレートがRelocated Itemsディレクトリに移動させられると発生

起きるとどうなるか

  • dotnet newdotnet new consoleすると、下記のexceptionが発生するようになった
  • /HogeTemplateディレクトリにテンプレートを置いていた場合、下記のようなエラーメッセージになる
Could not find a part of the path '/MyDotnetTemplates/HogeTemplate'.
   at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
   at System.IO.Enumeration.FileSystemEnumerator`1.Init()
   at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, Boolean isNormalized, EnumerationOptions options)
   at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)
   at System.IO.Enumeration.FileSystemEnumerableFactory.UserEntries(String directory, String expression, EnumerationOptions options)
   at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
   at System.IO.Directory.EnumerateFileSystemEntries(String path, String searchPattern, SearchOption searchOption)
   at Microsoft.TemplateEngine.Utils.PhysicalFileSystem.EnumerateFileSystemEntries(String directoryName, String pattern, SearchOption searchOption)
   at Microsoft.TemplateEngine.Edge.Settings.Scanner.DetermineDirectoriesToScan(String baseDir)
   at Microsoft.TemplateEngine.Edge.Settings.Scanner.Scan(String baseDir, Boolean allowDevInstall)
   at Microsoft.TemplateEngine.Edge.Settings.TemplateCache.Scan(String installDir, IReadOnlyList`1& mountPointIdsForNewInstalls, Boolean allowDevInstall)
   at Microsoft.TemplateEngine.Edge.Settings.SettingsLoader.RebuildCacheFromSettingsIfNotCurrent(Boolean forceRebuild)
   at Microsoft.TemplateEngine.Cli.New3Command.ExecuteAsync()
   at Microsoft.TemplateEngine.Cli.CommandParsing.NewCommandInputCli.<>c__DisplayClass19_0.<<OnExecute>b__0>d.MoveNext()

なぜ起きるのか

  • dotnet new --install <directory>を実行すると、使用している.NET SDKのバージョンに応じて、テンプレートが置いてあるディレクトリの絶対パスを~/.templateengine/<sdk_version>ディレクトリ以下の下記ファイルに書き込みにいく
    • en-US.templatecache.json
    • installUnitDescriptors.json
    • nugetTemplateSearchInfo.json
    • settings.json
    • templatecache.json
  • dotnet newを実行すると、インストールされているテンプレートを上記の絶対パスで探しに行く
  • macOSのアップデートでは上記ファイルの絶対パスが更新されないので、exceptionが発生した

どうしたら起きなくなる?

  • .templateengine/<sdk_version>ディレクトリ以下にある、対象テンプレートの情報を全消しする
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?