Build PSProxmox.dll and fix compilation issues

This commit is contained in:
Alphaeus Mote
2025-04-28 14:35:22 -04:00
parent 2385442c83
commit 7889ba2f97
9 changed files with 244 additions and 12 deletions
+81
View File
@@ -0,0 +1,81 @@
# Contributing to PSProxmox
Thank you for your interest in contributing to PSProxmox! This document provides guidelines and instructions for contributing.
## Code of Conduct
By participating in this project, you agree to abide by the [Code of Conduct](CODE_OF_CONDUCT.md).
## How Can I Contribute?
### Reporting Bugs
This section guides you through submitting a bug report. Following these guidelines helps maintainers understand your report, reproduce the behavior, and find related reports.
- Use the bug report template when creating an issue
- Include detailed steps to reproduce the problem
- Describe the behavior you observed and what you expected to see
- Include PowerShell and Proxmox VE version information
### Suggesting Enhancements
This section guides you through submitting an enhancement suggestion, including completely new features and minor improvements to existing functionality.
- Use the feature request template when creating an issue
- Provide a clear and detailed explanation of the feature you want
- Explain why this enhancement would be useful to most PSProxmox users
### Pull Requests
- Fill in the required template
- Follow the C# and PowerShell style guides
- Include tests for new features or bug fixes
- Update documentation as needed
- End all files with a newline
## Development Workflow
1. Fork the repository
2. Create a new branch for your changes
3. Make your changes
4. Add or update tests as needed
5. Run tests to ensure they pass
6. Update documentation as needed
7. Submit a pull request
## Style Guides
### Git Commit Messages
- Use the present tense ("Add feature" not "Added feature")
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the first line to 72 characters or less
- Reference issues and pull requests liberally after the first line
### C# Style Guide
- Follow the [Microsoft C# Coding Conventions](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions)
- Use 4 spaces for indentation
- Use camelCase for private fields and parameters
- Use PascalCase for public/protected properties and methods
- Add XML documentation comments for all public members
### PowerShell Style Guide
- Follow the [PowerShell Best Practices and Style Guide](https://github.com/PoshCode/PowerShellPracticeAndStyle)
- Use proper verb-noun naming for cmdlets
- Include comment-based help for all cmdlets
- Use pipeline input where appropriate
## Testing
- Write tests for all new features and bug fixes
- Run tests before submitting a pull request
- Ensure all tests pass
## Documentation
- Update the README.md with details of changes to the interface
- Update the CHANGELOG.md with details of changes
- Update XML documentation comments for all public members
- Update comment-based help for all cmdlets
+6 -6
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Management.Automation;
@@ -78,7 +79,7 @@ namespace PSProxmox.Client
}
string url = $"{_connection.ApiUrl}/{endpoint}";
// Log the URL if verbose is enabled
if (_cmdlet != null)
{
@@ -89,7 +90,7 @@ namespace PSProxmox.Client
var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = method;
request.Headers.Add("Cookie", $"PVEAuthCookie={_connection.Ticket}");
if (method != "GET")
{
request.Headers.Add("CSRFPreventionToken", _connection.CSRFPreventionToken);
@@ -104,10 +105,9 @@ namespace PSProxmox.Client
// Add parameters for POST/PUT requests
if (parameters != null && (method == "POST" || method == "PUT"))
{
string postData = string.Join("&", Array.ConvertAll(
parameters.Keys.ToArray(),
key => $"{Uri.EscapeDataString(key)}={Uri.EscapeDataString(parameters[key])}"
));
string postData = string.Join("&",
parameters.Keys.Select(key => $"{Uri.EscapeDataString(key)}={Uri.EscapeDataString(parameters[key])}")
);
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
+8 -2
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using PSProxmox.Client;
using PSProxmox.Session;
@@ -14,7 +15,7 @@ namespace PSProxmox.Cmdlets
/// <code>Leave-ProxmoxCluster -Connection $connection -Force</code>
/// </example>
/// </summary>
[Cmdlet(VerbsCommon.Leave, "ProxmoxCluster", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)]
[Cmdlet("Leave", "ProxmoxCluster", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)]
public class LeaveProxmoxClusterCmdlet : PSCmdlet
{
/// <summary>
@@ -53,7 +54,12 @@ namespace PSProxmox.Cmdlets
}
WriteVerbose($"Removing node {Connection.Server} from cluster");
client.Delete("cluster/leave", parameters);
string queryString = "";
if (parameters.Count > 0)
{
queryString = "?" + string.Join("&", parameters.Select(p => $"{p.Key}={p.Value}"));
}
client.Delete($"cluster/leave{queryString}");
WriteVerbose($"Node {Connection.Server} removed from cluster");
}
+2 -2
View File
@@ -73,7 +73,7 @@ namespace PSProxmox.Cmdlets
/// <para type="description">Additional parameters for the storage.</para>
/// </summary>
[Parameter(Mandatory = false)]
public Hashtable AdditionalParameters { get; set; }
public Dictionary<string, string> AdditionalParameters { get; set; }
/// <summary>
/// Processes the cmdlet.
@@ -119,7 +119,7 @@ namespace PSProxmox.Cmdlets
}
// Create the storage
string createResponse = client.Post("storage", parameters);
client.Post("storage", parameters);
// Get the created storage
string storageResponse = client.Get($"storage/{Name}");
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 freedbygrace
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+2 -1
View File
@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
namespace PSProxmox.Models
{
@@ -30,6 +31,6 @@ namespace PSProxmox.Models
/// Gets the role's privileges as a list.
/// </summary>
[JsonIgnore]
public List<string> PrivilegesList => Privileges?.Split(',') ?? new List<string>();
public List<string> PrivilegesList => Privileges?.Split(',').ToList() ?? new List<string>();
}
}
+99
View File
@@ -0,0 +1,99 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>PSProxmox</AssemblyName>
<RootNamespace>PSProxmox</RootNamespace>
<Version>2023.04.28.1324</Version>
<Authors>PSProxmox Contributors</Authors>
<Company>PSProxmox</Company>
<Description>PowerShell module for managing Proxmox VE clusters</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/freedbygrace/PSProxmox</PackageProjectUrl>
<RepositoryUrl>https://github.com/freedbygrace/PSProxmox</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>PowerShell;Proxmox;VE;Virtualization</PackageTags>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" />
</ItemGroup>
<PropertyGroup>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<ItemGroup>
<Compile Include="Client\ProxmoxApiClient.cs" />
<Compile Include="Cmdlets\ClearProxmoxIPPoolCmdlet.cs" />
<Compile Include="Cmdlets\ConnectProxmoxServerCmdlet.cs" />
<Compile Include="Cmdlets\DisconnectProxmoxServerCmdlet.cs" />
<Compile Include="Cmdlets\GetProxmoxClusterBackupCmdlet.cs" />
<Compile Include="Cmdlets\GetProxmoxClusterCmdlet.cs" />
<Compile Include="Cmdlets\GetProxmoxIPPoolCmdlet.cs" />
<Compile Include="Cmdlets\GetProxmoxNetworkCmdlet.cs" />
<Compile Include="Cmdlets\GetProxmoxNodeCmdlet.cs" />
<Compile Include="Cmdlets\GetProxmoxRoleCmdlet.cs" />
<Compile Include="Cmdlets\GetProxmoxSDNVnetCmdlet.cs" />
<Compile Include="Cmdlets\GetProxmoxSDNZoneCmdlet.cs" />
<Compile Include="Cmdlets\GetProxmoxStorageCmdlet.cs" />
<Compile Include="Cmdlets\GetProxmoxUserCmdlet.cs" />
<Compile Include="Cmdlets\GetProxmoxVMCmdlet.cs" />
<Compile Include="Cmdlets\GetProxmoxVMTemplateCmdlet.cs" />
<Compile Include="Cmdlets\JoinProxmoxClusterCmdlet.cs" />
<Compile Include="Cmdlets\LeaveProxmoxClusterCmdlet.cs" />
<Compile Include="Cmdlets\NewProxmoxClusterBackupCmdlet.cs" />
<Compile Include="Cmdlets\NewProxmoxIPPoolCmdlet.cs" />
<Compile Include="Cmdlets\NewProxmoxNetworkCmdlet.cs" />
<Compile Include="Cmdlets\NewProxmoxRoleCmdlet.cs" />
<Compile Include="Cmdlets\NewProxmoxSDNVnetCmdlet.cs" />
<Compile Include="Cmdlets\NewProxmoxSDNZoneCmdlet.cs" />
<Compile Include="Cmdlets\NewProxmoxStorageCmdlet.cs" />
<Compile Include="Cmdlets\NewProxmoxUserCmdlet.cs" />
<Compile Include="Cmdlets\NewProxmoxVMBuilderCmdlet.cs" />
<Compile Include="Cmdlets\NewProxmoxVMCmdlet.cs" />
<Compile Include="Cmdlets\NewProxmoxVMFromTemplateCmdlet.cs" />
<Compile Include="Cmdlets\NewProxmoxVMTemplateCmdlet.cs" />
<Compile Include="Cmdlets\RemoveProxmoxNetworkCmdlet.cs" />
<Compile Include="Cmdlets\RemoveProxmoxRoleCmdlet.cs" />
<Compile Include="Cmdlets\RemoveProxmoxSDNVnetCmdlet.cs" />
<Compile Include="Cmdlets\RemoveProxmoxSDNZoneCmdlet.cs" />
<Compile Include="Cmdlets\RemoveProxmoxStorageCmdlet.cs" />
<Compile Include="Cmdlets\RemoveProxmoxUserCmdlet.cs" />
<Compile Include="Cmdlets\RemoveProxmoxVMCmdlet.cs" />
<Compile Include="Cmdlets\RemoveProxmoxVMTemplateCmdlet.cs" />
<Compile Include="Cmdlets\RestartProxmoxVMCmdlet.cs" />
<Compile Include="Cmdlets\RestoreProxmoxClusterBackupCmdlet.cs" />
<Compile Include="Cmdlets\StartProxmoxVMCmdlet.cs" />
<Compile Include="Cmdlets\StopProxmoxVMCmdlet.cs" />
<Compile Include="IPAM\IPAMManager.cs" />
<Compile Include="Models\ProxmoxCluster.cs" />
<Compile Include="Models\ProxmoxClusterBackup.cs" />
<Compile Include="Models\ProxmoxConnectionInfo.cs" />
<Compile Include="Models\ProxmoxIPPool.cs" />
<Compile Include="Models\ProxmoxNetwork.cs" />
<Compile Include="Models\ProxmoxNode.cs" />
<Compile Include="Models\ProxmoxRole.cs" />
<Compile Include="Models\ProxmoxResponse.cs" />
<Compile Include="Models\ProxmoxSDNVnet.cs" />
<Compile Include="Models\ProxmoxSDNZone.cs" />
<Compile Include="Models\ProxmoxStorage.cs" />
<Compile Include="Models\ProxmoxTicket.cs" />
<Compile Include="Models\ProxmoxUser.cs" />
<Compile Include="Models\ProxmoxVM.cs" />
<Compile Include="Models\ProxmoxVMBuilder.cs" />
<Compile Include="Models\ProxmoxVMTemplate.cs" />
<Compile Include="Session\ProxmoxConnection.cs" />
<Compile Include="Session\ProxmoxSession.cs" />
<Compile Include="Templates\TemplateManager.cs" />
<Compile Include="Utilities\JsonUtility.cs" />
</ItemGroup>
<ItemGroup>
<None Include="PSProxmox.psd1" CopyToOutputDirectory="Always" />
<None Include="PSProxmox.psm1" CopyToOutputDirectory="Always" />
</ItemGroup>
</Project>
+24
View File
@@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PSProxmox", "PSProxmox.csproj", "{A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F1E2D3C4-B5A6-9876-5432-1098F7E6D5C4}
EndGlobalSection
EndGlobal
+1 -1
View File
@@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" />
<PackageReference Include="System.Management.Automation" Version="7.0.0" />
<PackageReference Include="System.Management.Automation" Version="6.1.7" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>