Repository navigation
Expand file tree
/
Copy pathBuild-Portable.ps1
More file actions
207 lines (161 loc) · 6.07 KB
/
Copy pathBuild-Portable.ps1
File metadata and controls
207 lines (161 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Builds a portable self-contained distribution of EntityClassGenerator.
.DESCRIPTION
Creates a portable ZIP package with:
- Self-contained .NET runtime (no .NET installation required)
- All dependencies included
- Ready to extract and run
- Optimized with ReadyToRun compilation
.PARAMETER Configuration
Build configuration (default: Release)
.PARAMETER OutputDir
Output directory for the portable build (default: ./publish/portable-win-x64)
.EXAMPLE
.\Build-Portable.ps1
.\Build-Portable.ps1 -Configuration Debug
#>
[CmdletBinding()]
param(
[Parameter()]
[ValidateSet('Debug', 'Release')]
[string]$Configuration = 'Release',
[Parameter()]
[string]$OutputDir = "publish/portable-win-x64"
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
# Colors
function Write-Header { Write-Host "`n=== $args ===" -ForegroundColor Cyan }
function Write-Success { Write-Host "✅ $args" -ForegroundColor Green }
function Write-Failure { Write-Host "❌ $args" -ForegroundColor Red }
try {
Write-Header "Building Entity Class Generator - Portable Edition"
# Paths
$rootDir = $PSScriptRoot
$projectPath = Join-Path $rootDir "src/EntityClassGenerator.App/EntityClassGenerator.App.csproj"
$publishDir = Join-Path $rootDir $OutputDir
$zipFileName = "EntityClassGenerator-v1.0.0-Portable-win-x64.zip"
$zipPath = Join-Path $rootDir "publish/$zipFileName"
# Clean previous build
if (Test-Path $publishDir) {
Write-Host "Cleaning previous build..." -ForegroundColor Yellow
Remove-Item $publishDir -Recurse -Force
}
# Publish
Write-Header "Publishing self-contained application"
$publishArgs = @(
'publish',
$projectPath,
'-c', $Configuration,
'-r', 'win-x64',
'--self-contained', 'true',
'-o', $publishDir,
'/p:PublishSingleFile=false',
'/p:PublishReadyToRun=true',
'/p:IncludeNativeLibrariesForSelfExtract=true'
)
& dotnet @publishArgs
if ($LASTEXITCODE -ne 0) {
throw "Publish failed with exit code $LASTEXITCODE"
}
Write-Success "Application published to $publishDir"
# Create README for portable version
Write-Header "Creating distribution README"
$readmeContent = @"
# Entity Class Generator - Portable Edition
Version: 1.0.0
Build Date: $(Get-Date -Format 'yyyy-MM-dd')
Runtime: .NET 10 (self-contained)
## What's This?
Entity Class Generator is a WPF desktop application that reverse-engineers SQL Server databases into:
- Entity Framework Core entity classes
- DbContext with DbSet properties
- Fluent API configurations
## How to Run
1. Extract this ZIP to any folder
2. Run ``EntityClassGenerator.App.exe``
3. No .NET installation required! (runtime is included)
## System Requirements
- Windows 10 version 1809 or later (October 2018 Update)
- Windows 11 (all versions)
- x64 processor
- 4 GB RAM minimum (8 GB recommended)
- SQL Server access (local or remote)
## Features
✅ 5-Step Wizard (Connection → Tables → Naming → Output → Preview)
✅ Multiple authentication methods (Windows, SQL Server)
✅ Schema filtering and table multi-select
✅ Flexible naming conventions with saved profiles
✅ Real-time syntax-highlighted preview
✅ Fluent API configurations for complex mappings
✅ Recent connections and saved profiles
✅ Dark/light/system theme support
## Quick Start
1. **Connection**: Enter SQL Server details
2. **Tables**: Select tables to generate
3. **Naming**: Choose naming style (PascalCase, camelCase, snake_case)
4. **Output**: Pick output directory
5. **Preview**: Review and generate!
## Troubleshooting
**Cannot connect to SQL Server?**
- Verify SQL Server is running and accessible
- Check firewall settings (port 1433)
- Ensure SQL authentication is enabled (if using SQL auth)
**"Access Denied" error?**
- Run as Administrator if accessing system-protected SQL instances
- Check folder write permissions for output directory
**Missing tables in list?**
- Select correct schema from dropdown
- Click "Refresh" button
## Support
Repository: https://github.com/yourusername/EntityClassGenerator
Issues: https://github.com/yourusername/EntityClassGenerator/issues
## License
Open Source - see LICENSE file for details
---
Generated: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')
"@
$readmePath = Join-Path $publishDir "README.txt"
$readmeContent | Out-File -FilePath $readmePath -Encoding UTF8
Write-Success "README created"
# Copy main project README as reference docs
$mainReadme = Join-Path $rootDir "README.md"
if (Test-Path $mainReadme) {
Copy-Item $mainReadme -Destination (Join-Path $publishDir "TECHNICAL_DOCS.md")
Write-Success "Technical docs copied"
}
# Create ZIP
Write-Header "Creating ZIP package"
$publishParentDir = Split-Path $publishDir -Parent
if (-not (Test-Path $publishParentDir)) {
New-Item -ItemType Directory -Path $publishParentDir -Force | Out-Null
}
if (Test-Path $zipPath) {
Remove-Item $zipPath -Force
}
Compress-Archive -Path "$publishDir/*" -DestinationPath $zipPath -CompressionLevel Optimal
Write-Success "ZIP created at $zipPath"
# Calculate size
$zipSize = (Get-Item $zipPath).Length / 1MB
$publishSize = (Get-ChildItem $publishDir -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB
# Summary
Write-Header "Build Complete"
Write-Host ""
Write-Host " 📦 Portable Build: " -NoNewline
Write-Host "$publishDir" -ForegroundColor Cyan
Write-Host " 📦 ZIP Package: " -NoNewline
Write-Host "$zipPath" -ForegroundColor Cyan
Write-Host " 📊 Published Size: " -NoNewline
Write-Host ("{0:N2} MB" -f $publishSize) -ForegroundColor Yellow
Write-Host " 📊 ZIP Size: " -NoNewline
Write-Host ("{0:N2} MB" -f $zipSize) -ForegroundColor Yellow
Write-Host ""
Write-Success "Portable distribution ready for deployment!"
Write-Host ""
} catch {
Write-Failure "Build failed: $_"
Write-Host $_.ScriptStackTrace -ForegroundColor Red
exit 1
}