Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Functionality to Include Text-Grab in System PATH and Build Process Enhancements #488

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 55 additions & 32 deletions build-x64.ps1
Original file line number Diff line number Diff line change
@@ -1,45 +1,68 @@
# Set up paths
$BuildPath = "$PSScriptRoot\bld\x64"
$BuildPathSC = "$PSScriptRoot\bld\x64\Text-Grab-Self-Contained"
$Version = Get-Date -Format "yyyy-MM-dd" # 2020-11-1
$VersionDot = $Version -replace '-','.'
$Version = Get-Date -Format "yyyy-MM-dd"
$VersionDot = $Version -replace '-', '.'
$Project = "Text-Grab"
$Archive = "$BuildPath\$Project-$Version.zip"
$ArchiveSC = "$BuildPath\$Project-Self-Contained-$Version.zip"

# Clean up
if(Test-Path -Path $BuildPath)
{
# Clean up old build directory if it exists
if (Test-Path -Path $BuildPath) {
Remove-Item $BuildPath -Recurse
Write-Host "Old build directory removed."
}

# Dotnet restore and build
# Build non-self-contained version of Text-Grab
Write-Host "Building non-self-contained version of Text-Grab..."
dotnet publish "$PSScriptRoot\$Project\$Project.csproj" `
--runtime win-x64 `
--self-contained false `
-c Release `
-v minimal `
-o $BuildPath `
-p:PublishReadyToRun=true `
-p:PublishSingleFile=true `
-p:CopyOutputSymbolsToPublishDirectory=false `
-p:Version=$VersionDot `
--nologo

# Archive Build
--runtime win-x64 `
--self-contained false `
-c Release `
-v minimal `
-o $BuildPath `
-p:PublishReadyToRun=true `
-p:PublishSingleFile=true `
-p:CopyOutputSymbolsToPublishDirectory=false `
-p:Version=$VersionDot `
--nologo

# Archive the non-self-contained build
Compress-Archive -Path "$BuildPath\$Project.exe" -DestinationPath $Archive
Write-Host "Non-self-contained build archived at $Archive."

# Dotnet restore and build
# Build self-contained version of Text-Grab
Write-Host "Building self-contained version of Text-Grab..."
dotnet publish "$PSScriptRoot\$Project\$Project.csproj" `
--runtime win-x64 `
--self-contained true `
-c Release `
-v minimal `
-o $BuildPathSC `
-p:PublishReadyToRun=true `
-p:PublishSingleFile=true `
-p:CopyOutputSymbolsToPublishDirectory=false `
-p:Version=$VersionDot `
--nologo

# Archive Build
Compress-Archive -Path "$BuildPathSC" -DestinationPath $ArchiveSC
--runtime win-x64 `
--self-contained true `
-c Release `
-v minimal `
-o $BuildPathSC `
-p:PublishReadyToRun=true `
-p:PublishSingleFile=true `
-p:CopyOutputSymbolsToPublishDirectory=false `
-p:Version=$VersionDot `
--nologo

# Archive the self-contained build
Compress-Archive -Path "$BuildPathSC" -DestinationPath $ArchiveSC
Write-Host "Self-contained build archived at $ArchiveSC."

# Define the installation directory for Text-Grab
# Adjust this path to where Text-Grab is built and stored
$textGrabPath = "$BuildPath\TextGrab.exe"

# Check and add Text-Grab to the system PATH if not already present
$currentPath = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)

if ($currentPath -notlike "*$textGrabPath*") {
# Add Text-Grab to the system PATH
$newPath = "$currentPath;$textGrabPath"
[System.Environment]::SetEnvironmentVariable("Path", $newPath, [System.EnvironmentVariableTarget]::Machine)
Write-Host "Text-Grab has been added to the system PATH."
} else {
Write-Host "Text-Grab is already in the system PATH."
}

Write-Host "Build complete!"