Initial commit

This commit is contained in:
Pavel Shevaev 2024-09-23 18:27:20 +03:00
commit 868ea48c21
5 changed files with 3532 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
tags

14
composer.json Normal file
View File

@ -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"]
}
}

1584
dotnet-install.ps1 vendored Executable file

File diff suppressed because it is too large Load Diff

1854
dotnet-install.sh vendored Executable file

File diff suppressed because it is too large Load Diff

79
dotnet.inc.php Normal file
View File

@ -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";
}