{"id":14980417,"url":"https://github.com/chanthmiao/devtools-win","last_synced_at":"2025-07-17T03:07:28.646Z","repository":{"id":245741652,"uuid":"365155125","full_name":"ChanthMiao/DevTools-Win","owner":"ChanthMiao","description":"个人在 Windows 下的自用的 Powershell 脚本集合，可以有效改善 Windows 下的开发体验。A collection of Powershell scripts for personal use under Windows, which can effectively improve the development experience under Windows.","archived":false,"fork":false,"pushed_at":"2024-11-02T05:00:45.000Z","size":95,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T03:18:25.965Z","etag":null,"topics":["clang","devtools-win","powershell","powershell-core","powershell-module","vs2019","windows-development"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChanthMiao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-07T07:46:09.000Z","updated_at":"2025-03-04T14:56:29.000Z","dependencies_parsed_at":"2024-06-23T20:46:51.738Z","dependency_job_id":"d8a79a93-919f-4b29-9ff6-5512d05dce4e","html_url":"https://github.com/ChanthMiao/DevTools-Win","commit_stats":null,"previous_names":["chanthmiao/devtools-win"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/ChanthMiao/DevTools-Win","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChanthMiao%2FDevTools-Win","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChanthMiao%2FDevTools-Win/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChanthMiao%2FDevTools-Win/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChanthMiao%2FDevTools-Win/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChanthMiao","download_url":"https://codeload.github.com/ChanthMiao/DevTools-Win/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChanthMiao%2FDevTools-Win/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265562197,"owners_count":23788480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clang","devtools-win","powershell","powershell-core","powershell-module","vs2019","windows-development"],"created_at":"2024-09-24T14:01:44.449Z","updated_at":"2025-07-17T03:07:28.629Z","avatar_url":"https://github.com/ChanthMiao.png","language":"PowerShell","readme":"# DevTools-Win\n\n~~为 Windows 用户设计的 Powershell 辅助开发模块。~~\n\n个人在 Windows 下的自用的 Powershell 脚本集合，可以有效改善 Windows 下的开发体验。\n\n![Icon2](https://cdn.jsdelivr.net/gh/ChanthMiao/DevTools-Win@main/assets/icon_64px.png)\n\n## 主要功能\n\n|       命令        | 别名  | 功能简述                                          |\n| :---------------: | :---: | :------------------------------------------------ |\n|   Set-WebProxy    |  swp  | 为当前Powershell会话设置网络代理                  |\n|  Clear-WebProxy   | clwp  | 清除当前Powershell会话的网络代理                  |\n|     Add-Path      |  apa  | 向环境变量（PATH一类）添加路径                    |\n|    Remove-Path    |  rpa  | 从环境变量（PATH一类）删除路径                    |\n|    Enter-VsEnv    | etvs  | 设定 VS 开发者 cli 环境                           |\n|   Enable-Clang    | ecla  | 设置运行clang必要的环境变量（LIB, INCLUDE, PATH） |\n|   Enable-Vcpkg    | evpg  | 为 cli 环境集成 vcpkg                             |\n|  Format-ItemSize  |  fis  | 字节单位换算，提高文件大小可读性                  |\n|   Get-ItemSize    |  gis  | 计算指定文件/文件夹大小                           |\n|    Get-TempDir    |  gtd  | 获取系统/用户临时文件夹                           |\n|  Get-CmdletAlias  | gcas  | 查询命令别名                                      |\n| Send-Notification | sdnf  | 发送桌面通知（可用作定时任务脚本的完成通知）      |\n|     Write-Log     | wrlg  | 简易日志接口，提高脚本可维护性                    |\n|     Start-Log     | salg  | 记录当前 Powershell 会话或脚本输出                |\n|     Stop-Log      | splg  | 停止记录当前 Powershell 会话或脚本输出            |\n|  New-RandString   |  nrs  | 生成随机字符串                                    |\n|   Enable-Python   |  epy  | 切换当前会话的Python环境                          |\n|  Set-RustMirror   | srsm  | 设置 rust 镜像                                    |\n\n## 命令详细文档\n\n~~暂无计划，此模块目前主要是自用~~（欢迎PR）\n\n## 安装\n\n主要安装方式有三：\n\n- 手动下载仓库[源码包](https://github.com/xmake-io/xmake/archive/refs/heads/master.zip)，并解压至 PSModulePath 所包含的路径下；\n- 进入 PSModulePath 所包含的路径，执行仓库克隆\n- ~~使用 scoop 进行安装~~（暂未实现）\n\n## 可选依赖库\n\n本模块唯一的可选依赖库为[适用于 .Net5 的 Windows SDK 库](https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref)。该库用于为切换至 .Net5 后的 Powershell Core 提供 WinRT API 支持，以实现 `Send-Notification` 命令。具体原因可参考一下两条链接内容：\n\n- \u003chttps://github.com/dotnet/runtime/issues/37672\u003e\n- \u003chttps://github.com/PowerShell/PowerShell/blob/master/CHANGELOG/7.1.md\u003e\n\n不需要在 Powershell Core 使用 `Send-Notification` 命令的用户，可在模块配置目录的创建名为disable-cswinrt的空文件（对应指令为`New-Item $Env:LOCALAPPDATA\\DevTools-Win\\disable-cswinrt -Force`）。\n\n需要使用此依赖的用户则遵照以下步的依赖安装：\n\n```ps1\n# 进入 DevTools.psd1 所在目录\ncd \"DevTools-Win\"\n# 设置http(s)代理（推荐网络受限地区用户采用）\n. .\\src\\public\\Set-WebProxy.ps1\nswp http://\u003c你的代理地址\u003e:\u003c你的代理端口\u003e\n# 首次加载模块，触发自动依赖下载和安装\nImport-Module \"DevTools-Win\"\n# 查看lib目录，依赖文件已就绪\nls .\\lib\n# \n#     Directory: C:\\Users\\shiel\\source\\modules\\DevTools-Win\\lib\n# \n# Mode                 LastWriteTime         Length Name\n# ----                 -------------         ------ ----\n# -a---           2021/4/13    20:26       26685320 Microsoft.Windows.SDK.NET.dll\n# -a---           2021/4/13    20:26         300424 WinRT.Runtime.dll\n# \n```\n\n后续如果需要更新依赖库文件，仅需手动删除上述 lib 路径，以在在下次加载触发依赖安装。\n\n## 自定义配置\n\n自定义配置存放于目录`$Env:LOCALAPPDATA\\DevTools-Win`下的 config.json 文件（不支持注释）内，用于覆盖默认配置。\n\n```json5\n{\n    \"Proxy\": \"http://192.168.36.1:8080\", // 避免每次使用swp时重复输入，可被$Env:HTTP(S)_PROXY覆盖，默认为空\n    \"VsWhere\": \"C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\Installer\\\\vswhere.exe\", // 指定vswhere程序路径，可被$Env:VSWHERE_PATH覆盖\n    \"VcpkgRoot\": \"C:\\\\Users\\\\abc\\\\source\\\\repos\\\\vcpkg\", // 指定 vcpkg 根目录，可被$Env:VCPKG_ROOT覆盖，默认为空\n    \"Clang\": \"C:\\\\Users\\\\abc\\\\scoop\\\\shims\\\\clang.ps1\", // 指定 clang 路径，可被$Env:CLANG_PATH覆盖，默认为空\n    \"PyRoot\": \"C:\\\\Users\\\\abc\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python38\", // 指定 Python 根目录，可被$Env:Py_ROOT覆盖，默认自动检测\n    \"RustMirror\": \"rsproxy\" // 指定 rust 镜像源名称，默认为rsproxy\n}\n```\n\n自v1.1.2起，提供`Get-DtwConfig, Set-DtwConfig`快速查/更改配置。如果需要令更改永久生效，执行命令`Show-DtwConfig|ConvertTo-Json|Out-File $Env:LOCALAPPDATA\\DevTools-Win\\config.json`。\n\n## 兼容性\n\n本模块基于自用脚本打包分享。我个人的主要使用环境为 Windows 10 + Powershell Core + Windows Terminal。在正式发布前，已针对 Windows Powershell 5.1 进行了一定程度的兼容性适配，但不保证 100% 兼容。\n\n微软当前对Powershell的开发重心已全方面倾斜至 Powershell Core，原 Windows Powershell 5.1 仅做兼容性保留（实际使用上，我已遇到不少Bug，但长期未修复）。考虑到目前二者间差异和维护状态，个人建议用户迁移至 Powershell Core。\n\n## Dirty Hack\n\n由于 .Net 技术栈本身的限制，`Remove-Module` 无法卸载 Assembly 文件。这会导致烦人的文件占用问题。为了克服这一问题，`Send-Notification` 命令在实现上采用了一点小技巧。通过 `Start-Job` 创建后台任务的副作用（脱离当前会话），使 Assembly 文件的加载限定在新的 AppDomain 内。这样，Assembly 文件会在任务完成后自动完成卸载（随新 AppDomain 一起被卸载）。\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanthmiao%2Fdevtools-win","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchanthmiao%2Fdevtools-win","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanthmiao%2Fdevtools-win/lists"}