Theoretically, Inline Task should be able to realize your idea, it allow us to write code inside the .csproj file. But when I actually tested it, I couldn’t get the data of the third-party library or even some local libraries during the build.
Inline Task, you can test it on your side, because there is a problem with the VS tool and its environment on my side, maybe it can be realized on your side.
Anyway, I found another way.
1, Create a console app named "ReadLaunchSettings":
using System;
using System.IO;
using System.Linq;
using System.Text.Json;
namespace ReadLaunchSettings
{
class Program
{
static void Main(string[] args)
{
var launchSettingsFilePath = args[0];
var json = File.ReadAllText(launchSettingsFilePath);
var jdoc = JsonDocument.Parse(json);
var profiles = jdoc.RootElement.GetProperty("profiles");
var profile = profiles.EnumerateObject()
.FirstOrDefault(p => p.Value.GetProperty("remoteDebugEnabled").GetBoolean());
if (profile.Value.ValueKind != JsonValueKind.Undefined)
{
Console.WriteLine("true");
Console.WriteLine(profile.Value.GetProperty("remoteDebugMachine").GetString());
}
else
{
Console.WriteLine("false");
Console.WriteLine("null");
}
}
}
}
2, build the above console app to get the execute able application(.exe file)

3, change the content of the .csproj file of the project which has the launchSettings.json file(On my side, it is web application.):
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<Target Name="TestBowman" BeforeTargets="PreBuildEvent">
<Exec Command="C:\Users\Administrator\source\repos\projectsref\ReadLaunchSettings\bin\Debug\net6.0\ReadLaunchSettings.exe $(ProjectDir)Properties\launchSettings.json" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="ConsoleOutput" />
</Exec>
<PropertyGroup>
<RemoteDebugEnabled>$(ConsoleOutput.Split(';')[0])</RemoteDebugEnabled>
<RemoteDebugMachine>$(ConsoleOutput.Split(';')[1])</RemoteDebugMachine>
</PropertyGroup>
<Message Text="RemoteDebugEnabled: $(RemoteDebugEnabled)" />
<Message Text="RemoteDebugMachine: $(RemoteDebugMachine)" />
</Target>
</Project>
After the above steps, if I build this project, I will get the info you want:
