diff --git a/RaspberryDebugger/Connection/Connection.cs b/RaspberryDebugger/Connection/Connection.cs index f5f0362..6bb7951 100644 --- a/RaspberryDebugger/Connection/Connection.cs +++ b/RaspberryDebugger/Connection/Connection.cs @@ -591,11 +591,22 @@ private async Task InstallSdkPrerequsitesAsync() if ! apt-get update ; then exit 1 fi - - if ! apt-get install -yq libc6 libgcc1 libgssapi-krb5-2 libicu-dev libssl1.1 libstdc++6 zlib1g libgdiplus ; then - exit 1 + + debianVersion=$(cat /etc/debian_version) + versionTwelve='12' + if dpkg --compare-versions $debianVersion gt $versionTwelve + then + # Debian 12 or newer + if ! apt-get install -yq libc6 libgcc-s1 libgssapi-krb5-2 libicu-dev libssl3 libstdc++6 zlib1g libgdiplus ; then + exit 1 + fi + else + # Older than Debian 12 + if ! apt-get install -yq libc6 libgcc1 libgssapi-krb5-2 libicu-dev libssl1.1 libstdc++6 zlib1g libgdiplus ; then + exit 1 + fi fi - + exit 0 """; @@ -708,10 +719,16 @@ public async Task SetupDebuggerAsync() // see: https://developercommunity.visualstudio.com/t/VS2022-remote-debugging-over-SSH-does-no/10394545#T-N10410651 // This structure is used when Debug->Attach to Process is used. Unfortunately it's tied to // the VS version. - // Currently the VSIX is only targeted to VS2022 so keep the version selector fixed. - // TODO: Use RaspberryDebuggerPackage.VisualStudioVersion for DIR. + // The getvsdbgsh docs suggest that one should use the VS Version to select the proper debugger. I tried + // that as VS2026 has been released. Unfortunately, getvsdbgsh returns an error using "vs2026" as a -v option. + // At least it does at this time anyway. In the process of trying to reverse engineer the valid options for + // -v I noticed that for any version I submitted - vs2019/vs2022/vs2017/latest, the script always attempted + // to download the latest revision of vsdbg. So I'm just going to use latest until that decides to stop working. + // It's going to be installed in the dir associated with the VS version though, keeping the paradigm suggested + // above. var installCommand = - $"""curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v vs2022 -l {PackageHelper.RemoteDebuggerFolder}"""; + //$"""curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v {PackageHelper.VisualStudioVersion} -l {PackageHelper.RemoteDebuggerFolder}"""; + $"""curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l {PackageHelper.RemoteDebuggerFolder}"""; try { diff --git a/RaspberryDebugger/PackageHelper.cs b/RaspberryDebugger/PackageHelper.cs index b867014..528eff1 100644 --- a/RaspberryDebugger/PackageHelper.cs +++ b/RaspberryDebugger/PackageHelper.cs @@ -46,6 +46,16 @@ namespace RaspberryDebugger { + enum VisualStudioVersions + { + Unknown, + + vs2017 = 15, + vs2019, + vs2022, + vs2026 + } + /// /// Package specific constants. /// @@ -61,6 +71,30 @@ internal static class PackageHelper /// private static readonly string ConnectionsPath; + /// + /// Indicates what VS application is currently running. + /// + private static VisualStudioVersions _visualStudioVersion = VisualStudioVersions.Unknown; + public static VisualStudioVersions VisualStudioVersion + { + get + { + if ( _visualStudioVersion == VisualStudioVersions.Unknown ) + { + ThreadHelper.ThrowIfNotOnUIThread(); + + DTE2 dte = (DTE2)Package.GetGlobalService(typeof(SDTE)); + + if (Version.TryParse(dte.Version, out Version result)) + { + Enum.TryParse(result.Major.ToString(), out _visualStudioVersion); + } + } + + return _visualStudioVersion; + } + } + /// /// Directory on the Raspberry Pi where .NET Core SDKs will be installed along with the /// vsdbg remote debugger. @@ -74,15 +108,13 @@ internal static class PackageHelper /// /// Directory on the Raspberry Pi where the vsdbg remote debugger will be installed. - /// Currently the VSIX is only targeted to VS2022 so keep the version selector fixed. - /// TODO: Use RaspberryDebuggerPackage.VisualStudioVersion for DIR.. /// - public const string RemoteDebuggerFolder = "~/.vs-debugger/vs2022"; + public static readonly string RemoteDebuggerFolder = $"~/.vs-debugger/{VisualStudioVersion}"; /// /// Path to the vsdbg program on the remote machine. /// - public const string RemoteDebuggerPath = RemoteDebuggerFolder + "/vsdbg"; + public static string RemoteDebuggerPath = RemoteDebuggerFolder + "/vsdbg"; /// /// Returns the root directory on the Raspberry Pi where the folder where diff --git a/RaspberryDebugger/RaspberryDebugger.csproj b/RaspberryDebugger/RaspberryDebugger.csproj index 0a05bc9..4884e59 100644 --- a/RaspberryDebugger/RaspberryDebugger.csproj +++ b/RaspberryDebugger/RaspberryDebugger.csproj @@ -46,6 +46,7 @@ 4 CS0414 latest + True pdbonly