{"id":28579035,"url":"https://github.com/dotnet-campus/usingmsbuildcopyoutputfiletofastdebug","last_synced_at":"2025-06-11T01:37:57.982Z","repository":{"id":34910833,"uuid":"189213397","full_name":"dotnet-campus/UsingMSBuildCopyOutputFileToFastDebug","owner":"dotnet-campus","description":"通过复制输出文件让 VisualStudio 外部启动快速调试底层库 Using MSBuild Copy Output File To Fast Debug","archived":false,"fork":false,"pushed_at":"2024-12-06T07:17:45.000Z","size":75,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-11T05:20:31.093Z","etag":null,"topics":["msbuid","visualstudio"],"latest_commit_sha":null,"homepage":null,"language":"C#","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/dotnet-campus.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}},"created_at":"2019-05-29T11:37:02.000Z","updated_at":"2024-12-06T07:19:57.000Z","dependencies_parsed_at":"2023-01-15T10:15:27.954Z","dependency_job_id":null,"html_url":"https://github.com/dotnet-campus/UsingMSBuildCopyOutputFileToFastDebug","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-campus%2FUsingMSBuildCopyOutputFileToFastDebug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-campus%2FUsingMSBuildCopyOutputFileToFastDebug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-campus%2FUsingMSBuildCopyOutputFileToFastDebug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-campus%2FUsingMSBuildCopyOutputFileToFastDebug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotnet-campus","download_url":"https://codeload.github.com/dotnet-campus/UsingMSBuildCopyOutputFileToFastDebug/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-campus%2FUsingMSBuildCopyOutputFileToFastDebug/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259182493,"owners_count":22818108,"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":["msbuid","visualstudio"],"created_at":"2025-06-11T01:37:53.474Z","updated_at":"2025-06-11T01:37:57.975Z","avatar_url":"https://github.com/dotnet-campus.png","language":"C#","readme":"# Roslyn 让 VisualStudio 急速调试底层库方法\r\n\r\n在一个大项目里面调试底层库经常需要重新编译整个项目，本项目提供了在底层库编译完成之后将输出文件复制到主项目的输出文件夹，通过外部项目调试的方式提高调试效率\r\n\r\n| Build | NuGet |\r\n|--|--|\r\n|![](https://github.com/dotnet-campus/UsingMSBuildCopyOutputFileToFastDebug/workflows/.NET%20Core/badge.svg)|[![](https://img.shields.io/nuget/v/dotnetCampus.UsingMSBuildCopyOutputFileToFastDebug.svg)](https://www.nuget.org/packages/dotnetCampus.UsingMSBuildCopyOutputFileToFastDebug)|\r\n\r\n## 使用方法\r\n\r\n### 安装\r\n\r\n在需要调试的底层库项目安装 NuGet 库 [dotnetCampus.UsingMSBuildCopyOutputFileToFastDebug](https://www.nuget.org/packages/dotnetCampus.UsingMSBuildCopyOutputFileToFastDebug)\r\n\r\n此库推荐仅在 Debug 下安装\r\n\r\n```xml\r\n  \u003cItemGroup Condition=\" '$(Configuration)' == 'Debug'\"\u003e\r\n    \u003cPackageReference Include=\"dotnetCampus.UsingMSBuildCopyOutputFileToFastDebug\" Version=\"1.3.1\" /\u003e\r\n  \u003c/ItemGroup\u003e\r\n```\r\n\r\n### 配置\r\n\r\n配置有两个方法，高级方法将会覆盖基础方法\r\n\r\n**基础方法**：\r\n\r\n通过右击底层库属性，点击调试，设置为可执行文件，路径修改为主项目的启动程序。就可以在底层库点击调试运行主项目调试，同时支持打断点和进行二进制兼容的更改\r\n\r\n请注意，将使用首个可执行文件调试配置作为输出配置\r\n\r\n**高级方法**：\r\n\r\n编辑底层库项目的 csproj 文件，添加下面代码\r\n\r\n```xml\r\n    \u003cPropertyGroup\u003e\r\n        \u003cMainProjectExecutablePathCommandArgs\u003e主项目的输出可执行文件\u003c/MainProjectExecutablePathCommandArgs\u003e\r\n    \u003c/PropertyGroup\u003e\r\n```\r\n\r\n请注意如果路径包含空格，记得加上引号，如下面例子\r\n\r\n```xml\r\n    \u003cPropertyGroup\u003e\r\n        \u003cMainProjectExecutablePathCommandArgs\u003e\"C:\\dotnet campus\\Foo\\bin\\release\\net5.0\\Foo.exe\"\u003c/MainProjectExecutablePathCommandArgs\u003e\r\n    \u003c/PropertyGroup\u003e\r\n```\r\n\r\n以上主项目的输出文件夹支持相对路径，相对于当前底层库项目 csproj 的相对路径\r\n\r\n## 推荐使用方法\r\n\r\n如果是小项目进行调试，推荐修改库的demo或添加单元测试进行测试\r\n\r\n如果是需要调试具体状态，而不方便写demo等推荐使用此工具提升调试效率，可以将此工具在各个底层库安装\r\n\r\n如果是需要做比较大的更改，如接口修改，推荐使用 [dotnet-campus/DllReferencePathChanger: VS DLL引用替换插件](https://github.com/dotnet-campus/DllReferencePathChanger ) 插件\r\n\r\n## 原理\r\n\r\n在软件运行的时候依然可以移动 dll 或 exe 的路径，而此工具将底层库项目的输出 dll 和 pdb 文件拷贝到主项目的文件夹或 MainProjectPath 设置的文件夹，将原本的 dll 和 pdb 重命名，然后通过调试的可执行文件方式启动主项目\r\n\r\n此时的主项目将会加载新的 dll 文件，同时因为存在 pdb 文件也能进去代码调试\r\n\r\n通过将原本dll重命名的方式可以解决主项目执行的文件占用问题\r\n\r\n此调试方式要求对底层库的更改满足二进制兼容\r\n\r\n关于二进制兼容请看 [VisualStudio 通过外部调试方法快速调试库代码](https://blog.lindexi.com/post/visualstudio-%E9%80%9A%E8%BF%87%E5%A4%96%E9%83%A8%E8%B0%83%E8%AF%95%E6%96%B9%E6%B3%95%E5%BF%AB%E9%80%9F%E8%B0%83%E8%AF%95%E5%BA%93%E4%BB%A3%E7%A0%81 )\r\n\r\n原有的 dll 和 pdb 文件将被加入清理列表文件，将会在执行清理的时候进行清理\r\n\r\n## 细节\r\n\r\n默认仅有在 Debug 下开启此功能，如需在 Release 也开启，请通过设置 EnableUsingMSBuildCopyOutputFileToFastDebug 属性为 true 开启\r\n\r\n```xml\r\n    \u003cPropertyGroup\u003e\r\n        \u003cEnableUsingMSBuildCopyOutputFileToFastDebug\u003etrue\u003c/EnableUsingMSBuildCopyOutputFileToFastDebug\u003e\r\n    \u003c/PropertyGroup\u003e\r\n```\r\n\r\n此项设置之后将会在 Debug 和 Release 下都开启复制\r\n\r\n## 感谢\r\n\r\n感谢 https://github.com/kkwpsv/lsjutil 提供 json 解析","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-campus%2Fusingmsbuildcopyoutputfiletofastdebug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotnet-campus%2Fusingmsbuildcopyoutputfiletofastdebug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-campus%2Fusingmsbuildcopyoutputfiletofastdebug/lists"}