1
0
Fork 0
mirror of https://github.com/Corsinvest/cv4pve-pepper.git synced 2025-02-12 10:01:53 +00:00

Fix check version

Fix #3
This commit is contained in:
Daniele Corsini 2020-06-20 22:36:29 +02:00
parent c498d40ec8
commit 63253f2a4e
3 changed files with 30 additions and 16 deletions

2
.vscode/launch.json vendored
View file

@ -10,7 +10,7 @@
"request": "launch", "request": "launch",
"preLaunchTask": "build", "preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path. // If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Corsinvest.ProxmoxVE.Pepper/bin/Debug/netcoreapp3.0/cv4pve-pepper.dll", "program": "${workspaceFolder}/src/Corsinvest.ProxmoxVE.Pepper/bin/Debug/netcoreapp3.1/cv4pve-pepper.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/src/Corsinvest.ProxmoxVE.Pepper", "cwd": "${workspaceFolder}/src/Corsinvest.ProxmoxVE.Pepper",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console

View file

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<Version>1.2.1</Version> <Version>1.3.0</Version>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>cv4pve-pepper</AssemblyName> <AssemblyName>cv4pve-pepper</AssemblyName>
<Company>Corsinvest Srl</Company> <Company>Corsinvest Srl</Company>
@ -19,6 +19,6 @@
<TrimmerRootAssembly Include="System.Net.WebClient" /> <TrimmerRootAssembly Include="System.Net.WebClient" />
<!-- <ProjectReference Include="..\..\..\cv4pve-api-dotnet\src\Corsinvest.ProxmoxVE.Api.Shell\Corsinvest.ProxmoxVE.Api.Shell.csproj" /> --> <!-- <ProjectReference Include="..\..\..\cv4pve-api-dotnet\src\Corsinvest.ProxmoxVE.Api.Shell\Corsinvest.ProxmoxVE.Api.Shell.csproj" /> -->
<PackageReference Include="Corsinvest.ProxmoxVE.Api.Shell" Version="2.3.1" /> <PackageReference Include="Corsinvest.ProxmoxVE.Api.Shell" Version="2.5.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -10,6 +10,7 @@
* Copyright (C) 2016 Corsinvest Srl GPLv3 and CEL * Copyright (C) 2016 Corsinvest Srl GPLv3 and CEL
*/ */
using System.Diagnostics;
using System.IO; using System.IO;
using Corsinvest.ProxmoxVE.Api.Extension.Helpers; using Corsinvest.ProxmoxVE.Api.Extension.Helpers;
using Corsinvest.ProxmoxVE.Api.Shell.Helpers; using Corsinvest.ProxmoxVE.Api.Shell.Helpers;
@ -21,7 +22,7 @@ namespace Corsinvest.ProxmoxVE.Pepper
{ {
static int Main(string[] args) static int Main(string[] args)
{ {
var app = ShellHelper.CreateConsoleApp("cv4pve-pepper", var app = ShellHelper.CreateConsoleApp("cv4pve-pepper",
"Launching SPICE on Proxmox VE"); "Launching SPICE on Proxmox VE");
var optVmId = app.VmIdOrNameOption().DependOn(app, CommandOptionExtension.HOST_OPTION_NAME); var optVmId = app.VmIdOrNameOption().DependOn(app, CommandOptionExtension.HOST_OPTION_NAME);
@ -29,27 +30,40 @@ namespace Corsinvest.ProxmoxVE.Pepper
"Executable SPICE client remote viewer", "Executable SPICE client remote viewer",
CommandOptionType.SingleValue) CommandOptionType.SingleValue)
.DependOn(app, CommandOptionExtension.HOST_OPTION_NAME); .DependOn(app, CommandOptionExtension.HOST_OPTION_NAME);
optRemoteViewer.Accepts().ExistingFile(); optRemoteViewer.Accepts().ExistingFile();
app.OnExecute(() => app.OnExecute(() =>
{ {
var fileName = Path.GetTempFileName().Replace(".tmp", ".vv"); var fileName = Path.GetTempFileName().Replace(".tmp", ".vv");
var ret = SpiceHelper.CreateFileSpaceClient(app.ClientTryLogin(), var ret = SpiceHelper.CreateFileSpaceClient(app.ClientTryLogin(), optVmId.Value(), fileName);
optVmId.Value(),
fileName);
if (ret) if (ret)
{ {
var cmd = StringHelper.Quote(optRemoteViewer.Value()) +
" " +
StringHelper.Quote(fileName);
ret = ShellHelper.Execute(cmd, var process = new Process
true, {
null, StartInfo = new ProcessStartInfo()
app.Out, {
app.DryRunIsActive(), UseShellExecute = false,
app.DebugIsActive()).ExitCode == 0; CreateNoWindow = true,
RedirectStandardOutput = false,
FileName = StringHelper.Quote(optRemoteViewer.Value()),
Arguments = StringHelper.Quote(fileName)
}
};
if (app.DebugIsActive())
{
app.Out.WriteLine($"Run FileName: {process.StartInfo.FileName}");
app.Out.WriteLine($"Run Arguments: {process.StartInfo.Arguments}");
}
if (!app.DryRunIsActive())
{
process.Start();
ret = process.HasExited ? process.ExitCode == 0 : true;
}
} }
return ret ? 0 : 1; return ret ? 0 : 1;