MyGet から NuGet への変更

公開日 :

Sitecore が提供しているツールが利用しているパッケージマネージャが、MyGet から NuGet に変更されました。今回は影響範囲とその手順に関して紹介をします。

MyGet から NuGet へ

これまでパッケージマネージャーとして MyGet を利用していましたが、今月から NuGet に代わりました。MyGet を利用している範囲は以下の通りです。

  • Sitecore Install Framework

  • Sitecore Docker Tools

  • 各種 CLI

  • SDK モジュールなど、

今後、新しく使う場合は nuget を参照する形になるため気にならないかもしれませんが、すでに利用している場合は切り替える手続きが必要です。

MyGet の設定を削除する

まず最初に、MyGet を利用している際の SitecoreRegistory を削除します。

Unregister-PSRepository -Name SitecoreGallery

random desc

続いてモジュールをアンインストールします。

Uninstall-Module -Name SitecoreDockerTools -AllVersions

random desc

XM Cloud のプロジェクトの変更

今回は XM Cloud で記載されている設定を変更します。他の SDK などでも nuget.config のファイルがあれば、これを変更することで新しく利用することが可能になります。Package Source を以下のように変更してください。

  <packageSources>
    <clear />
    <add key="Nuget" value="https://api.nuget.org/v3/index.json" />
    <add key="Sitecore" value="https://nuget.sitecore.com/resources/v3/index.json" />
  </packageSources>

また init.ps1 で myget を読み込んでいるコードがあります。# Check for Sitecore Gallery のコードに記載されている部分を以下のように書き換えます。

# Check for Sitecore Gallery
Import-Module PowerShellGet
$SitecoreGallery = Get-PSRepository | Where-Object { $_.SourceLocation -eq "https://nuget.sitecore.com/resources/v2/" }
if (-not $SitecoreGallery) {
    Write-Host "Adding Sitecore PowerShell Gallery..." -ForegroundColor Green
    Unregister-PSRepository -Name SitecoreGallery -ErrorAction SilentlyContinue
    Register-PSRepository -Name SitecoreGallery -SourceLocation https://nuget.sitecore.com/resources/v2/ -InstallationPolicy Trusted
    $SitecoreGallery = Get-PSRepository -Name SitecoreGallery
}

新しい nuget と連携する部分はこの変更で完了となります。

まとめ

これまでブログで紹介をしてきた記事で、古いプロジェクトでは myget を利用しているケースがあります。その部分は、随時 nuget の新しい URL を利用するように変更をしてください。

参考情報