Monday, March 6, 2023

Overcoming Sitecore CLI Plugin Installation Hurdles: Resolving "dotnet-tools.json came from another computer and might be blocked" Error in Sitecore JSS


When installing Sitecore CLI Plugins, you may receive the following error:


File .config\dotnet-tools.json came from another computer and might be blocked to help protect this computer. For more information, including how to unblock, see https://aka.ms/motw

This error occurs when the .NET tool installer detects that the dotnet-tools.json file is from a different computer. This is a security feature to help protect your computer from malicious code.

Solution

To fix this error, you can take the following steps:

Back up the dotnet-tools.json file.

Recreate the dotnet-tools.json file.

Update the content of the dotnet-tools.json file to include the Sitecore CLI Plugins that you want to install.

Run the following command to install the Sitecore CLI Plugins:

dotnet tool install sitecore.cli

Example


# Back up the `dotnet-tools.json` file

copy dotnet-tools.json dotnet-tools.json.backup


# Recreate the `dotnet-tools.json` file

new-item -itemtype file -path dotnet-tools.json


# Update the content of the `dotnet-tools.json` file

$tools = @{

    {

        "name": "Sitecore.CLI",

        "version": "5.1.25"

    }

}


Out-File -FilePath dotnet-tools.json -InputObject $tools -Encoding ascii

# Install the Sitecore CLI Plugins

Conclusion

Once you have followed these steps, you should be able to install the Sitecore CLI Plugins without any errors.

No comments:

Post a Comment