Gitlab私有存储库支持SourceLink 调试之使用proxy方式
2023-06-13 09:11:07 时间
前情概要
在 让你发布的nuget包支持源代码调试#为gitlab的私有源代码项目提供支持 小节中有介绍到如何让gitlab的私有存储库支持SourceLink. 其中有一个方法是说在vs中打开webbrower登录, 利用已登录session支持. 但是在时间车轮经过一段不短的距离后. vs2022 中已经没有web brower了, 同时gitlab也不再支持IE. 所以利用共享Session方式行不通了. 同时GCM+SourceLink任然不支持, 最后只能选择使用Proxy的方式来实现一把.
方案
VS --> SourceLink --> gitlab.com(127.0.0.1,gitlabproxy) --> gitlab.com(使用 用户token + gitlab api 下载源文件)
环境配置
修改hosts文件, 将gitlab.com 指向 127.0.0.1
# C:\Windows\System32\drivers\etc\hosts
127.0.0.1 gitlab.com
启动一个WebProxy. 让gitlabproxy可以访问真正的gitlab.com
用什么都可以, 反正就是一个Proxy, 例如我的http代理在 http://127.0.0.1:10809.
当然, 如果不选择使用webproxy的方式, 也可以配置gitlabproxy的gitlabHost, 将它改成一个真实的gitlab.com服务器ip, 然后配置requet.header.host=gitlab.com
准备 gitlab.com(127.0.0.1,gitlabproxy) 代理程序
将 https://gitlab.com/slcon/pub/repo/gitlabproxy repo clone 下来. 然后做一点修改
# Microsoft.SourceLink.GitLab.1.0.0 打包的生成的PATH中已经没有 "/-/" 部分了. 所以删除个.
new Regex(@"^\/(?<project>.+?)\/-\/raw\/(?<commit>[\da-f].+?)\/(?<filepath>.+)$");
# ==>
new Regex(@"^\/(?<project>.+?)\/raw\/(?<commit>[\da-f].+?)\/(?<filepath>.+)$");
# 使用代理, 访问真正的gitlab.com
response = WebRequest.Create(remoteUrl).GetResponse() as HttpWebResponse;
# ==>
var request = WebRequest.Create(remoteUrl);
request.Proxy = new WebProxy("http://127.0.0.1:10809");
response = request.GetResponse() as HttpWebResponse;
将此修改的gitlabproxy程序部署到本地iis, 并绑定域名 https://gitlab.com:443
修改 gitlabproxy 的 web.config 文件
到https://gitlab.com/-/profile/personal_access_tokens 创建一个个人token, 然后添加到appSettings section 中.
<appSettings>
<add key="gitlabHost" value="https://gitlab.com" />
<add key="{your gitlab group path}" value="glpat-****************" />
<add key="{your gitlab project path}" value="glpat-****************" />
</appSettings>
完成
不出意外的话, 现在在vs里面F11调试就可以进入源代码了.
Links
https://gitlab.com/slcon/pub/repo/gitlabproxy https://github.com/dotnet/sourcelink/issues/281
相关文章
- 串口调试助手fx2n_PLC串口调试助手「建议收藏」
- shell脚本的调试
- idea怎么远程debug_idea 多线程调试
- android 4怎么打开usb调试?「建议收藏」
- Android debug_Android开发在手机上调试
- React源码学习进阶篇(一)新版React如何调试源码?
- Android Automotive Framework调试技巧
- 逆向调试objection的使用
- Zynq PS之UART调试
- SAP SE16N手工调试修改表数据详解编程语言
- 解放双手:MSSQL存储过程调试指南(mssql存储过程调试)
- 利用ROP绕过DEP(Defeating DEP with ROP)调试笔记
- MySQL 存储过程调试技巧分享(mysql调试存储过程)
- 「MSSQL调试存储过程:从入门到精通」(mssql调试存储过程)
- 调试中:无法连接MySQL服务器(不能连接到mysql服务器)
- 解析VS2010利用VS.PHP插件调试PHP的方法