D:删除构建文件,增加调试脚本

This commit is contained in:
jimmy committed 2025-12-29 10:08:26 +08:00
1 parent 3b89b2d722
commit d133bacf55
40 files changed
+1180 -1066

No files matched your search

-216
View File
@@ -1,216 +0,0 @@
# 项目元数据清理总结
## ✅ 已完成的任务
### 1. Git 清理
- ✅ 从 Git 中移除了 `src/Sharp/Wpf/obj/` 文件夹下的所有 22 个文件
- ✅ 确认其他模块没有 obj/bin 文件被错误追踪
- ✅ `.gitignore` 已正确配置 `obj/` 和 `bin/` 规则
### 2. 元数据统一管理
#### 创建的核心文件
- **`Directory.Build.props`** - 集中管理所有项目的元数据
- 版本:1.0.1
- 作者:duyl328
- 版权:Copyright © 2024-2025 duyl328
- 仓库:https://gitea.duyl328.org/jimmy/sharp-basic
- 许可证:AGPL-3.0-or-later
- 项目描述、标签等
#### 清理的项目文件
成功清理了 **17 个项目文件**,移除了冗余的元数据:
**已清理的项目**:
1. Cache.csproj
2. Common.csproj
3. Config.csproj
4. Data.csproj
5. EventBus.csproj
6. Log.csproj
7. NetClient.csproj
8. NetServer.csproj
9. Plc.csproj
10. Plc.Siemens.csproj
11. Ports.csproj
12. Process.csproj
13. Python.csproj
14. Sharp.Demo.csproj
15. Wpf.csproj
16. Wpf.DevTools.csproj
17. Wpf.HandyControl.csproj
**每个项目移除了 12 个冗余属性**:
- Version, AssemblyVersion, FileVersion
- Authors, Company, Product, Copyright
- PackageId, PackageProjectUrl, RepositoryUrl, RepositoryType, PackageLicenseExpression
**保留的项目特有属性**:
- `Description` - 每个项目的独特描述
- `PackageTags` - 每个项目的特定标签
### 3. 项目元数据验证
#### 清理前的项目文件(以 Common.csproj 为例)
```xml
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<!-- ... -->
<Version>1.0.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Authors>Sharp Team</Authors>
<Company>Sharp Team</Company>
<Product>Sharp Framework</Product>
<Copyright>Copyright © 2024 Sharp Team</Copyright>
<Description>...</Description>
<PackageId>Sharp.Common</PackageId>
<PackageProjectUrl>https://github.com/your-org/sharp-basic</PackageProjectUrl>
<RepositoryUrl>https://github.com/your-org/sharp-basic</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>...</PackageTags>
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
</PropertyGroup>
```
#### 清理后的项目文件
```xml
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Description>Sharp Framework 核心库 - 提供 Result<T> 模式、Global 容器、系统配置等基础功能</Description>
<PackageTags>sharp;common;result;railway-oriented;functional;utilities</PackageTags>
</PropertyGroup>
```
**优势**:
- 📉 代码大幅减少(从 ~25 行元数据减少到 2 行)
- 🔄 统一管理:版本、作者、许可证等在一处更新
- ✨ 保持灵活性:每个项目保留独特的描述和标签
### 4. 创建的工具脚本
**`update-metadata.ps1`**
- 自动清理所有项目文件的冗余元数据
- 可重复运行,安全无副作用
- 详细日志输出,显示每个项目的处理结果
使用方法:
```powershell
cd src/Sharp
powershell -ExecutionPolicy Bypass -File update-metadata.ps1
```
## 📋 Git 变更概览
```
修改的文件 (M):
- 17 个 .csproj 项目文件(清理元数据)
- LICENSE(更新版权声明)
- README.md(添加项目信息和徽章)
删除的文件 (D):
- src/Sharp/Wpf/obj/** (22 个文件)
新增的文件 (??):
- AUTHORS
- CHANGELOG.md
- CONTRIBUTING.md
- NOTICE
- PROJECT_METADATA_SUMMARY.md
- METADATA_CLEANUP_SUMMARY.md
- src/Sharp/Directory.Build.props
- src/Sharp/update-metadata.ps1
```
## 🎯 元数据继承关系
```
Directory.Build.props (父级)
│
├─→ 所有项目自动继承:
│ • Version: 1.0.1
│ • Authors: duyl328
│ • Company: duyl328
│ • Product: Sharp-Basic Framework
│ • Copyright: Copyright © 2024-2025 duyl328
│ • Description: 模块化.NET 8企业应用开发框架
│ • RepositoryUrl: https://gitea.duyl328.org/jimmy/sharp-basic
│ • PackageLicenseExpression: AGPL-3.0-or-later
│ • PackageTags: wpf;mvvm;dotnet;framework;...
│ • ... 其他编译和包设置
│
└─→ 各项目.csproj (子级)
• 只定义项目特有的属性
• Description (覆盖父级的通用描述)
• PackageTags (覆盖父级的通用标签)
```
## ✨ 效果验证
### 构建测试
```bash
cd src/Sharp
dotnet build Sharp.sln -c Release
```
### 查看生成的程序集信息
```bash
# 所有程序集应显示:
# Version: 1.0.1.0
# FileVersion: 1.0.1.0
# Company: duyl328
# Product: Sharp-Basic Framework
# Copyright: Copyright © 2024-2025 duyl328. All rights reserved.
```
### 打包验证
```bash
dotnet pack Common/Common.csproj -c Release -o ./nupkg
# 检查生成的 .nupkg 文件元数据
# 应包含从 Directory.Build.props 继承的所有信息
```
## 📝 下一步建议
1. **提交更改**
```bash
git add .
git commit -m "A:统一项目元数据管理
- 创建 Directory.Build.props 集中管理元数据
- 清理所有项目文件的冗余元数据(17个项目)
- 从 Git 中移除 Wpf/obj 文件夹
- 添加完整的项目文档(AUTHORS, CHANGELOG, CONTRIBUTING, NOTICE)
- 更新 LICENSE 和 README.md
版本: 1.0.1
作者: duyl328
许可证: AGPL-3.0-or-later"
```
2. **创建 Git 标签**
```bash
git tag -a v1.0.1 -m "Release version 1.0.1"
git push origin v1.0.1
```
3. **发布 NuGet 包**(如果需要)
```bash
dotnet pack -c Release
# 将 nupkg 文件发布到 NuGet 或私有包源
```
## 🎉 完成状态
✅ Wpf/obj 文件夹已从 Git 中移除
✅ 所有 17 个模块的元数据已清理并统一
✅ Directory.Build.props 正确配置
✅ 项目文档完整(LICENSE, AUTHORS, CONTRIBUTING, CHANGELOG, NOTICE)
✅ README.md 包含徽章和项目信息
✅ 自动化清理脚本可供未来使用
**项目现在是一个标准的、专业的、元数据管理规范的开源项目!** 🎊
-152
View File
@@ -1,152 +0,0 @@
# 项目元数据配置总结
本文档总结了 Sharp-Basic Framework v1.0.1 的元数据配置。
## ✅ 已完成的配置
### 1. 核心元数据文件
#### `Directory.Build.props` (src/Sharp/)
- ✅ 作者: duyl328
- ✅ 版权: Copyright © 2024-2025 duyl328
- ✅ 版本: 1.0.1
- ✅ 仓库: https://gitea.duyl328.org/jimmy/sharp-basic
- ✅ 许可证: AGPL-3.0-or-later
- ✅ 项目描述: 模块化.NET 8企业应用开发框架
- ✅ 包标签: wpf;mvvm;dotnet;framework;plc;industrial;iot;siemens;ef-core;serilog;configuration
- ✅ 源代码链接支持 (Source Link for Gitea)
- ✅ 确定性构建配置
### 2. 许可证文件
#### `LICENSE`
- ✅ GNU AGPL v3.0 完整文本
- ✅ 更新版权声明示例
### 3. 项目文档
#### `README.md`
- ✅ 项目徽章(版本、许可证、.NET版本)
- ✅ 项目信息(版本、作者、仓库、许可证)
- ✅ 详细的许可证说明(包含网络服务条款)
- ✅ 作者信息和链接
- ✅ 版权声明
#### `AUTHORS`
- ✅ 主要作者信息
- ✅ 贡献者列表框架
#### `CONTRIBUTING.md`
- ✅ 行为准则
- ✅ Bug 报告指南
- ✅ 功能请求流程
- ✅ 代码规范(命名、注释、风格)
- ✅ 测试要求
- ✅ 提交信息规范
- ✅ Pull Request 流程
- ✅ 开发环境设置
#### `CHANGELOG.md`
- ✅ 版本 1.0.1 变更记录
- ✅ 版本 1.0.0 初始发布记录
- ✅ 版本号规范说明
- ✅ 变更类型定义
#### `NOTICE`
- ✅ 项目版权声明
- ✅ 第三方依赖列表及其许可证
- Microsoft.Extensions.*
- Entity Framework Core
- Serilog
- Polly
- HandyControl
- S7.NET+
- Tomlyn
## 📋 NuGet 包元数据
所有项目现在继承以下元数据(通过 Directory.Build.props):
```xml
<Authors>duyl328</Authors>
<Company>duyl328</Company>
<Product>Sharp-Basic Framework</Product>
<Description>模块化.NET 8企业应用开发框架</Description>
<Copyright>Copyright © 2024-2025 duyl328. All rights reserved.</Copyright>
<VersionPrefix>1.0.1</VersionPrefix>
<RepositoryUrl>https://gitea.duyl328.org/jimmy/sharp-basic</RepositoryUrl>
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
<PackageTags>wpf;mvvm;dotnet;framework;plc;industrial;iot;siemens;ef-core;serilog;configuration;csharp;enterprise;modular;iiot</PackageTags>
```
## 🔍 下一步建议
### 可选的额外文件
1. **CODE_OF_CONDUCT.md** - 社区行为准则
- 推荐使用 Contributor Covenant
- 定义社区标准和执法机制
2. **SECURITY.md** - 安全策略
- 如何报告安全漏洞
- 支持的版本
- 披露政策
3. **.editorconfig** - 编辑器配置
- 统一代码风格
- 适用于所有贡献者
4. **Issue/PR 模板** (Gitea 支持)
- `.gitea/ISSUE_TEMPLATE/bug_report.md`
- `.gitea/ISSUE_TEMPLATE/feature_request.md`
- `.gitea/PULL_REQUEST_TEMPLATE.md`
5. **Badges 徽章增强**
- 构建状态(如果有 CI)
- 测试覆盖率
- NuGet 下载量
- 文档链接
### 持续维护
- 📅 定期更新 CHANGELOG.md
- 👥 更新 AUTHORS 文件添加新贡献者
- 📦 发布新版本时更新版本号
- 📄 保持文档与代码同步
## 🎯 标准合规性检查
✅ **开源许可证**: AGPL-3.0-or-later
✅ **版本管理**: 语义化版本 1.0.1
✅ **版权声明**: 所有必要文件已包含
✅ **第三方归属**: NOTICE 文件已创建
✅ **贡献流程**: CONTRIBUTING.md 已完善
✅ **变更跟踪**: CHANGELOG.md 已建立
✅ **作者信息**: AUTHORS 文件已创建
✅ **项目描述**: README.md 详细且专业
## 📝 维护命令
### 更新版本号
```powershell
# 编辑 Directory.Build.props
# 更新 <VersionPrefix> 标签
# 更新 CHANGELOG.md 添加新版本记录
```
### 构建 NuGet 包
```bash
dotnet pack -c Release
```
### 验证元数据
```bash
dotnet pack --no-build -c Release -o ./nupkg
# 检查生成的 .nupkg 文件的元数据
```
---
**项目现在已符合标准开源项目的要求!** 🎉
所有元数据已正确配置,文档完善,准备好发布和接受贡献。
+7
View File
@@ -0,0 +1,7 @@
@echo off
REM ========================================
REM 快速启动开发工具菜单
REM ========================================
cd /d "%~dp0\scripts"
call dev.bat
+199
View File
@@ -0,0 +1,199 @@
# Sharp-Basic 开发脚本工具
此目录包含用于开发 Sharp-Basic 项目的实用脚本工具。
## 快速开始
**推荐方式:** 在项目根目录双击 `dev.bat`,或在 `scripts` 目录双击 `dev.bat`,会显示交互式菜单。
## ⚠️ 重要说明
1. **清理后必须还原**: `clean.bat` 会删除 bin/obj 目录,删除后**必须运行 restore.bat** 还原 NuGet 包才能构建
2. **推荐使用 rebuild.bat**: 它会自动完成 清理 → 还原 → 构建 的完整流程
3. **首次使用**: 建议先运行 `verify.bat` 验证环境配置
## 脚本列表
### 批处理脚本 (.bat)
| 脚本 | 功能 | 说明 |
|------|------|------|
| `clean.bat` | 清理构建产物 | 删除所有 bin、obj 目录并运行 dotnet clean |
| `build.bat` | 构建解决方案 | Release 模式编译整个解决方案 |
| `rebuild.bat` | 重新构建 | 先清理再构建 |
| `restore.bat` | 还原 NuGet 包 | 恢复所有依赖包 |
| `test.bat` | 运行单元测试 | 执行所有测试项目并显示详细日志 |
| `run-demo.bat` | 运行演示应用 | 启动 Sharp.Demo 应用程序 |
| `format.bat` | 代码格式化 | 使用 dotnet format 统一代码风格 |
| `dev.bat` | 开发菜单 | 交互式菜单,集成所有功能 ⭐ **推荐** |
| `verify.bat` | 验证环境 | 检查开发环境和项目配置是否正常 |
### PowerShell 脚本 (.ps1)
| 脚本 | 功能 | 说明 |
|------|------|------|
| `clean-deep.ps1` | 深度清理 | 删除所有构建产物、缓存、临时文件,可选清理 NuGet 全局缓存 |
## 使用方法
### 方式一:交互式菜单(推荐)
```cmd
# 在项目根目录
dev.bat
# 或进入 scripts 目录
cd scripts
dev.bat
```
菜单选项:
```
[1] 清理项目 (clean)
[2] 还原包 (restore)
[3] 构建项目 (build)
[4] 重新构建 (rebuild)
[5] 运行测试 (test)
[6] 运行演示应用 (run-demo)
[7] 格式化代码 (format)
[8] 深度清理 (PowerShell)
[0] 退出
```
### 方式二:直接运行单个脚本
```cmd
# 进入 scripts 目录
cd scripts
# 运行具体脚本
clean.bat # 清理项目
build.bat # 构建项目
test.bat # 运行测试
```
### 方式三:PowerShell 深度清理
```powershell
# 在 scripts 目录
.\clean-deep.ps1
# 或从项目根目录
powershell -ExecutionPolicy Bypass -File scripts\clean-deep.ps1
```
## 常见使用场景
### 场景 1:日常开发
```cmd
dev.bat
# 选择 3 (构建) 或 6 (运行演示)
```
### 场景 2:遇到编译问题或缓存问题
```cmd
# 推荐方式 - 自动处理所有步骤
cd scripts
rebuild.bat # 清理 + 还原 + 重新构建
# 手动方式 - 分步执行
cd scripts
clean.bat # 清理
restore.bat # 还原包(必须!)
build.bat # 构建
```
### 场景 3:代码提交前
```cmd
cd scripts
format.bat # 格式化代码
test.bat # 确保测试通过
```
### 场景 4:解决缓存问题
```cmd
cd scripts
.\clean-deep.ps1 # PowerShell 深度清理
```
### 场景 5:克隆项目后首次构建
```cmd
cd scripts
restore.bat # 还原 NuGet 包
build.bat # 构建项目
```
## 脚本功能详解
### clean.bat - 清理构建产物
- 运行 `dotnet clean Sharp.sln`
- 使用 PowerShell 递归删除所有 `bin` 和 `obj` 目录
- **重要**: 清理后必须运行 `restore.bat` 还原 NuGet 包
- 用于解决编译缓存问题
### rebuild.bat - 完整重建 ⭐ **推荐用于清理场景**
- 步骤 1: 清理所有构建产物
- 步骤 2: 还原 NuGet 包
- 步骤 3: Release 模式重新构建
- 自动处理依赖关系,一次性完成所有操作
### clean-deep.ps1 - 深度清理
除了 clean.bat 的功能外,还包括:
- 删除 `.vs` 目录(Visual Studio 缓存)
- 删除 `TestResults` 目录
- 删除临时文件:*.tmp, *.temp, *.log, *.cache, *.bak, *.user
- 可选清理 NuGet 全局缓存(需确认)
- 显示删除统计信息
### build.bat - 构建解决方案
- 使用 Release 配置编译
- 显示构建结果(成功/失败)
- 返回错误代码
### rebuild.bat - 重新构建
- 先运行 clean.bat
- 再运行 build.bat
- 确保干净的构建环境
### test.bat - 运行单元测试
- 使用 Debug 配置
- 详细日志输出
- 显示测试结果统计
### restore.bat - 还原 NuGet 包
- 恢复所有项目依赖
- 适用于克隆项目后首次构建
### format.bat - 代码格式化
- 使用 `dotnet format` 工具
- 统一代码风格
- 建议提交前运行
### run-demo.bat - 运行演示应用
- 启动 Sharp.Demo WPF 应用
- 用于快速测试功能
## 注意事项
1. **PowerShell 执行策略**:如果无法运行 PowerShell 脚本,需要设置执行策略:
```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```
2. **路径问题**:所有脚本都会自动切换到正确的目录,无需手动 cd
3. **深度清理警告**:`clean-deep.ps1` 会提示是否清理 NuGet 全局缓存,清理后需要重新下载所有包
4. **编码问题**:所有脚本使用 UTF-8 编码,支持中文显示
## 自定义和扩展
如需添加新脚本:
1. 在 `scripts` 目录创建新的 .bat 或 .ps1 文件
2. 使用 `cd /d "%~dp0\.."` 切换到项目根目录(批处理)
3. 使用 `Set-Location (Join-Path $PSScriptRoot "..")` 切换到项目根目录(PowerShell)
4. 可选:在 `dev.bat` 菜单中添加新选项
## 许可证
遵循 Sharp-Basic 项目的 GNU AGPLv3 许可证。
+45
View File
@@ -0,0 +1,45 @@
@echo off
REM ========================================
REM 构建脚本 - 编译整个解决方案
REM ========================================
echo.
echo ==========================================
echo 构建 Sharp-Basic 解决方案
echo ==========================================
echo.
REM 切换到项目根目录
cd /d "%~dp0\.."
REM 切换到解决方案目录
cd src\Sharp
echo 正在检查是否需要还原 NuGet 包...
dotnet restore Sharp.sln --verbosity quiet
if %ERRORLEVEL% NEQ 0 (
echo 警告: NuGet 包还原失败
)
echo.
echo 正在构建解决方案...
echo.
dotnet build Sharp.sln --configuration Release
if %ERRORLEVEL% EQU 0 (
echo.
echo ==========================================
echo 构建成功!
echo ==========================================
) else (
echo.
echo ==========================================
echo 构建失败!错误代码: %ERRORLEVEL%
echo ==========================================
echo.
echo 提示: 如果缺少依赖包,请先运行 restore.bat
)
cd ..\..
echo.
pause
+95
View File
@@ -0,0 +1,95 @@
# ========================================
# PowerShell 深度清理脚本
# 删除所有构建产物、缓存、临时文件
# ========================================
Write-Host ""
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host "Sharp-Basic 深度清理工具" -ForegroundColor Cyan
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host ""
# 切换到项目根目录
Set-Location (Join-Path $PSScriptRoot "..")
# 统计删除的目录和文件数量
$deletedDirs = 0
$deletedFiles = 0
# 1. 删除所有 bin 目录
Write-Host "[1/7] 正在删除所有 bin 目录..." -ForegroundColor Yellow
Get-ChildItem -Path . -Recurse -Directory -Filter "bin" -ErrorAction SilentlyContinue | ForEach-Object {
Write-Host " 删除: $($_.FullName)" -ForegroundColor Gray
Remove-Item $_.FullName -Recurse -Force -ErrorAction SilentlyContinue
$deletedDirs++
}
# 2. 删除所有 obj 目录
Write-Host ""
Write-Host "[2/7] 正在删除所有 obj 目录..." -ForegroundColor Yellow
Get-ChildItem -Path . -Recurse -Directory -Filter "obj" -ErrorAction SilentlyContinue | ForEach-Object {
Write-Host " 删除: $($_.FullName)" -ForegroundColor Gray
Remove-Item $_.FullName -Recurse -Force -ErrorAction SilentlyContinue
$deletedDirs++
}
# 3. 删除 .vs 目录(Visual Studio 缓存)
Write-Host ""
Write-Host "[3/7] 正在删除 .vs 目录..." -ForegroundColor Yellow
Get-ChildItem -Path . -Recurse -Directory -Filter ".vs" -Force -ErrorAction SilentlyContinue | ForEach-Object {
Write-Host " 删除: $($_.FullName)" -ForegroundColor Gray
Remove-Item $_.FullName -Recurse -Force -ErrorAction SilentlyContinue
$deletedDirs++
}
# 4. 删除 TestResults 目录
Write-Host ""
Write-Host "[4/7] 正在删除 TestResults 目录..." -ForegroundColor Yellow
Get-ChildItem -Path . -Recurse -Directory -Filter "TestResults" -ErrorAction SilentlyContinue | ForEach-Object {
Write-Host " 删除: $($_.FullName)" -ForegroundColor Gray
Remove-Item $_.FullName -Recurse -Force -ErrorAction SilentlyContinue
$deletedDirs++
}
# 5. 删除临时文件
Write-Host ""
Write-Host "[5/7] 正在删除临时文件..." -ForegroundColor Yellow
$tempPatterns = @("*.tmp", "*.temp", "*.log", "*.cache", "*.bak", "*.user")
foreach ($pattern in $tempPatterns) {
Get-ChildItem -Path . -Recurse -File -Filter $pattern -ErrorAction SilentlyContinue | ForEach-Object {
Write-Host " 删除: $($_.FullName)" -ForegroundColor Gray
Remove-Item $_.FullName -Force -ErrorAction SilentlyContinue
$deletedFiles++
}
}
# 6. 使用 dotnet clean
Write-Host ""
Write-Host "[6/7] 使用 dotnet clean 清理解决方案..." -ForegroundColor Yellow
Push-Location "src\Sharp"
dotnet clean Sharp.sln --verbosity minimal
Pop-Location
# 7. 清理 NuGet 包缓存(可选,慎用)
Write-Host ""
Write-Host "[7/7] 是否清理 NuGet 包缓存?" -ForegroundColor Yellow
Write-Host " 警告: 这将删除所有缓存的 NuGet 包,下次构建需要重新下载" -ForegroundColor Red
$response = Read-Host " 输入 'yes' 继续,任意键跳过"
if ($response -eq 'yes') {
Write-Host " 正在清理 NuGet 缓存..." -ForegroundColor Gray
dotnet nuget locals all --clear
} else {
Write-Host " 已跳过 NuGet 缓存清理" -ForegroundColor Gray
}
# 显示统计信息
Write-Host ""
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host "清理完成!" -ForegroundColor Green
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host "删除的目录数: $deletedDirs" -ForegroundColor White
Write-Host "删除的文件数: $deletedFiles" -ForegroundColor White
Write-Host ""
# 暂停以便查看结果
Read-Host "按回车键退出"
+37
View File
@@ -0,0 +1,37 @@
@echo off
REM ========================================
REM 清理脚本 - 删除所有 bin, obj 目录
REM ========================================
echo.
echo ==========================================
echo 清理 Sharp-Basic 项目构建产物
echo ==========================================
echo.
REM 切换到项目根目录
cd /d "%~dp0\.."
echo [1/2] 使用 dotnet clean 清理解决方案...
cd src\Sharp
dotnet clean Sharp.sln --verbosity quiet
if %ERRORLEVEL% NEQ 0 (
echo 警告: dotnet clean 执行失败
)
cd ..\..
echo.
echo [2/2] 正在删除所有 bin 和 obj 目录...
REM 使用 PowerShell 进行更可靠的删除
powershell -NoProfile -ExecutionPolicy Bypass -Command "Get-ChildItem -Path '.' -Include bin,obj -Recurse -Directory -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue"
echo.
echo ==========================================
echo 清理完成!
echo ==========================================
echo.
echo 提示: 清理后需要运行 restore.bat 还原 NuGet 包
echo 或直接运行 rebuild.bat 进行完整重建
echo.
pause
+94
View File
@@ -0,0 +1,94 @@
@echo off
REM ========================================
REM 开发环境快速启动脚本
REM ========================================
REM 切换到脚本目录
cd /d "%~dp0"
:menu
cls
echo.
echo ==========================================
echo Sharp-Basic 开发工具菜单
echo ==========================================
echo.
echo 当前目录: %CD%
echo.
echo 常用操作:
echo [1] 清理项目 (clean)
echo [2] 还原 NuGet 包 (restore)
echo [3] 构建项目 (build)
echo [4] 重新构建 (clean + restore + build)
echo [5] 运行测试 (test)
echo [6] 运行演示应用 (run-demo)
echo.
echo 高级操作:
echo [7] 格式化代码 (format)
echo [8] 深度清理 (PowerShell - 包含缓存清理)
echo.
echo [0] 退出
echo.
echo ==========================================
echo.
set /p choice="请输入选项 (0-8): "
if "%choice%"=="1" goto clean
if "%choice%"=="2" goto restore
if "%choice%"=="3" goto build
if "%choice%"=="4" goto rebuild
if "%choice%"=="5" goto test
if "%choice%"=="6" goto run
if "%choice%"=="7" goto format
if "%choice%"=="8" goto deep
if "%choice%"=="0" goto exit
echo.
echo 无效选项!请输入 0-8 之间的数字
timeout /t 2 >nul
goto menu
:clean
cls
call clean.bat
goto menu
:restore
cls
call restore.bat
goto menu
:build
cls
call build.bat
goto menu
:rebuild
cls
call rebuild.bat
goto menu
:test
cls
call test.bat
goto menu
:run
cls
call run-demo.bat
goto menu
:format
cls
call format.bat
goto menu
:deep
cls
powershell -ExecutionPolicy Bypass -File clean-deep.ps1
pause
goto menu
:exit
exit
+53
View File
@@ -0,0 +1,53 @@
@echo off
REM ========================================
REM 代码格式化脚本
REM ========================================
echo.
echo ==========================================
echo 格式化 C# 代码
echo ==========================================
echo.
REM 切换到项目根目录
cd /d "%~dp0\.."
REM 切换到解决方案目录
cd src\Sharp
REM 检查 dotnet format 是否可用
dotnet format --version >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo 错误: dotnet format 工具不可用
echo.
echo 请安装 dotnet format:
echo dotnet tool install -g dotnet-format
echo.
cd ..\..
pause
exit /b 1
)
echo 正在格式化代码...
echo.
dotnet format Sharp.sln --verbosity diagnostic
if %ERRORLEVEL% EQU 0 (
echo.
echo ==========================================
echo 代码格式化完成!
echo ==========================================
) else (
echo.
echo ==========================================
echo 代码格式化失败!错误代码: %ERRORLEVEL%
echo ==========================================
echo.
echo 可能的原因:
echo 1. 代码存在语法错误
echo 2. 某些文件被占用
)
cd ..\..
echo.
pause
+57
View File
@@ -0,0 +1,57 @@
@echo off
REM ========================================
REM 重新构建脚本 - 清理、还原、重新编译
REM ========================================
echo.
echo ==========================================
echo 重新构建 Sharp-Basic 解决方案
echo ==========================================
echo.
REM 切换到项目根目录
cd /d "%~dp0\.."
echo [步骤 1/3] 清理项目...
cd src\Sharp
dotnet clean Sharp.sln --verbosity quiet
cd ..\..
powershell -NoProfile -ExecutionPolicy Bypass -Command "Get-ChildItem -Path '.' -Include bin,obj -Recurse -Directory -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue"
echo 清理完成
echo.
echo [步骤 2/3] 还原 NuGet 包...
cd src\Sharp
dotnet restore Sharp.sln --verbosity quiet
if %ERRORLEVEL% NEQ 0 (
echo.
echo ==========================================
echo NuGet 包还原失败!
echo ==========================================
cd ..\..
pause
exit /b 1
)
echo 还原完成
cd ..\..
echo.
echo [步骤 3/3] 构建解决方案...
cd src\Sharp
dotnet build Sharp.sln --configuration Release --no-restore
if %ERRORLEVEL% EQU 0 (
echo.
echo ==========================================
echo 重新构建成功!
echo ==========================================
) else (
echo.
echo ==========================================
echo 构建失败!错误代码: %ERRORLEVEL%
echo ==========================================
)
cd ..\..
echo.
pause
+43
View File
@@ -0,0 +1,43 @@
@echo off
REM ========================================
REM NuGet 包还原脚本
REM ========================================
echo.
echo ==========================================
echo 还原 NuGet 包
echo ==========================================
echo.
REM 切换到项目根目录
cd /d "%~dp0\.."
REM 切换到解决方案目录
cd src\Sharp
echo 正在还原 NuGet 包...
echo.
dotnet restore Sharp.sln --verbosity minimal
if %ERRORLEVEL% EQU 0 (
echo.
echo ==========================================
echo NuGet 包还原成功!
echo ==========================================
echo.
echo 提示: 现在可以运行 build.bat 进行构建
) else (
echo.
echo ==========================================
echo NuGet 包还原失败!错误代码: %ERRORLEVEL%
echo ==========================================
echo.
echo 可能的原因:
echo 1. 网络连接问题
echo 2. NuGet 源配置问题
echo 3. 项目文件损坏
)
cd ..\..
echo.
pause
+44
View File
@@ -0,0 +1,44 @@
@echo off
REM ========================================
REM 运行演示应用
REM ========================================
echo.
echo ==========================================
echo 启动 Sharp.Demo 应用程序
echo ==========================================
echo.
REM 切换到项目根目录
cd /d "%~dp0\.."
REM 切换到解决方案目录
cd src\Sharp
REM 检查项目是否存在
if not exist "Sharp.Demo\Sharp.Demo.csproj" (
echo 错误: 找不到 Sharp.Demo 项目!
echo 项目路径: Sharp.Demo\Sharp.Demo.csproj
cd ..\..
pause
exit /b 1
)
echo 正在启动应用...
echo.
dotnet run --project Sharp.Demo\Sharp.Demo.csproj
if %ERRORLEVEL% NEQ 0 (
echo.
echo ==========================================
echo 应用启动失败!错误代码: %ERRORLEVEL%
echo ==========================================
echo.
echo 可能的原因:
echo 1. 项目未构建,请先运行 build.bat
echo 2. 缺少依赖包,请先运行 restore.bat
echo 3. 代码存在编译错误
)
cd ..\..
pause
+41
View File
@@ -0,0 +1,41 @@
@echo off
REM ========================================
REM 测试脚本 - 运行所有单元测试
REM ========================================
echo.
echo ==========================================
echo 运行 Sharp-Basic 单元测试
echo ==========================================
echo.
REM 切换到项目根目录
cd /d "%~dp0\.."
REM 切换到解决方案目录
cd src\Sharp
echo 正在还原依赖并构建测试项目...
dotnet restore Sharp.sln --verbosity quiet
dotnet build Sharp.sln --configuration Debug --verbosity quiet
echo.
echo 正在运行测试...
echo.
dotnet test Sharp.sln --configuration Debug --no-build --verbosity normal
if %ERRORLEVEL% EQU 0 (
echo.
echo ==========================================
echo 所有测试通过!
echo ==========================================
) else (
echo.
echo ==========================================
echo 测试失败!错误代码: %ERRORLEVEL%
echo ==========================================
)
cd ..\..
echo.
pause
+55
View File
@@ -0,0 +1,55 @@
@echo off
REM ========================================
REM 验证脚本功能
REM ========================================
echo.
echo ==========================================
echo 验证 Sharp-Basic 脚本工具
echo ==========================================
echo.
cd /d "%~dp0\.."
echo [测试 1] 检查解决方案文件...
if exist "src\Sharp\Sharp.sln" (
echo [OK] 找到 Sharp.sln
) else (
echo [FAIL] 未找到 Sharp.sln
)
echo.
echo [测试 2] 检查 dotnet 版本...
dotnet --version
if %ERRORLEVEL% EQU 0 (
echo [OK] dotnet CLI 可用
) else (
echo [FAIL] dotnet CLI 不可用
)
echo.
echo [测试 3] 测试清理功能(扫描 bin/obj 目录)...
powershell -NoProfile -ExecutionPolicy Bypass -Command "$dirs = Get-ChildItem -Path 'src\Sharp' -Include bin,obj -Recurse -Directory -Force -ErrorAction SilentlyContinue; Write-Host \" 找到 $($dirs.Count) 个 bin/obj 目录\""
echo.
echo [测试 4] 检查项目文件完整性...
set /a count=0
for %%f in (src\Sharp\Common\Common.csproj src\Sharp\Config\Config.csproj src\Sharp\Wpf\Wpf.csproj) do (
if exist "%%f" (
set /a count+=1
)
)
echo [OK] 找到 %count% 个核心项目文件
echo.
echo ==========================================
echo 验证完成
echo ==========================================
echo.
echo 建议使用步骤:
echo 1. 运行 restore.bat - 还原 NuGet 包
echo 2. 运行 build.bat - 构建项目
echo 或直接运行 rebuild.bat - 完整重建
echo.
pause
+16
View File
@@ -0,0 +1,16 @@
{
"permissions": {
"allow": [
"Bash(dir:*)",
"Bash(cd:*)",
"Bash(grep:*)",
"Bash(dotnet sln:*)",
"Bash(dotnet build:*)",
"Bash(dotnet restore:*)",
"Bash(dotnet list:*)",
"Bash(dotnet new:*)",
"Bash(rm:*)",
"Bash(findstr:*)"
]
}
}
+394
View File
@@ -0,0 +1,394 @@
# Sharp.Process & Sharp.Python 使用示例
## 示例1:在 WPF 应用中使用
### 注册服务(App.xaml.cs)
```csharp
using Microsoft.Extensions.DependencyInjection;
using Sharp.Process.DependencyInjection;
using Sharp.Python.DependencyInjection;
protected override void OnStartup(StartupEventArgs e)
{
var services = new ServiceCollection();
// 注册日志
services.AddLogging(builder => {
builder.AddConsole();
builder.AddDebug();
});
// 注册 Process 和 Python 服务
services.AddSharpProcess();
services.AddSharpPython(options => {
options.DefaultVirtualEnvPath = @"C:\MyProject\.venv";
options.AutoLogOutputByDefault = true;
});
// 注册 ViewModel
services.AddTransient<MainViewModel>();
services.AddTransient<MainWindow>();
var provider = services.BuildServiceProvider();
provider.GetRequiredService<MainWindow>().Show();
}
```
### ViewModel 示例
```csharp
using Sharp.Process;
using Sharp.Python;
public class MainViewModel : ViewModelBase
{
private readonly IPythonExecutor _python;
private readonly ILogger<MainViewModel> _logger;
private string _output = "";
public string Output
{
get => _output;
set => SetProperty(ref _output, value);
}
public MainViewModel(IPythonExecutor python, ILogger<MainViewModel> logger)
{
_python = python;
_logger = logger;
RunPythonCommand = new AsyncCommand(ExecutePythonScriptAsync);
}
public IAsyncCommand RunPythonCommand { get; }
private async Task ExecutePythonScriptAsync()
{
IsBusy = true;
Output = "";
try
{
var result = await _python.RunScriptAsync(
@"C:\Scripts\data_processor.py",
new {
input_file = "data.csv",
output_dir = "results",
batch_size = 32
},
new PythonOptions
{
OnOutputReceived = line => {
_dispatcher.Invoke(() => {
Output += $"{DateTime.Now:HH:mm:ss} - {line}\n";
});
}
}
);
if (result.IsSuccess)
{
_dialogService.ShowMessage("处理完成!", "成功");
}
else
{
var error = result.ErrorMessage ?? "未知错误";
_dialogService.ShowError($"处理失败: {error}", "错误");
}
}
catch (Exception ex)
{
_logger.LogError(ex, "执行 Python 脚本失败");
_dialogService.ShowError($"执行失败: {ex.Message}", "错误");
}
finally
{
IsBusy = false;
}
}
}
```
## 示例2:调用任意命令行工具
```csharp
using Sharp.Process;
public class BuildService
{
private readonly IProcessExecutor _process;
private readonly ILogger<BuildService> _logger;
public BuildService(IProcessExecutor process, ILogger<BuildService> logger)
{
_process = process;
_logger = logger;
}
// 执行 dotnet build
public async Task<bool> BuildProjectAsync(string projectPath)
{
var result = await _process.CreateBuilder()
.WithCommand("dotnet", "build", projectPath)
.WithWorkingDirectory(Path.GetDirectoryName(projectPath))
.OnOutputReceived(line => _logger.LogInformation("[Build] {Line}", line))
.OnErrorReceived(line => _logger.LogWarning("[Build] {Error}", line))
.WithTimeout(TimeSpan.FromMinutes(10))
.ExecuteAsync();
return result.IsSuccess && result.Value.ExitCode == 0;
}
// 执行 Git 命令
public async Task<string?> GetGitBranchAsync(string repoPath)
{
var result = await _process.CreateBuilder()
.WithCommand("git", "branch", "--show-current")
.WithWorkingDirectory(repoPath)
.ExecuteAsync();
if (result.IsSuccess)
{
return result.Value.StandardOutput.Trim();
}
return null;
}
// 执行 ffmpeg 视频转换
public async Task<bool> ConvertVideoAsync(string inputPath, string outputPath)
{
var result = await _process.CreateBuilder()
.WithCommand("ffmpeg")
.WithArgument("-i").WithArgument(inputPath)
.WithArgument(outputPath)
.WithTimeout(TimeSpan.FromHours(1))
.OnOutputReceived(line => {
// 解析 ffmpeg 进度输出
if (line.Contains("time="))
{
_logger.LogInformation("转换进度: {Line}", line);
}
})
.ExecuteAsync();
return result.IsSuccess && result.Value.ExitCode == 0;
}
}
```
## 示例3:AI 模型推理服务
```csharp
using Sharp.Python;
public class ImageClassificationService
{
private readonly IPythonExecutor _python;
private readonly ILogger<ImageClassificationService> _logger;
public ImageClassificationService(IPythonExecutor python, ILogger<ImageClassificationService> logger)
{
_python = python;
_logger = logger;
}
public async Task<ClassificationResult?> ClassifyAsync(string imagePath)
{
_logger.LogInformation("开始分类图片: {ImagePath}", imagePath);
var result = await _python.RunScriptAsync<ClassificationResult>(
@"C:\AI\models\classify.py",
new {
image_path = imagePath,
model = "resnet50",
top_k = 5
},
new PythonOptions
{
VirtualEnvPath = @"C:\AI\models\.venv",
Timeout = TimeSpan.FromMinutes(2),
OnOutputReceived = line => _logger.LogDebug("[Python] {Line}", line)
}
);
if (result.IsSuccess)
{
_logger.LogInformation("分类成功: {Label} (置信度: {Confidence})",
result.Value.Label, result.Value.Confidence);
return result.Value;
}
else
{
_logger.LogError("分类失败: {Error}", result.ErrorMessage);
return null;
}
}
}
public class ClassificationResult
{
public string Label { get; set; } = "";
public double Confidence { get; set; }
public List<string> TopLabels { get; set; } = new();
}
```
对应的 Python 脚本 (`classify.py`):
```python
import argparse
import json
import sys
from PIL import Image
import torch
from torchvision import models, transforms
def classify_image(image_path, model_name, top_k):
# 加载模型
print(f"加载模型: {model_name}", file=sys.stderr)
model = models.resnet50(pretrained=True)
model.eval()
# 预处理
preprocess = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
# 加载图片
print(f"处理图片: {image_path}", file=sys.stderr)
image = Image.open(image_path)
input_tensor = preprocess(image)
input_batch = input_tensor.unsqueeze(0)
# 推理
with torch.no_grad():
output = model(input_batch)
# 解析结果
probabilities = torch.nn.functional.softmax(output[0], dim=0)
top_prob, top_catid = torch.topk(probabilities, top_k)
# 输出 JSON(只输出到 stdout)
result = {
"label": f"class_{top_catid[0].item()}",
"confidence": top_prob[0].item(),
"topLabels": [f"class_{catid.item()}" for catid in top_catid]
}
print(json.dumps(result))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--image-path', required=True)
parser.add_argument('--model', default='resnet50')
parser.add_argument('--top-k', type=int, default=5)
args = parser.parse_args()
classify_image(args.image_path, args.model, args.top_k)
```
## 示例4:批量数据处理
```csharp
using Sharp.Python;
public class DataProcessingService
{
private readonly IPythonExecutor _python;
public async Task<bool> ProcessAllCsvFilesAsync(string directory)
{
var csvFiles = Directory.GetFiles(directory, "*.csv");
foreach (var file in csvFiles)
{
var result = await _python.RunScriptAsync(
"process_csv.py",
new {
input = file,
output = file.Replace(".csv", "_processed.csv"),
remove_duplicates = true,
normalize = true
}
);
if (!result.IsSuccess)
{
return false;
}
}
return true;
}
}
```
## 测试建议
### 简单测试脚本(test.py)
```python
import sys
import json
import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--name', default='World')
parser.add_argument('--count', type=int, default=1)
args = parser.parse_args()
# 日志输出到 stderr
print(f"参数: name={args.name}, count={args.count}", file=sys.stderr)
# 处理
for i in range(args.count):
print(f"Hello, {args.name}! ({i+1})", file=sys.stderr)
# 结果输出到 stdout(JSON)
result = {
"message": f"Greeted {args.name} {args.count} times",
"success": True
}
print(json.dumps(result))
if __name__ == '__main__':
main()
```
### C# 测试代码
```csharp
// 测试基本调用
var result = await _python.RunScriptAsync("test.py", new {
name = "Sharp",
count = 3
});
if (result.IsSuccess)
{
Console.WriteLine(result.Value.StandardOutput);
}
// 测试 JSON 解析
public class TestResult
{
public string Message { get; set; } = "";
public bool Success { get; set; }
}
var jsonResult = await _python.RunScriptAsync<TestResult>("test.py", new {
name = "Sharp",
count = 5
});
if (jsonResult.IsSuccess)
{
Console.WriteLine(jsonResult.Value.Message);
}
```
@@ -1,4 +0,0 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
@@ -1,70 +0,0 @@
#pragma checksum "..\..\..\App.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "E3F9FFB46D71276D1887DE3B3CD38133E8717023"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using Wpf;
namespace Wpf {
/// <summary>
/// App
/// </summary>
public partial class App : System.Windows.Application {
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "9.0.4.0")]
public void InitializeComponent() {
#line 5 "..\..\..\App.xaml"
this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);
#line default
#line hidden
}
/// <summary>
/// Application Entry Point.
/// </summary>
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "9.0.4.0")]
public static void Main() {
Wpf.App app = new Wpf.App();
app.InitializeComponent();
app.Run();
}
}
}
@@ -1,71 +0,0 @@
#pragma checksum "..\..\..\App.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "E3F9FFB46D71276D1887DE3B3CD38133E8717023"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using Wpf;
namespace Wpf {
/// <summary>
/// App
/// </summary>
public partial class App : System.Windows.Application {
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "9.0.4.0")]
public void InitializeComponent() {
#line 5 "..\..\..\App.xaml"
this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);
#line default
#line hidden
}
/// <summary>
/// Application Entry Point.
/// </summary>
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "9.0.4.0")]
public static void Main() {
Wpf.App app = new Wpf.App();
app.InitializeComponent();
app.Run();
}
}
}
@@ -1,75 +0,0 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "E11B1709F73A671EB1F1804D276CA5E1F763BAD3"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using Wpf;
namespace Wpf {
/// <summary>
/// MainWindow
/// </summary>
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "9.0.4.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/Wpf;component/mainwindow.xaml", System.UriKind.Relative);
#line 1 "..\..\..\MainWindow.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "9.0.4.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
this._contentLoaded = true;
}
}
}
@@ -1,76 +0,0 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "E11B1709F73A671EB1F1804D276CA5E1F763BAD3"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using Wpf;
namespace Wpf {
/// <summary>
/// MainWindow
/// </summary>
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "9.0.4.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/Wpf;V1.0.0.0;component/mainwindow.xaml", System.UriKind.Relative);
#line 1 "..\..\..\MainWindow.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "9.0.4.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
this._contentLoaded = true;
}
}
}
@@ -1,24 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Sharp.Wpf")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+433e206d456d0ef3b2fc57c458ff3fc030643be6")]
[assembly: System.Reflection.AssemblyProductAttribute("Sharp.Wpf")]
[assembly: System.Reflection.AssemblyTitleAttribute("Sharp.Wpf")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")]
// 由 MSBuild WriteCodeFragment 类生成。
@@ -1 +0,0 @@
cd23ae979f4410b7a90bcdab8832e81e422253dc2d502d88544f9372c3b0bd4d
@@ -1,24 +0,0 @@
is_global = true
build_property.ApplicationManifest =
build_property.StartupObject =
build_property.ApplicationDefaultFont =
build_property.ApplicationHighDpiMode =
build_property.ApplicationUseCompatibleTextRendering =
build_property.ApplicationVisualStyles =
build_property.TargetFramework = net8.0-windows
build_property.TargetFrameworkIdentifier = .NETCoreApp
build_property.TargetFrameworkVersion = v8.0
build_property.TargetPlatformMinVersion = 7.0
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Sharp.Wpf
build_property.ProjectDir = D:\code\sharp-basic\src\Sharp\Wpf\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.CsWinRTUseWindowsUIXamlProjections = false
build_property.EffectiveAnalysisLevelStyle = 8.0
build_property.EnableCodeStyleSeverity =
@@ -1,8 +0,0 @@
// <auto-generated/>
global using System;
global using System.Collections.Generic;
global using System.Drawing;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;
global using System.Windows.Forms;
@@ -1,11 +0,0 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {}
},
"libraries": {}
}
@@ -1,25 +0,0 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
{
"name": "Microsoft.WindowsDesktop.App",
"version": "8.0.0"
}
],
"additionalProbingPaths": [
"C:\\Users\\yllyo\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\yllyo\\.nuget\\packages",
"D:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": true,
"CSWINRT_USE_WINDOWS_UI_XAML_PROJECTIONS": false,
"Microsoft.NETCore.DotNetHostPolicy.SetAppPaths": true
}
}
}
@@ -1,20 +0,0 @@
Wpf
winexe
C#
.cs
D:\yuanll\sharp-basic\src\Sharp\Wpf\obj\Debug\net8.0-windows\
Wpf
none
false
TRACE;DEBUG;NET;NET8_0;NETCOREAPP
D:\yuanll\sharp-basic\src\Sharp\Wpf\App.xaml
11407045341
41779921481
198-211836927
MainWindow.xaml;
True
@@ -1,20 +0,0 @@
Wpf
1.0.0.0
winexe
C#
.cs
D:\yuanll\sharp-basic\src\Sharp\Wpf\obj\Debug\net8.0-windows\
Wpf
none
false
TRACE;DEBUG;NET;NET8_0;NETCOREAPP;WINDOWS;WINDOWS7_0;NET5_0_OR_GREATER;NET6_0_OR_GREATER;NET7_0_OR_GREATER;NET8_0_OR_GREATER;NETCOREAPP3_0_OR_GREATER;NETCOREAPP3_1_OR_GREATER;WINDOWS7_0_OR_GREATER
D:\yuanll\sharp-basic\src\Sharp\Wpf\App.xaml
11407045341
61117646960
198-211836927
MainWindow.xaml;
False
@@ -1,4 +0,0 @@
FD:\yuanll\sharp-basic\src\Sharp\Wpf\MainWindow.xaml;;
@@ -1,82 +0,0 @@
{
"format": 1,
"restore": {
"D:\\code\\sharp-basic\\src\\Sharp\\Wpf\\Wpf.csproj": {}
},
"projects": {
"D:\\code\\sharp-basic\\src\\Sharp\\Wpf\\Wpf.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\code\\sharp-basic\\src\\Sharp\\Wpf\\Wpf.csproj",
"projectName": "Sharp.Wpf",
"projectPath": "D:\\code\\sharp-basic\\src\\Sharp\\Wpf\\Wpf.csproj",
"packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\",
"outputPath": "D:\\code\\sharp-basic\\src\\Sharp\\Wpf\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"D:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\Administrator\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net8.0-windows"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0-windows7.0": {
"targetAlias": "net8.0-windows",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "10.0.100"
},
"frameworks": {
"net8.0-windows7.0": {
"targetAlias": "net8.0-windows",
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": {
"target": "Package",
"version": "[9.0.0, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
},
"Microsoft.WindowsDesktop.App": {
"privateAssets": "none"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.100/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Administrator\.nuget\packages\;D:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">7.0.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\Administrator\.nuget\packages\" />
<SourceRoot Include="D:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup>
</Project>
@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
-138
View File
@@ -1,138 +0,0 @@
{
"version": 3,
"targets": {
"net8.0-windows7.0": {
"Microsoft.Extensions.DependencyInjection.Abstractions/9.0.0": {
"type": "package",
"compile": {
"lib/net8.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": {
"related": ".xml"
}
},
"runtime": {
"lib/net8.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": {
"related": ".xml"
}
},
"build": {
"buildTransitive/net8.0/_._": {}
}
}
}
},
"libraries": {
"Microsoft.Extensions.DependencyInjection.Abstractions/9.0.0": {
"sha512": "+6f2qv2a3dLwd5w6JanPIPs47CxRbnk+ZocMJUhv9NxP88VlOcJYZs9jY+MYSjxvady08bUZn6qgiNh7DadGgg==",
"type": "package",
"path": "microsoft.extensions.dependencyinjection.abstractions/9.0.0",
"files": [
".nupkg.metadata",
".signature.p7s",
"Icon.png",
"LICENSE.TXT",
"PACKAGE.md",
"THIRD-PARTY-NOTICES.TXT",
"buildTransitive/net461/Microsoft.Extensions.DependencyInjection.Abstractions.targets",
"buildTransitive/net462/_._",
"buildTransitive/net8.0/_._",
"buildTransitive/netcoreapp2.0/Microsoft.Extensions.DependencyInjection.Abstractions.targets",
"lib/net462/Microsoft.Extensions.DependencyInjection.Abstractions.dll",
"lib/net462/Microsoft.Extensions.DependencyInjection.Abstractions.xml",
"lib/net8.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll",
"lib/net8.0/Microsoft.Extensions.DependencyInjection.Abstractions.xml",
"lib/net9.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll",
"lib/net9.0/Microsoft.Extensions.DependencyInjection.Abstractions.xml",
"lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll",
"lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Abstractions.xml",
"lib/netstandard2.1/Microsoft.Extensions.DependencyInjection.Abstractions.dll",
"lib/netstandard2.1/Microsoft.Extensions.DependencyInjection.Abstractions.xml",
"microsoft.extensions.dependencyinjection.abstractions.9.0.0.nupkg.sha512",
"microsoft.extensions.dependencyinjection.abstractions.nuspec",
"useSharedDesignerContext.txt"
]
}
},
"projectFileDependencyGroups": {
"net8.0-windows7.0": [
"Microsoft.Extensions.DependencyInjection.Abstractions >= 9.0.0"
]
},
"packageFolders": {
"C:\\Users\\Administrator\\.nuget\\packages\\": {},
"D:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\code\\sharp-basic\\src\\Sharp\\Wpf\\Wpf.csproj",
"projectName": "Sharp.Wpf",
"projectPath": "D:\\code\\sharp-basic\\src\\Sharp\\Wpf\\Wpf.csproj",
"packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\",
"outputPath": "D:\\code\\sharp-basic\\src\\Sharp\\Wpf\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"D:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\Administrator\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net8.0-windows"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0-windows7.0": {
"targetAlias": "net8.0-windows",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "10.0.100"
},
"frameworks": {
"net8.0-windows7.0": {
"targetAlias": "net8.0-windows",
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": {
"target": "Package",
"version": "[9.0.0, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
},
"Microsoft.WindowsDesktop.App": {
"privateAssets": "none"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.100/PortableRuntimeIdentifierGraph.json"
}
}
}
}
-10
View File
@@ -1,10 +0,0 @@
{
"version": 2,
"dgSpecHash": "zqaFYIDtlpU=",
"success": true,
"projectFilePath": "D:\\code\\sharp-basic\\src\\Sharp\\Wpf\\Wpf.csproj",
"expectedPackageFiles": [
"C:\\Users\\Administrator\\.nuget\\packages\\microsoft.extensions.dependencyinjection.abstractions\\9.0.0\\microsoft.extensions.dependencyinjection.abstractions.9.0.0.nupkg.sha512"
],
"logs": []
}
@@ -1 +0,0 @@
"restore":{"projectUniqueName":"D:\\code\\sharp-basic\\src\\Sharp\\Wpf\\Wpf.csproj","projectName":"Sharp.Wpf","projectPath":"D:\\code\\sharp-basic\\src\\Sharp\\Wpf\\Wpf.csproj","outputPath":"D:\\code\\sharp-basic\\src\\Sharp\\Wpf\\obj\\","projectStyle":"PackageReference","fallbackFolders":["D:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"],"originalTargetFrameworks":["net8.0-windows"],"sources":{"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\":{},"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net8.0-windows7.0":{"targetAlias":"net8.0-windows","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]},"restoreAuditProperties":{"enableAudit":"true","auditLevel":"low","auditMode":"direct"},"SdkAnalysisLevel":"10.0.100"}"frameworks":{"net8.0-windows7.0":{"targetAlias":"net8.0-windows","dependencies":{"Microsoft.Extensions.DependencyInjection.Abstractions":{"target":"Package","version":"[9.0.0, )"}},"imports":["net461","net462","net47","net471","net472","net48","net481"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.NETCore.App":{"privateAssets":"all"},"Microsoft.WindowsDesktop.App":{"privateAssets":"none"}},"runtimeIdentifierGraphPath":"C:\\Program Files\\dotnet\\sdk\\10.0.100/PortableRuntimeIdentifierGraph.json"}}
@@ -1 +0,0 @@
17654362814006268
@@ -1 +0,0 @@
17657764918263100
-14
View File
@@ -1,14 +0,0 @@
using System.Configuration;
using System.Data;
using System.Windows;
namespace Client
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}