protected virtual string GetDebuggeeBinaryDirPath(string debuggeeProjectDirPath, string framework, string runtime)
{
- string debuggeeBinaryDirPath = null;
+ string debuggeeBinaryDirPath;
if (runtime != null)
{
debuggeeBinaryDirPath = Path.Combine(debuggeeProjectDirPath, "bin", "Debug", framework, runtime);
return debuggeeBinaryDirPath;
}
- protected static string GetDebuggeeBinaryDllPath(string debuggeeBinaryDirPath, string debuggeeName)
+ protected static string GetDebuggeeBinaryDllPath(TestConfiguration config, string debuggeeBinaryDirPath, string debuggeeName)
{
- return Path.Combine(debuggeeBinaryDirPath, debuggeeName + ".dll");
+ return config.IsNETCore ? Path.Combine(debuggeeBinaryDirPath, debuggeeName + (config.PublishSingleFile ? "" : ".dll")) : null;
}
- protected static string GetDebuggeeBinaryExePath(string debuggeeBinaryDirPath, string debuggeeName)
+ protected static string GetDebuggeeBinaryExePath(TestConfiguration config, string debuggeeBinaryDirPath, string debuggeeName)
{
- return Path.Combine(debuggeeBinaryDirPath, debuggeeName + ".exe");
+ return config.IsDesktop ? Path.Combine(debuggeeBinaryDirPath, debuggeeName + ".exe") : null;
}
protected static string GetLogPath(TestConfiguration config, string framework, string runtime, string debuggeeName)
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
namespace Microsoft.Diagnostics.TestHelpers
{
buildProperties.Add("RuntimeIdentifier", runtimeIdentifier);
}
+ if (config.PublishSingleFile)
+ {
+ Debug.Assert(runtimeIdentifier != null);
+ buildProperties.Add("PublishSingleFile", "true");
+ }
string debugType = config.DebugType;
if (debugType == null)
{
string debuggeeSolutionDirPath = GetDebuggeeSolutionDirPath(dotNetRootBuildDirPath, debuggeeName);
string debuggeeProjectDirPath = GetDebuggeeProjectDirPath(debuggeeSolutionDirPath, initialSourceDirPath, debuggeeName);
string debuggeeBinaryDirPath = GetDebuggeeBinaryDirPath(debuggeeProjectDirPath, framework, runtimeIdentifier);
- string debuggeeBinaryDllPath = config.IsNETCore ? GetDebuggeeBinaryDllPath(debuggeeBinaryDirPath, debuggeeName) : null;
- string debuggeeBinaryExePath = config.IsDesktop ? GetDebuggeeBinaryExePath(debuggeeBinaryDirPath, debuggeeName) : null;
+ string debuggeeBinaryDllPath = GetDebuggeeBinaryDllPath(config, debuggeeBinaryDirPath, debuggeeName);
+ string debuggeeBinaryExePath = GetDebuggeeBinaryExePath(config, debuggeeBinaryDirPath, debuggeeName);
string logPath = GetLogPath(config, framework, runtimeIdentifier, debuggeeName);
return new CsprojBuildDebuggeeTestStep(dotNetPath,
initialSourceDirPath,
get { return GetValue("BuildProjectRuntime"); }
}
+ /// <summary>
+ /// Returns "true" if build/run this cli debuggee as a single-file app
+ /// </summary>
+ public bool PublishSingleFile
+ {
+ get { return string.Equals(GetValue("PublishSingleFile"), "true", StringComparison.InvariantCultureIgnoreCase); }
+ }
+
/// <summary>
/// The version of the Microsoft.NETCore.App package to reference when running the debuggee (i.e.
/// using the dotnet cli --fx-version option).
/// </summary>
public bool LogToConsole
{
- get { return bool.TryParse(GetValue("LogToConsole"), out bool b) && b; }
+ get { return string.Equals(GetValue("LogToConsole"), "true", StringComparison.InvariantCultureIgnoreCase); }
}
/// <summary>
<TestDotnetDumpCommandsWithRuntime21 Condition="'$(OS)' == 'Linux'">false</TestDotnetDumpCommandsWithRuntime21>
<!-- Build the debuggee for this framework version but run it on latest -->
- <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '6')">net5.0</BuildProjectFrameworkLatest>
+ <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '6')">net6.0</BuildProjectFrameworkLatest>
<BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '5')">net5.0</BuildProjectFrameworkLatest>
<BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '3.1')">netcoreapp3.1</BuildProjectFrameworkLatest>
<BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '2.1')">netcoreapp2.1</BuildProjectFrameworkLatest>
<CliPath>$(DotNetRoot)/dotnet</CliPath>
<NuGetPackageFeeds>
- myget.org dotnet-core=https://dotnet.myget.org/F/dotnet-core/api/v3/index.json;
- nuget.org=https://www.nuget.org/api/v2/
+ dotnet6=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet6/nuget/v3/index.json;
+ dotnet-core=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
+ dotnet-public=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json
</NuGetPackageFeeds>
<Options>
<SetHostRuntime>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</SetHostRuntime>
</Option>
<!--
- SOS.StackAndOtherTests (cli because tested with embedded and portable PDBs)
+ SOS.StackAndOtherTests (cli because tested with embedded, portable PDBs and single-file)
-->
<Option>
<DebuggeeBuildProcess>cli</DebuggeeBuildProcess>
<TestName>SOS.StackAndOtherTests</TestName>
<Options>
<Option Condition="'$(RuntimeVersionLatest)' != ''">
- <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
- <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
+ <Options>
+ <Option>
+ <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
+ <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
+ </Option>
+ </Options>
</Option>
<Option Condition="'$(RuntimeVersion50)' != ''">
<BuildProjectFramework>net5.0</BuildProjectFramework>
<FrameworkVersion Condition="'$(FrameworkVersion)' == ''">$(RuntimeFrameworkVersion)</FrameworkVersion>
<RuntimeSymbolsPath>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</RuntimeSymbolsPath>
<LLDBHelperScript>$(ScriptRootDir)/lldbhelper.py</LLDBHelperScript>
- <HostExe>$(DotNetRoot)/dotnet</HostExe>
- <HostArgs>--fx-version $(FrameworkVersion)</HostArgs>
+
+ <!-- Single-file debuggees don't need the host -->
+ <HostExe Condition="'$(PublishSingleFile)' != 'true'">$(DotNetRoot)/dotnet</HostExe>
+ <HostArgs Condition="'$(PublishSingleFile)' != 'true'">--fx-version $(FrameworkVersion)</HostArgs>
<Options>
<Option Condition="$(OS) == Linux">
<TestDesktop Condition="'$(TargetArchitecture)' == 'arm64'">false</TestDesktop>
<!-- Build the debuggee for this framework version but run it on latest -->
- <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '6')">net5.0</BuildProjectFrameworkLatest>
+ <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '6')">net6.0</BuildProjectFrameworkLatest>
<BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '5')">net5.0</BuildProjectFrameworkLatest>
<BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '3.1')">netcoreapp3.1</BuildProjectFrameworkLatest>
<BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '2.1')">netcoreapp2.1</BuildProjectFrameworkLatest>
<CliPath>$(DotNetRoot)\dotnet.exe</CliPath>
<NuGetPackageFeeds>
- myget.org dotnet-core=https://dotnet.myget.org/F/dotnet-core/api/v3/index.json;
- nuget.org=https://www.nuget.org/api/v2/
+ dotnet6=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet6/nuget/v3/index.json;
+ dotnet-core=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
+ dotnet-public=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json
</NuGetPackageFeeds>
<Options>
install(TARGETS DesktopClrHost DESTINATION ${CLR_MANAGED_BINARY_DIR}/WebApp3/${CLR_BUILD_TYPE}/netcoreapp3.1)
install(TARGETS DesktopClrHost DESTINATION ${CLR_MANAGED_BINARY_DIR}/WebApp3/${CLR_BUILD_TYPE}/net5.0)
+install(TARGETS DesktopClrHost DESTINATION ${CLR_MANAGED_BINARY_DIR}/WebApp3/${CLR_BUILD_TYPE}/net6.0)
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsShippingAssembly>false</IsShippingAssembly>
<Optimize>false</Optimize>
+ <BuildTargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0</BuildTargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">$(BuildTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <OutputType>Exe</OutputType>
- <TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+ <OutputType>Exe</OutputType>
+ <TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">$(BuildTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">$(BuildTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">$(BuildTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
</Project>
<OutputType>Exe</OutputType>
<Optimize>true</Optimize>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">$(BuildTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">$(BuildTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">$(BuildTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">$(BuildTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">$(BuildTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">$(BuildTargetFrameworks)</TargetFrameworks>
<DefineConstants Condition="'$(TargetFramework)' == 'net462'">$(DefineConstants);FULL_CLR</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == '' and '$(OS)' != 'Windows_NT'">netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == '' and '$(OS)' == 'Windows_NT'">net462;netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == '' and '$(OS)' != 'Windows_NT'">$(BuildTargetFrameworks)</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == '' and '$(OS)' == 'Windows_NT'">net462;$(BuildTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">$(BuildTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">$(BuildTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
- <TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
+ <TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
}
arguments.AppendFormat(@"--no-lldbinit -o ""settings set interpreter.prompt-on-quit false"" -o ""command script import {0}"" -o ""version""", lldbHelperScript);
+ string debuggeeTarget = config.HostExe;
+ if (string.IsNullOrWhiteSpace(debuggeeTarget))
+ {
+ debuggeeTarget = debuggeeConfig.BinaryExePath;
+ }
+
// Load the dump or launch the debuggee process
if (action == DebuggerAction.LoadDump)
{
- initialCommands.Add($@"target create --core ""%DUMP_NAME%"" ""{config.HostExe}""");
+ initialCommands.Add($@"target create --core ""%DUMP_NAME%"" ""{debuggeeTarget}""");
}
else
{
sb.AppendFormat(@" ""{0}""", arg);
}
}
- sb.AppendFormat(@" ""{0}""", debuggeeConfig.BinaryExePath);
+ if (!string.IsNullOrWhiteSpace(config.HostExe))
+ {
+ sb.AppendFormat(@" ""{0}""", debuggeeConfig.BinaryExePath);
+ }
if (!string.IsNullOrWhiteSpace(information.DebuggeeArguments))
{
string[] args = ReplaceVariables(variables, information.DebuggeeArguments).Trim().Split(' ');
sb.AppendFormat(@" ""{0}""", arg);
}
}
- initialCommands.Add($@"target create ""{config.HostExe}""");
+ initialCommands.Add($@"target create ""{debuggeeTarget}""");
initialCommands.Add(sb.ToString());
initialCommands.Add("process launch -s");
{
defines.Add("NETCORE_OR_DOTNETDUMP");
}
+ if (_config.PublishSingleFile)
+ {
+ defines.Add("SINGLE_FILE_APP");
+ }
return defines;
}
// If the dbgeng functions fail to get the module/assembly name, use the DAC API
if (!bModuleNameWorked)
{
- if (g_sos->GetPEFileName(dmd.File, MAX_LONGPATH, wszNameBuffer, NULL) == S_OK)
+ wszNameBuffer[0] = W('\0');
+ if (FAILED(g_sos->GetPEFileName(dmd.File, MAX_LONGPATH, wszNameBuffer, NULL)) || wszNameBuffer[0] == W('\0'))
{
- if (wszNameBuffer[0] != W('\0'))
+ ToRelease<IXCLRDataModule> pModule;
+ if (SUCCEEDED(g_sos->GetModule(dmd.Address, &pModule)))
{
- WCHAR *pJustName = _wcsrchr(wszNameBuffer, GetTargetDirectorySeparatorW());
- if (pJustName == NULL)
- pJustName = wszNameBuffer - 1;
-
- DOAPPEND(pJustName + 1);
- bModuleNameWorked = TRUE;
+ ULONG32 nameLen = 0;
+ pModule->GetFileName(MAX_LONGPATH, &nameLen, wszNameBuffer);
}
}
+ if (wszNameBuffer[0] != W('\0'))
+ {
+ WCHAR *pJustName = _wcsrchr(wszNameBuffer, GetTargetDirectorySeparatorW());
+ if (pJustName == NULL)
+ pJustName = wszNameBuffer - 1;
+
+ DOAPPEND(pJustName + 1);
+ bModuleNameWorked = TRUE;
+ }
}
// Under certain circumstances DacpMethodDescData::GetMethodDescName()
* *
\**********************************************************************/
// fileName should be at least MAX_LONGPATH
-HRESULT FileNameForModule (const DacpModuleData * const pModule, __out_ecount (MAX_LONGPATH) WCHAR *fileName)
+HRESULT FileNameForModule(const DacpModuleData* const pModuleData, __out_ecount(MAX_LONGPATH) WCHAR* fileName)
{
- fileName[0] = L'\0';
-
+ fileName[0] = W('\0');
+
HRESULT hr = S_OK;
- CLRDATA_ADDRESS dwAddr = pModule->File;
+ CLRDATA_ADDRESS dwAddr = pModuleData->File;
if (dwAddr == 0)
{
// TODO: We have dynamic module
return E_NOTIMPL;
}
-
+
CLRDATA_ADDRESS base = 0;
hr = g_sos->GetPEFileBase(dwAddr, &base);
if (SUCCEEDED(hr))
{
hr = g_sos->GetPEFileName(dwAddr, MAX_LONGPATH, fileName, NULL);
- if (SUCCEEDED(hr))
- {
- if (fileName[0] != W('\0'))
- return hr; // done
- }
+ if (SUCCEEDED(hr) && fileName[0] != W('\0'))
+ return hr; // done
+
#ifndef FEATURE_PAL
// Try the base *
if (base)
{
- hr = DllsName((ULONG_PTR) base, fileName);
+ hr = DllsName((ULONG_PTR)base, fileName);
+ if (SUCCEEDED(hr) && fileName[0] != W('\0'))
+ return hr; // done
}
#endif // !FEATURE_PAL
}
+
+ ToRelease<IXCLRDataModule> pModule;
+ if (SUCCEEDED(g_sos->GetModule(pModuleData->Address, &pModule)))
+ {
+ ULONG32 nameLen = 0;
+ hr = pModule->GetFileName(MAX_LONGPATH, &nameLen, fileName);
+ }
- // If we got here, either DllsName worked, or we couldn't find a name
return hr;
}