Initial commit
This commit is contained in:
commit
868ea48c21
|
@ -0,0 +1 @@
|
|||
tags
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "bit/taskman_dotnet",
|
||||
"description": "taskman dotnet support",
|
||||
"homepage": "https://git.bit5.ru/composer/taskman_dotnet",
|
||||
"require": {
|
||||
"php": ">=8.3"
|
||||
},
|
||||
"post-install-cmd": [
|
||||
"taskman\\DotnetSupport::install"
|
||||
],
|
||||
"autoload": {
|
||||
"classmap": ["dotnet.inc.php"]
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
namespace taskman;
|
||||
|
||||
class DotnetSupport
|
||||
{
|
||||
static function install()
|
||||
{
|
||||
dotnet_install("8.0.0");
|
||||
}
|
||||
}
|
||||
|
||||
task('dotnet_set_env_path', ['always' => true], function() {
|
||||
dotnet_set_env_path();
|
||||
});
|
||||
|
||||
task('dotnet_install', function() {
|
||||
DotnetSupport::install();
|
||||
});
|
||||
|
||||
function dotnet_install(string $version)
|
||||
{
|
||||
$has_dotnet = true;
|
||||
|
||||
$dotnet_curr_ver = "";
|
||||
try
|
||||
{
|
||||
$dotnet_curr_ver = shell_get("dotnet --version");
|
||||
print("DOTNET CURRENT VERSION: $dotnet_curr_ver\n");
|
||||
}
|
||||
catch(\Throwable $th)
|
||||
{
|
||||
$has_dotnet = false;
|
||||
}
|
||||
|
||||
if($has_dotnet && version_compare($dotnet_curr_ver, $version) >= 0)
|
||||
return;
|
||||
|
||||
print("DOTNET VERSION MISMATCH: $dotnet_curr_ver < $version\n");
|
||||
|
||||
$install_file_path = dotnet_get_installer_path();
|
||||
|
||||
$version_parts = explode('.', $version);
|
||||
$channel = $version_parts[0].'.'.$version_parts[1];
|
||||
if(is_win())
|
||||
shell("powershell -NoProfile -ExecutionPolicy unrestricted Invoke-Expression '\"$install_file_path\" -Channel $channel'");
|
||||
else
|
||||
shell("\"$install_file_path\" --channel $channel");
|
||||
}
|
||||
|
||||
function dotnet_set_env_path()
|
||||
{
|
||||
$dotnet_path = dotnet_get_path();
|
||||
if(is_win())
|
||||
putenv("PATH=$dotnet_path;".getenv('PATH'));
|
||||
else
|
||||
putenv("PATH=$dotnet_path:".getenv('PATH'));
|
||||
}
|
||||
|
||||
function dotnet_get_path()
|
||||
{
|
||||
if(is_win())
|
||||
{
|
||||
$appdata_path = getenv('LOCALAPPDATA');
|
||||
return "$appdata_path\\Microsoft\\dotnet\\";
|
||||
}
|
||||
else
|
||||
{
|
||||
return getenv("HOME")."/.dotnet/";
|
||||
}
|
||||
}
|
||||
|
||||
function dotnet_get_installer_path() : string
|
||||
{
|
||||
if(is_win())
|
||||
return __DIR__ . "/dotnet-install.ps1";
|
||||
else
|
||||
return __DIR__ . "/dotnet-install.sh";
|
||||
}
|
||||
|
Loading…
Reference in New Issue