powershell:convert-path

本文介绍了convertpath的功能,即如何将相对路径(如'.'代表的当前目录)转换为完整的绝对路径。这对于理解和操作文件系统非常有用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

convertpath就是转换路径的作用,就是把比如.代表当前目录,则会转换为当前目录的完整路径

下面是示例

 

转载于:https://www.cnblogs.com/popping57/p/3229447.html

PS C:\Users\Administrator> # CurlTools.psm1 >> # ============== >> # 修复版模块主文件 >> >> # 初始化模块变量 >> $script:Config = $null >> $script:CurlPath = $null >> $script:ConfigDir = $null >> $script:ConfigPath = $null >> >> # 检测操作系统 >> function Get-Platform { >> if ($PSVersionTable.PSEdition -eq "Core") { >> if ($IsWindows) { return "Windows" } >> elseif ($IsLinux) { return "Linux" } >> elseif ($IsMacOS) { return "macOS" } >> } else { >> return "Windows" >> } >> } >> >> # 获取跨平台配置目录 >> function Get-ConfigDir { >> $platform = Get-Platform >> switch ($platform) { >> "Linux" { >> if (-not (Test-Path "$env:HOME/.config")) { >> New-Item -ItemType Directory -Path "$env:HOME/.config" -Force | Out-Null >> } >> return "$env:HOME/.config/curltools" >> } >> "macOS" { >> if (-not (Test-Path "$env:HOME/Library/Application Support")) { >> New-Item -ItemType Directory -Path "$env:HOME/Library/Application Support" -Force | Out-Null >> } >> return "$env:HOME/Library/Application Support/CurlTools" >> } >> default { >> if (-not (Test-Path $env:APPDATA)) { >> New-Item -ItemType Directory -Path $env:APPDATA -Force | Out-Null >> } >> return "$env:APPDATA\CurlTools" >> } >> } >> } >> >> # 增强版路径检测 >> function Get-DefaultCurlPath { >> $platform = Get-Platform >> switch ($platform) { >> "Linux" { >> if (Test-Path "/usr/bin/curl") { return "/usr/bin" } >> return $null >> } >> "macOS" { >> if (Test-Path "/usr/local/bin/curl") { return "/usr/local/bin" } >> return $null >> } >> default { >> # 尝试自动检测Windows上的curl路径 >> $potentialPaths = @( >> "C:\Program Files\curl\bin", >> "C:\curl\bin", >> "$env:USERPROFILE\curl\bin", >> "E:\curl-8.15.0_4-win64-mingw\bin", >> "C:\Windows\System32" # 添加系统路径 >> ) >> >> foreach ($path in $potentialPaths) { >> $curlExe = Join-Path $path "curl.exe" >> if (Test-Path $curlExe -PathType Leaf) { >> return $path >> } >> } >> >> # 如果找不到,尝试在PATH中查找 >> $pathDirs = $env:Path -split ';' >> foreach ($dir in $pathDirs) { >> $curlExe = Join-Path $dir "curl.exe" >> if (Test-Path $curlExe -PathType Leaf) { >> return $dir >> } >> } >> >> return $null >> } >> } >> } >> >> # 增强初始化逻辑 >> function Initialize-ModuleConfig { >> $script:ConfigDir = Get-ConfigDir >> >> # 确保配置目录存在 >> if (-not (Test-Path $script:ConfigDir)) { >> New-Item -ItemType Directory -Path $script:ConfigDir -Force | Out-Null >> } >> >> $script:ConfigPath = Join-Path -Path $script:ConfigDir -ChildPath "config.json" >> >> # 加载或创建默认配置 >> if (Test-Path $script:ConfigPath) { >> try { >> $script:Config = Get-Content $script:ConfigPath | ConvertFrom-Json >> } catch { >> Write-Warning "配置加载失败: $_,创建新配置" >> $script:Config = $null >> } >> } >> >> if (-not $script:Config) { >> $defaultPath = Get-DefaultCurlPath >> if (-not $defaultPath) { >> throw "无法找到curl.exe,请确保curl已安装并添加到PATH" >> } >> >> $script:Config = [PSCustomObject]@{ >> CurlPath = $defaultPath >> LastUpdate = (Get-Date).ToString("o") >> AutoUpdate = $true >> } >> $script:Config | ConvertTo-Json | Set-Content $script:ConfigPath -Force >> } >> >> # 设置模块路径并验证 >> $script:CurlPath = $script:Config.CurlPath >> $curlExe = Join-Path $script:CurlPath "curl.exe" >> if (-not (Test-Path $curlExe -PathType Leaf)) { >> throw "curl.exe在路径'$script:CurlPath'中不存在" >> } >> } >> >> # 保存配置 >> function Save-ModuleConfig { >> $script:Config | ConvertTo-Json | Set-Content $script:ConfigPath -Force >> } >> >> # 在模块导入时自动初始化配置 >> try { >> Initialize-ModuleConfig >> } catch { >> Write-Error "模块初始化失败: $_" >> throw >> } >> >> # 其他函数保持不变(Get-FileHashFromUrl, Get-CurlVersion等) >> # ... [保持原有函数代码] ... >> # CurlTools.psm1 # ============== # 修复版模块主文件 # 初始化模块变量 $script:Config = $null $script:CurlPath = $null $script:ConfigDir = $null $script:ConfigPath = $null # 检测操作系统 function Get-Platform { if ($PSVersionTable.PSEdition -eq "Core") { if ($IsWindows) { return "Windows" } elseif ($IsLinux) { return "Linux" } elseif ($IsMacOS) { return "macOS" } } else { return "Windows" } } # 获取跨平台配置目录 function Get-ConfigDir { $platform = Get-Platform switch ($platform) { "Linux" { if (-not (Test-Path "$env:HOME/.config")) { New-Item -ItemType Directory -Path "$env:HOME/.config" -Force | Out-Null } return "$env:HOME/.config/curltools" } "macOS" { if (-not (Test-Path "$env:HOME/Library/Application Support")) { New-Item -ItemType Directory -Path "$env:HOME/Library/Application Support" -Force | Out-Null } return "$env:HOME/Library/Application Support/CurlTools" } default { if (-not (Test-Path $env:APPDATA)) { New-Item -ItemType Directory -Path $env:APPDATA -Force | Out-Null } return "$env:APPDATA\CurlTools" } } } # 增强版路径检测 function Get-DefaultCurlPath { $platform = Get-Platform switch ($platform) { "Linux" { if (Test-Path "/usr/bin/curl") { return "/usr/bin" } return $null } "macOS" { if (Test-Path "/usr/local/bin/curl") { return "/usr/local/bin" } return $null } default { # 尝试自动检测Windows上的curl路径 $potentialPaths = @( "C:\Program Files\curl\bin", "C:\curl\bin", "$env:USERPROFILE\curl\bin", "E:\curl-8.15.0_4-win64-mingw\bin", "C:\Windows\System32" # 添加系统路径 ) foreach ($path in $potentialPaths) { $curlExe = Join-Path $path "curl.exe" if (Test-Path $curlExe -PathType Leaf) { return $path } } # 如果找不到,尝试在PATH中查找 $pathDirs = $env:Path -split ';' foreach ($dir in $pathDirs) { $curlExe = Join-Path $dir "curl.exe" if (Test-Path $curlExe -PathType Leaf) { return $dir } } return $null } } } # 增强初始化逻辑 function Initialize-ModuleConfig { $script:ConfigDir = Get-ConfigDir # 确保配置目录存在 if (-not (Test-Path $script:ConfigDir)) { New-Item -ItemType Directory -Path $script:ConfigDir -Force | Out-Null } $script:ConfigPath = Join-Path -Path $script:ConfigDir -ChildPath "config.json" # 加载或创建默认配置 if (Test-Path $script:ConfigPath) { try { $script:Config = Get-Content $script:ConfigPath | ConvertFrom-Json } catch { Write-Warning "配置加载失败: $_,创建新配置" $script:Config = $null } } if (-not $script:Config) { $defaultPath = Get-DefaultCurlPath if (-not $defaultPath) { throw "无法找到curl.exe,请确保curl已安装并添加到PATH" } $script:Config = [PSCustomObject]@{ CurlPath = $defaultPath LastUpdate = (Get-Date).ToString("o") AutoUpdate = $true } $script:Config | ConvertTo-Json | Set-Content $script:ConfigPath -Force } # 设置模块路径并验证 $script:CurlPath = $script:Config.CurlPath $curlExe = Join-Path $script:CurlPath "curl.exe" if (-not (Test-Path $curlExe -PathType Leaf)) { throw "curl.exe在路径'$script:CurlPath'中不存在" } } # 保存配置 function Save-ModuleConfig { $script:Config | ConvertTo-Json | Set-Content $script:ConfigPath -Force } # 在模块导入时自动初始化配置 try { Initialize-ModuleConfig } catch { Write-Error "模块初始化失败: $_" throw } # 其他函数保持不变(Get-FileHashFromUrl, Get-CurlVersion等) # ... [保持原有函数代码] ... : 模块初始化失败: 无法将参数绑定到参数“Path”,因为该参数是空值。 + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException Join-Path : 无法将参数绑定到参数“Path”,因为该参数是空值。 所在位置 行:127 字符: 26 + $curlExe = Join-Path $script:CurlPath "curl.exe" + ~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Join-Path],ParentContainsErrorRecordException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCom mand PS C:\Users\Administrator>
08-13
BeforeAll { # 导入模块 Import-Module "E:\CurlTools" -Force -ErrorAction Stop # 内部访问Get-CurlVersion函数 $script:GetCurlVersion = & (Get-Module CurlTools) { ${function:Get-CurlVersion} } } Describe "Core Functionality Tests" { It "Get-CurlPath returns valid executable path" { $path = Get-CurlPath $path | Should -Not -BeNullOrEmpty $path | Should -Exist $path | Should -Match "curl\.exe$" } It "Get-CurlVersion returns version info" { $version = $script:GetCurlVersion $version | Should -Not -BeNullOrEmpty $version | Should -Match "curl \d+\.\d+\.\d+" } # 其他测试保持不变... } # 加载测试框架 BeforeAll { # 正确导入模块(使用根目录) Import-Module "E:\CurlTools" -Force -ErrorAction Stop # 创建临时目录 $script:testTempDir = Join-Path $env:TEMP "CurlToolsTests" if (-not (Test-Path $script:testTempDir)) { New-Item -Path $script:testTempDir -ItemType Directory -Force | Out-Null } # 模拟配置文件 $mockConfig = @{ CurlPath = "E:\CurlTools\CurlBin\curl.exe" AllowedDomains = @("example.com", "github.com") MaxDownloadSpeed = 1024 } $mockConfig | ConvertTo-Json | Set-Content (Join-Path $script:testTempDir "mock_config.json") # 设置测试用URL $script:validUrl = "https://example.com" $script:blockedUrl = "http://untrusted.com/file" $script:invalidUrl = "https://invalid-domain-that-does-not-exist-123456.com" } Describe "模块加载测试" { It "应成功导入模块" { { Import-Module "E:\CurlTools" -Force -ErrorAction Stop } | Should -Not -Throw } It "应导出Get-CurlPath函数" { Get-Command -Name Get-CurlPath | Should -Not -BeNullOrEmpty } It "应正确检测curl.exe路径" { $curlPath = Get-CurlPath $curlPath | Should -BeLike "*CurlBin\curl.exe" Test-Path -Path $curlPath | Should -Be $true } } Describe "核心功能测试" { It "Get-CurlPath返回有效的可执行文件路径" { $path = Get-CurlPath $path | Should -Not -BeNullOrEmpty $path | Should -Exist $path | Should -Match "curl\.exe$" } It "Get-CurlVersion返回版本信息" { $version = Get-CurlVersion $version | Should -Not -BeNullOrEmpty $version | Should -Match "curl \d+\.\d+\.\d+" } It "Invoke-SecureDownload成功下载文件" { $testFile = Join-Path $script:testTempDir "test_$(Get-Date -Format 'yyyyMMddHHmmss').html" { Invoke-SecureDownload ` -Url $script:validUrl ` -OutputPath $testFile ` -ErrorAction Stop } | Should -Not -Throw # 验证文件下载 $testFile | Should -Exist (Get-Item $testFile).Length | Should -BeGreaterThan 0 } It "优雅处理无效URL" { $testFile = Join-Path $script:testTempDir "invalid_test.html" { Invoke-SecureDownload ` -Url $script:invalidUrl ` -OutputPath $testFile ` -ErrorAction Stop } | Should -Throw } } Describe "安全策略测试" { It "应拒绝未授权域名" { $testFile = Join-Path $script:testTempDir "blocked_test.txt" { Invoke-SecureDownload ` -Url $script:blockedUrl ` -OutputPath $testFile ` -ErrorAction Stop } | Should -Throw -ExpectedMessage "Domain blocked by policy" } It "应允许github.com下载" { $testFile = Join-Path $script:testTempDir "github.ico" { Invoke-SecureDownload ` -Url "https://github.com/favicon.ico" ` -OutputPath $testFile ` -ErrorAction Stop } | Should -Not -Throw # 验证文件下载 $testFile | Should -Exist (Get-Item $testFile).Length | Should -BeGreaterThan 0 } } AfterAll { # 清理所有测试文件 if (Test-Path $script:testTempDir) { Remove-Item -Path $script:testTempDir -Recurse -Force } }
08-15
PS C:\Users\Administrator> # 安全的模块路径检测 >> $moduleRoot = if ($PSScriptRoot) { >> $PSScriptRoot >> } elseif ($MyInvocation.MyCommand.Path) { >> Split-Path -Parent $MyInvocation.MyCommand.Path >> } else { >> # 从模块清单获取路径 >> $manifestPath = (Get-Module CurlTools -ListAvailable | Select-Object -First 1).Path >> if ($manifestPath) { >> Split-Path -Parent $manifestPath >> } else { >> throw "无法确定模块根目录" >> } >> } >> >> # 安全导入函数 >> $privatePath = Join-Path $moduleRoot "Private" >> $publicPath = Join-Path $moduleRoot "Public" >> >> if (Test-Path $privatePath) { >> Get-ChildItem -Path "$privatePath/*.ps1" -ErrorAction SilentlyContinue | ForEach-Object { >> . $_.FullName >> } >> } >> >> if (Test-Path $publicPath) { >> Get-ChildItem -Path "$publicPath/*.ps1" -ErrorAction SilentlyContinue | ForEach-Object { >> . $_.FullName >> } >> } >> >> # 定义初始化函数 >> function Initialize-Module { >> # ... 初始化逻辑(见下方)... >> } >> >> # 延迟导出函数 >> $exportFunctions = @( >> 'Get-CurlPath', >> 'Set-CurlPath', >> 'Get-CurlVersion', >> 'Invoke-SecureDownload' >> ) >> >> if ($ExecutionContext.SessionState.Module) { >> Export-ModuleMember -Function $exportFunctions >> } >> >> # 执行模块初始化 >> Initialize-Module | Out-Null >> PS C:\Users\Administrator> function Initialize-Module { >> try { >> # 平台检测函数 >> function Get-Platform { >> if ($PSVersionTable.PSEdition -eq "Core") { >> if ($IsWindows) { "Windows" } >> elseif ($IsLinux) { "Linux" } >> elseif ($IsMacOS) { "macOS" } >> } else { >> if ($env:OS -like "Windows*") { "Windows" } >> elseif (Test-Path "/etc/os-release") { "Linux" } >> else { "macOS" } >> } >> } >> >> # 配置目录处理 >> $script:ConfigDir = switch (Get-Platform) { >> "Linux" { Join-Path $HOME ".config" "curltools" } >> "macOS" { Join-Path $HOME "Library" "Application Support" "CurlTools" } >> default { Join-Path $env:APPDATA "CurlTools" } >> } >> >> # 创建配置目录 >> if (-not (Test-Path $script:ConfigDir)) { >> New-Item -ItemType Directory -Path $script:ConfigDir -Force | Out-Null >> } >> >> $script:ConfigPath = Join-Path $script:ConfigDir "config.json" >> >> # 加载或创建配置 >> if (Test-Path $script:ConfigPath) { >> $script:Config = Get-Content $script:ConfigPath | ConvertFrom-Json >> } >> >> if (-not $script:Config) { >> $script:Config = [PSCustomObject]@{ >> CurlPath = $null >> LastUpdate = (Get-Date).ToString("o") >> AutoUpdate = $true >> } >> } >> >> # 设置curl路径 >> if (-not $script:Config.CurlPath -or -not (Test-Path $script:Config.CurlPath)) { >> $script:Config.CurlPath = Find-CurlPath >> } >> >> $script:CurlPath = $script:Config.CurlPath >> $script:Config | ConvertTo-Json | Set-Content $script:ConfigPath -Force >> $script:ModuleInitialized = $true >> >> return $true >> } catch { >> Write-Warning "模块初始化失败: $_" >> return $false >> } >> } >> PS C:\Users\Administrator> # 创建模块目录结构 >> $moduleDir = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\CurlTools" >> $privateDir = Join-Path $moduleDir "Private" >> $publicDir = Join-Path $moduleDir "Public" >> >> New-Item -Path $moduleDir -ItemType Directory -Force | Out-Null >> New-Item -Path $privateDir -ItemType Directory -Force | Out-Null >> New-Item -Path $publicDir -ItemType Directory -Force | Out-Null >> >> # ===== 保存模块主文件 ===== >> $moduleContent = @' >> # 完整的CurlTools.psm1内容(包含上面定义的路径检测和初始化函数) >> '@ >> Set-Content -Path "$moduleDir\CurlTools.psm1" -Value $moduleContent -Force >> >> # ===== 保存私有函数 ===== >> $installCurlContent = @' >> function Install-Curl { >> # 完整的Install-Curl函数定义(包含多平台支持) >> } >> '@ >> Set-Content -Path "$privateDir\InstallCurl.ps1" -Value $installCurlContent -Force >> >> # ===== 保存公共函数 ===== >> $getCurlPathContent = @' >> function Get-CurlPath { >> if (-not $script:ModuleInitialized) { >> Initialize-Module | Out-Null >> } >> return $script:CurlPath >> } >> '@ >> Set-Content -Path "$publicDir\GetCurlPath.ps1" -Value $getCurlPathContent -Force >> >> # 类似地保存其他公共函数... >> >> # ===== 创建模块清单 ===== >> $manifestParams = @{ >> Path = "$moduleDir\CurlTools.psd1" >> RootModule = 'CurlTools.psm1' >> ModuleVersion = '2.3.0' >> GUID = 'c0d1b1e1-1a2b-4c3d-8e4f-9a0b1c2d3e4f' >> Author = 'Your Name' >> Description = 'Robust curl tools for PowerShell' >> PowerShellVersion = '5.1' >> CompatiblePSEditions = @('Desktop', 'Core') >> FunctionsToExport = @( >> 'Get-CurlPath', >> 'Set-CurlPath', >> 'Get-CurlVersion', >> 'Invoke-SecureDownload' >> ) >> } >> >> New-ModuleManifest @manifestParams >> >> # 重新加载模块 >> Remove-Module CurlTools -ErrorAction SilentlyContinue -Force >> Import-Module $moduleDir -Force -Verbose >> >> # 测试模块 >> if (Get-Module CurlTools) { >> Write-Host "✅ CurlTools 模块安装成功!" -ForegroundColor Green >> >> # 测试基本功能 >> try { >> # 测试路径获取 >> $curlPath = Get-CurlPath >> Write-Host "Curl路径: $curlPath" >> >> # 测试版本获取 >> $version = Get-CurlVersion >> Write-Host "Curl版本: $($version[0])" >> >> # 测试下载功能 >> $testUrl = "https://raw.githubusercontent.com/PowerShell/PowerShell/master/README.md" >> $outputPath = Join-Path $env:TEMP "PowerShell_README_$(Get-Date -Format 'yyyyMMddHHmmss').md" >> Invoke-SecureDownload -Url $testUrl -OutputPath $outputPath >> Write-Host "✅ 测试下载成功: $outputPath" -ForegroundColor Green >> } >> catch { >> Write-Warning "⚠️ 测试失败: $_" >> } >> } >> else { >> Write-Error "❌ 模块安装失败" >> } >> 详细信息: 正在从路径“C:\Users\Administrator\Documents\WindowsPowerShell\Modules\CurlTools\CurlTools.psd1”加载模块。 详细信息: 正在从路径“C:\Users\Administrator\Documents\WindowsPowerShell\Modules\CurlTools\CurlTools.psm1”加载模块。 ✅ CurlTools 模块安装成功! Curl路径: E:\ai_temp\CurlTestPath 警告: ⚠️ 测试失败: 无法将“Get-CurlVersion”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 PS C:\Users\Administrator> function Find-CurlPath { >> $platform = if (Get-Command Get-Platform -ErrorAction SilentlyContinue) { >> Get-Platform >> } else { >> # 回退检测 >> if ($env:OS -like "Windows*") { "Windows" } >> elseif (Test-Path "/etc/os-release") { "Linux" } >> else { "macOS" } >> } >> >> $exeName = if ($platform -eq "Windows") { "curl.exe" } else { "curl" } >> >> # 1. 检查当前配置 >> if ($script:CurlPath -and (Test-Path (Join-Path $script:CurlPath $exeName))) { >> return $script:CurlPath >> } >> >> # 2. 检查系统PATH >> $pathCurl = Get-Command $exeName -ErrorAction SilentlyContinue >> if ($pathCurl) { >> return $pathCurl.Source | Split-Path >> } >> >> # 3. 平台特定路径 >> $searchPaths = switch ($platform) { >> "Windows" { @("C:\Windows\System32", "C:\Program Files\curl\bin", "${env:ProgramFiles}\Git\usr\bin") } >> "Linux" { @("/usr/bin", "/usr/local/bin") } >> "macOS" { @("/usr/local/bin", "/opt/homebrew/bin") } >> } >> >> foreach ($path in $searchPaths) { >> $fullPath = Join-Path $path $exeName >> if (Test-Path $fullPath) { >> return $path >> } >> } >> >> # 4. 自动安装 >> return Install-Curl >> } >> PS C:\Users\Administrator>
08-13
PS C:\Users\Administrator> # ProjectCleanup.ps1 >> $projectRoot = "E:\ProjectEcosystem\ProjectMonitor" >> >> # 1. 创建标准文件夹结构 >> $folders = @( >> "SQLite", >> "Logs", >> "Database", >> "Scripts", >> "Config" >> ) >> >> foreach ($folder in $folders) { >> $path = Join-Path $projectRoot $folder >> if (-not (Test-Path $path)) { >> New-Item -ItemType Directory -Path $path -Force | Out-Null >> } >> } >> >> # 2. 识别并移动SQLite文件 >> $sqliteFiles = @( >> "System.Data.SQLite.dll", >> "System.Data.SQLite.Linq.dll", >> "SQLite.Interop.dll", >> "sqlite3.def", >> "sqlite3.dll", >> "SQLite.NET.chm" >> ) >> >> foreach ($file in $sqliteFiles) { >> $source = Join-Path $projectRoot $file >> $dest = Join-Path $projectRoot "SQLite" $file >> >> if (Test-Path $source) { >> Move-Item -Path $source -Destination $dest -Force >> Write-Host "✅ 已移动: $file -> SQLite\" -ForegroundColor Cyan >> } >> } >> >> # 3. 移动数据库文件 >> $dbFiles = Get-ChildItem -Path $projectRoot -Filter "*.db*" >> foreach ($db in $dbFiles) { >> Move-Item -Path $db.FullName -Destination (Join-Path $projectRoot "Database") -Force >> Write-Host "✅ 已移动数据库: $($db.Name) -> Database\" -ForegroundColor Cyan >> } >> >> # 4. 移动脚本文件 >> $scriptFiles = Get-ChildItem -Path $projectRoot -Filter "*.ps*1" >> foreach ($script in $scriptFiles) { >> Move-Item -Path $script.FullName -Destination (Join-Path $projectRoot "Scripts") -Force >> Write-Host "✅ 已移动脚本: $($script.Name) -> Scripts\" -ForegroundColor Cyan >> } >> >> # 5. 移动配置文件 >> $configFiles = Get-ChildItem -Path $projectRoot -Filter "*config*" >> foreach ($config in $configFiles) { >> Move-Item -Path $config.FullName -Destination (Join-Path $projectRoot "Config") -Force >> Write-Host "✅ 已移动配置: $($config.Name) -> Config\" -ForegroundColor Cyan >> } >> >> # 6. 清理临时文件 >> $tempFiles = @( >> "*.zip", >> "*.tmp", >> "*.log", >> "*.bak", >> "Thumbs.db" >> ) >> >> foreach ($pattern in $tempFiles) { >> Get-ChildItem -Path $projectRoot -Filter $pattern | Remove-Item -Force >> } >> >> # 7. 清理空文件夹 >> Get-ChildItem -Path $projectRoot -Directory -Recurse | >> Where-Object { $_.GetFiles().Count -eq 0 -and $_.GetDirectories().Count -eq 0 } | >> Remove-Item -Force -Recurse >> >> Write-Host "✨ 清理完成!项目目录已整理 ✨" -ForegroundColor Green >> Write-Host "当前目录结构:" >> tree $projectRoot /F /A >> Join-Path : 找不到接受实际参数“System.Data.SQLite.dll”的位置形式参数。 所在位置 行:32 字符: 13 + $dest = Join-Path $projectRoot "SQLite" $file + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Join-Path],ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.JoinPathCommand Move-Item : 无法处理参数,因为参数“destination”的值为空。请将参数“destination”的值更改为非空值。 所在位置 行:35 字符: 9 + Move-Item -Path $source -Destination $dest -Force + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Move-Item],PSArgumentNullException + FullyQualifiedErrorId : ArgumentNull,Microsoft.PowerShell.Commands.MoveItemCommand ✅ 已移动: System.Data.SQLite.dll -> SQLite\ Join-Path : 找不到接受实际参数“System.Data.SQLite.Linq.dll”的位置形式参数。 所在位置 行:32 字符: 13 + $dest = Join-Path $projectRoot "SQLite" $file + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Join-Path],ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.JoinPathCommand Move-Item : 无法处理参数,因为参数“destination”的值为空。请将参数“destination”的值更改为非空值。 所在位置 行:35 字符: 9 + Move-Item -Path $source -Destination $dest -Force + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Move-Item],PSArgumentNullException + FullyQualifiedErrorId : ArgumentNull,Microsoft.PowerShell.Commands.MoveItemCommand ✅ 已移动: System.Data.SQLite.Linq.dll -> SQLite\ Join-Path : 找不到接受实际参数“SQLite.Interop.dll”的位置形式参数。 所在位置 行:32 字符: 13 + $dest = Join-Path $projectRoot "SQLite" $file + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Join-Path],ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.JoinPathCommand Join-Path : 找不到接受实际参数“sqlite3.def”的位置形式参数。 所在位置 行:32 字符: 13 + $dest = Join-Path $projectRoot "SQLite" $file + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Join-Path],ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.JoinPathCommand Join-Path : 找不到接受实际参数“sqlite3.dll”的位置形式参数。 所在位置 行:32 字符: 13 + $dest = Join-Path $projectRoot "SQLite" $file + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Join-Path],ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.JoinPathCommand Join-Path : 找不到接受实际参数“SQLite.NET.chm”的位置形式参数。 所在位置 行:32 字符: 13 + $dest = Join-Path $projectRoot "SQLite" $file + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Join-Path],ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.JoinPathCommand ✅ 已移动数据库: northwindEF.db -> Database\ ✅ 已移动数据库: project_state.db -> Database\ ✅ 已移动脚本: Initialize-DevEnv.psm1 -> Scripts\ ✅ 已移动脚本: Monitor-Project.ps1 -> Scripts\ ✅ 已移动脚本: Start-Ecosystem.ps1 -> Scripts\ Move-Item : 参数错误。 所在位置 行:57 字符: 5 + Move-Item -Path $config.FullName -Destination (Join-Path $project ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (E:\ProjectEcosy...tMonitor\Config:DirectoryInfo) [Move-Item], IOException + FullyQualifiedErrorId : MoveDirectoryItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand ✅ 已移动配置: Config -> Config\ ✅ 已移动配置: System.Data.SQLite.dll.config -> Config\ ✅ 已移动配置: test.exe.config -> Config\ ✅ 已移动配置: testef6.exe.config -> Config\ ✅ 已移动配置: testlinq.exe.config -> Config\ ✨ 清理完成!项目目录已整理 ✨ 当前目录结构: 卷 ="模型响应", 的文件夹 PATH 列表 卷序列号为 7648-2CD3 E:\PROJECTECOSYSTEM\PROJECTMONITOR | db_init.py | Installer.exe | Installer.pdb | monitor.py | SQLite.Designer.dll | SQLite.Designer.pdb | SQLite.Designer.xml | state_analyzer.py | System.Data.SQLite.dll | System.Data.SQLite.EF6.dll | System.Data.SQLite.EF6.pdb | System.Data.SQLite.EF6.xml | System.Data.SQLite.Linq.dll | System.Data.SQLite.Linq.pdb | System.Data.SQLite.Linq.xml | System.Data.SQLite.pdb | System.Data.SQLite.xml | test.exe | test.pdb | testef6.exe | testef6.pdb | testlinq.exe | testlinq.pdb | +---APIServer | | .gitignore | | APIServer.code-workspace | | package.json | | | \---src | index.js | +---BackendService | | .gitignore | | BackendService.code-workspace | | BackendService.sln | | | \---src | \---BackendService | BackendService.csproj | Program.cs | +---Config | System.Data.SQLite.dll.config | test.exe.config | testef6.exe.config | testlinq.exe.config | +---DataAnalysis | | .gitignore | | DataAnalysis.code-workspace | | requirements.txt | | | \---src | main.py | +---Database | northwindEF.db | project_state.db | +---EcoMonitor | | .gitignore | | README.md | | | \---config | settings.psd1 | +---MyApp | | .gitignore | | MyApp.code-workspace | | | \---src | index.html | main.js | style.css | +---MyWebApp | | .gitignore | | MyWebApp.code-workspace | | | \---src | index.html | main.js | style.css | \---Scripts Initialize-DevEnv.psm1 Monitor-Project.ps1 Start-Ecosystem.ps1 PS C:\Users\Administrator>
08-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值