-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathsetup-symlinks.ps1
More file actions
74 lines (63 loc) · 3.37 KB
/
setup-symlinks.ps1
File metadata and controls
74 lines (63 loc) · 3.37 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
# PowerShell script for Windows to create symlinks
# Requires Developer Mode enabled OR running PowerShell as Administrator
$ErrorActionPreference = "Stop"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$sampleUnity6Assets = Join-Path $scriptDir "examples\passport-unity6\Assets"
$sampleUnity6 = Join-Path $scriptDir "examples\passport-unity6"
Write-Output "Setting up symlinks for passport-unity6..."
# Check if running with sufficient privileges
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$isAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Output "WARNING: Not running as Administrator."
Write-Output "If symlink creation fails, either:"
Write-Output " 1. Enable Developer Mode (Settings > Update & Security > For developers)"
Write-Output " 2. Run PowerShell as Administrator"
Write-Output ""
}
# Remove existing directories/symlinks if they exist in Assets
Set-Location $sampleUnity6Assets
if (Test-Path "Scenes") { Remove-Item -Path "Scenes" -Recurse -Force }
if (Test-Path "Scripts") { Remove-Item -Path "Scripts" -Recurse -Force }
if (Test-Path "Editor") { Remove-Item -Path "Editor" -Recurse -Force }
if (Test-Path "Scenes.meta") { Remove-Item -Path "Scenes.meta" -Force }
if (Test-Path "Scripts.meta") { Remove-Item -Path "Scripts.meta" -Force }
if (Test-Path "Editor.meta") { Remove-Item -Path "Editor.meta" -Force }
# Create symlinks using relative paths (so they work cross-platform)
# Use relative paths like the bash script does
try {
# Create directory symbolic links (Unity recognises these on Windows)
# Note: Requires administrator privileges
# Using relative paths so symlinks work on all platforms
cmd /c mklink /D "Scenes" "..\..\passport\Assets\Scenes" | Out-Null
cmd /c mklink /D "Scripts" "..\..\passport\Assets\Scripts" | Out-Null
cmd /c mklink /D "Editor" "..\..\passport\Assets\Editor" | Out-Null
# Create file symbolic links for .meta files
cmd /c mklink "Scenes.meta" "..\..\passport\Assets\Scenes.meta" | Out-Null
cmd /c mklink "Scripts.meta" "..\..\passport\Assets\Scripts.meta" | Out-Null
cmd /c mklink "Editor.meta" "..\..\passport\Assets\Editor.meta" | Out-Null
Write-Output ""
Write-Output "✅ Asset symlinks created successfully!"
Write-Output ""
Write-Output "Scenes, Scripts, and Editor in passport-unity6 now point to passport/Assets"
Get-ChildItem | Where-Object { $_.Name -match "Scenes|Scripts|Editor" } | Format-Table Name, LinkType, Target
# Create directory symbolic link for Tests
Set-Location $sampleUnity6
if (Test-Path "Tests") { Remove-Item -Path "Tests" -Recurse -Force }
# Use relative path
cmd /c mklink /D "Tests" "..\passport\Tests" | Out-Null
Write-Output ""
Write-Output "✅ Tests symlink created successfully!"
Write-Output "Tests in passport-unity6 now points to passport/Tests"
Get-ChildItem | Where-Object { $_.Name -eq "Tests" } | Format-Table Name, LinkType, Target
}
catch {
Write-Output ""
Write-Output "❌ Failed to create symlinks!"
Write-Output "Error: $_"
Write-Output ""
Write-Output "Please enable Developer Mode:"
Write-Output " Settings > Update & Security > For developers > Developer Mode: ON"
Write-Output "Then run this script again."
exit 1
}