SharpTree is a tool designed to construct and visualize the filesystem tree structure.
- PowerShell Integration: Easily importable into PowerShell 5.1 or 7 scripts for automation and scripting tasks.
- Multi-Targeted: Compatible with both modern .NET environments (.NET 8) and legacy systems via .NET Framework 4.8 for PowerShell 5.1.
- .NET 8 SDK: Required for building the project. Download Here
- PowerShell 5.1 or 7: Available by default on Windows systems.
- Operating System: Windows.
-
Clone the Repository
git clone https://github.com/isaiahduarte/SharpTree.git cd SharpTree -
Restore Dependencies
Ensure all necessary NuGet packages are restored.
dotnet restore
-
Build the Project
Follow the Building SharpTree section to generate the necessary DLLs.
-
Ensure .NET 8 SDK is Installed
Download and install the latest .NET 8 SDK if you haven't already.
-
Navigate to the Project Directory
cd SharpTree -
Build the Project
Execute the following command to build for both target frameworks:
dotnet publish
-
Locate the Generated DLLs
After a successful build, the DLLs will be located in:
\bin\SharpTree\publish \bin\SharpTree.Core\publish
Integrate SharpTree into your PowerShell scripts by importing the compatible DLL and utilizing its methods to build and display filesystem trees.
Depending if you are using PowerShell 5.1 or 7, you will need to import the corresponding DLL:
Powershell 5.1
$dllPath = "C:\Path\To\SharpTree\bin\SharpTree.Core.Powershell\SharpTree.Core.Powershell.dll"Powershell 7
$dllPath = "C:\Path\To\SharpTree\bin\SharpTree.Core\publish\SharpTree.Core.Powershell.dll"Note: Powershell 7 is more efficient and recommended for use.
Import the SharpTree DLL
Use the Add-Type cmdlet to load the assembly:
# Import the DLL
Add-Type -Path $dllPath# See which version of PowerShell is running
if ($PSVersionTable.PSVersion.Major -eq 5) {
$dllPath = "C:\Path\To\SharpTree\bin\SharpTree.Core.Powershell\SharpTree.Core.Powershell.dll"
exit
} elseif ($PSVersionTable.PSVersion.Major -eq 7) {
$dllPath = "C:\Path\To\SharpTree\bin\SharpTree.Core\SharpTree.Core.dll"
} else {
Write-Host "Unsupported PowerShell version"
exit
}
# Load the assembly
Add-Type -Path $dllPath -PassThru
# Get the root node #Path #MinSize #MaxDepth
$Node = [SharpTree.Core.Services.FileSystemReader]::Read($ENV:USERPROFILE, 1024, -1)
# Save node to JSON
$Node.SaveToJson(C:\report.json)
# Display Node
$Node.Show()
# Load From JSON
$Node = [SharpTree.Core.Services.JsonNode]::LoadFromJson(C:\report.json)Test.webm
Contributions are welcome! To contribute to SharpTree, follow these steps:
-
Fork the Repository
Click the "Fork" button on the repository page to create a personal copy.
-
Clone Your Fork
git clone https://github.com/IsaiahDuarte/SharpTree.git cd SharpTree -
Create a New Branch
git checkout -b feature/YourFeatureName
-
Make Your Changes
Implement your feature or bug fix.
-
Commit Your Changes
git commit -m "Add description of your feature or fix" -
Push to Your Fork
git push origin feature/YourFeatureName
-
Open a Pull Request
Go to the original repository and create a pull request detailing your changes.