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",
"preLaunchTask": "build",
// 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": [],
"cwd": "${workspaceFolder}/src/Corsinvest.ProxmoxVE.Pepper",
// 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">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Version>1.2.1</Version>
<Version>1.3.0</Version>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>cv4pve-pepper</AssemblyName>
<Company>Corsinvest Srl</Company>
@ -19,6 +19,6 @@
<TrimmerRootAssembly Include="System.Net.WebClient" />
<!-- <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>
</Project>

View file

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