pekspro / EF-Migrations-Script-Generator-Task

24 stars 7 forks source link

When the dotnet-ef tool is installed on the target os, but the version is incorrect, should you delete the original version and reinstall the new version? #16

Closed smockgithub closed 4 years ago

smockgithub commented 4 years ago
 // if(output.indexOf("\ndotnet-ef ") < 0) {
            if(/\sdotnet-ef\s/gm.test(output) === false) {                

                if(eftoolversion) {
                    console.log("Installing latest version of dotnet-ef as global tool.");
                }
                else {
                    console.log("Installing version " + eftoolversion + " of dotnet-ef as global tool.");
                }

                let cmdPath = tl.which('dotnet');
                tool = tl.tool(cmdPath)
                            .arg('tool')
                            .arg('install')
                            .arg('--global')
                            .arg('dotnet-ef');

                if(eftoolversion) {
                    tool = tool.arg('--version')
                                .arg(eftoolversion)
                }

                await tool.exec();
            }
            else {
                console.log("dotnet-ef is already installed.");
            }

same like shell :

targetEfToolVersion='3.0.0'

eftoolversion=`dotnet tool list --global`

str_sub=`echo $eftoolversion | grep -Po '(?<=dotnet-ef ).*(?= dotnet-ef)'`

if [ ! $str_sub ]
then
echo 'dotnet-ef is empty'
elif [ $targetEfToolVersion == $str_sub ]
then
echo 'find and do not exec anything'
else
dotnet tool uninstall dotnet-ef --global
echo 'dotnet-ef is uninstall'
fi

#dotnet tool install --global dotnet-ef --version 3.0.0
pekspro commented 4 years ago

This is a good question @smockgithub :-)

Since the tool is installed then someone already has decided to do this in the build process (probably at least). And then I assume the wanted version has been selected. Therefore I think the tool should leave it as it is.

But I have all respect for other views on this. There is no clear right or wrong on this I think.