Skip to content

Modify debug and packaging method of BrowserProcess #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 47 additions & 44 deletions CefGlue.BrowserProcess/CefGlue.BrowserProcess.csproj
Original file line number Diff line number Diff line change
@@ -1,65 +1,68 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>$(DotnetVersion)</TargetFramework>
<AssemblyName>Xilium.CefGlue.BrowserProcess</AssemblyName>
<RootNamespace>Xilium.CefGlue.BrowserProcess</RootNamespace>
<RuntimeIdentifiers>osx-x64;osx-arm64;win-x64;win-arm64;linux-x64;linux-arm64</RuntimeIdentifiers>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<PublishCommonConfig>Configuration=$(Configuration);Platform=$(Platform);TargetFramework=$(TargetFramework);IsPublishing=True;PublishTrimmed=True;SelfContained=True;RuntimeIdentifier=</PublishCommonConfig>
<IsEditbinEnabled>True</IsEditbinEnabled>
</PropertyGroup>
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>$(DotnetVersion)</TargetFramework>
<AssemblyName>Xilium.CefGlue.BrowserProcess</AssemblyName>
<RootNamespace>Xilium.CefGlue.BrowserProcess</RootNamespace>
<RuntimeIdentifiers>osx-x64;osx-arm64;win-x64;win-arm64;linux-x64;linux-arm64</RuntimeIdentifiers>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<PublishCommonConfig>Configuration=$(Configuration);Platform=$(Platform);TargetFramework=$(TargetFramework);IsPublishing=False;RuntimeIdentifier=</PublishCommonConfig>
<IsEditbinEnabled>True</IsEditbinEnabled>
<RollForward>Major</RollForward>
</PropertyGroup>

<ItemGroup>
<None Remove="ObjectBinding\CefGlueGlobalScript.js" />
</ItemGroup>
<ItemGroup>
<None Remove="ObjectBinding\CefGlueGlobalScript.js" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="ObjectBinding\CefGlueGlobalScript.js" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ObjectBinding\CefGlueGlobalScript.js" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CefGlue.Common.Shared\CefGlue.Common.Shared.csproj" />
<ProjectReference Include="..\CefGlue\CefGlue.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CefGlue.Common.Shared\CefGlue.Common.Shared.csproj" />
<ProjectReference Include="..\CefGlue\CefGlue.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Runtime.Loader" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Runtime.Loader" />
</ItemGroup>

<Target Name="Editbin" AfterTargets="Compile" Condition="$(IsEditbinEnabled) == True And $(VcvarsFile) != '' And $([MSBuild]::IsOSPlatform('Windows'))">
<!--
<Target Name="Editbin" AfterTargets="Compile" Condition="$(IsEditbinEnabled) == True And $(VcvarsFile) != '' And $([MSBuild]::IsOSPlatform('Windows'))">
<!--
Quick explanation: This target runs after compile, and currently 3 more times for each MSBuild command executed in the next target "PublishApp".
We just want this target to be executed for windows specs and when passed the VcvarsFile location.
Using VS Studio: VcvarsFile="$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvars64.bat"
Using VS Studio tools: VcvarsFile="C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvars64.bat"
-->

<PropertyGroup>
<ApphostLocation>$(ProjectDir)$(BaseIntermediateOutputPath)$(Platform)\$(Configuration)\$(TargetFramework)\</ApphostLocation>
<ApphostLocation Condition="'$(IsPublishing)' == 'True'">$(ApphostLocation)$(RuntimeIdentifier)\</ApphostLocation> <!-- When publishing, we also use the runtime identifiers (check the next target "PublishApp") -->
</PropertyGroup>
<PropertyGroup>
<ApphostLocation>$(ProjectDir)$(BaseIntermediateOutputPath)$(Platform)\$(Configuration)\$(TargetFramework)\</ApphostLocation>
<ApphostLocation Condition="'$(IsPublishing)' == 'True'">$(ApphostLocation)$(RuntimeIdentifier)\</ApphostLocation>
<!-- When publishing, we also use the runtime identifiers (check the next target "PublishApp") -->
</PropertyGroup>

<!--
<!--
This command aims at increasing the stack size of Xilium.CefGlue.BrowserProcess.exe to 8 MiBs, using the visual studio tool "editbin".
Since we are reaching the .exe at the compile time, the file name is "apphost.exe" instead and located at /obj folder
-->
<Exec Command="call &quot;$(VcvarsFile)&quot;&#xD;&#xA; editbin /STACK:0x800000 &quot;$(ApphostLocation)\apphost.exe&quot;&#xD;&#xA;" />
</Target>
<Exec Command="call &quot;$(VcvarsFile)&quot;&#xD;&#xA; editbin /STACK:0x800000 &quot;$(ApphostLocation)\apphost.exe&quot;&#xD;&#xA;" />
</Target>

<Target Name="BuildApp" AfterTargets="AfterBuild" Condition="'$(_AssemblyTimestampBeforeCompile)' != '$(_AssemblyTimestampAfterCompile)' and '$(IsPublishing)' != 'False'">
<!-- WINDOWS -->
<Message Text="Buiding CefGlue.BrowserProcess on Windows ($(Platform))..." Importance="High" />
<MSBuild Projects="CefGlue.BrowserProcess.csproj" Targets="Build" Properties="$(PublishCommonConfig)win-$(ArchitectureConfig);IsEditbinEnabled=True;" />

<Target Name="PublishApp" AfterTargets="AfterBuild" Condition="'$(_AssemblyTimestampBeforeCompile)' != '$(_AssemblyTimestampAfterCompile)' and '$(IsPublishing)' != 'True'">
<!-- WINDOWS -->
<Message Text="Publishing CefGlue.BrowserProcess on Windows ($(Platform))..." Importance="High" />
<MSBuild Projects="CefGlue.BrowserProcess.csproj" Targets="Publish" Properties="$(PublishCommonConfig)win-$(ArchitectureConfig);IsEditbinEnabled=True;" />
<!-- LINUX -->
<Message Text="Buiding CefGlue.BrowserProcess on Linux ($(Platform))..." Importance="High" />
<MSBuild Projects="CefGlue.BrowserProcess.csproj" Targets="Build" Properties="$(PublishCommonConfig)linux-$(ArchitectureConfig);IsEditbinEnabled=False;" />

<!-- LINUX -->
<Message Text="Publishing CefGlue.BrowserProcess on Linux ($(Platform))..." Importance="High" />
<MSBuild Projects="CefGlue.BrowserProcess.csproj" Targets="Publish" Properties="$(PublishCommonConfig)linux-$(ArchitectureConfig);IsEditbinEnabled=False;" />
<!-- OSX -->
<Message Text="Buiding CefGlue.BrowserProcess on MacOS ($(Platform))..." Importance="High" />
<MSBuild Projects="CefGlue.BrowserProcess.csproj" Targets="Build" Properties="$(PublishCommonConfig)osx-$(ArchitectureConfig);IsEditbinEnabled=False;" />
</Target>

<!-- OSX -->
<Message Text="Publishing CefGlue.BrowserProcess on MacOS ($(Platform))..." Importance="High" />
<MSBuild Projects="CefGlue.BrowserProcess.csproj" Targets="Publish" Properties="$(PublishCommonConfig)osx-$(ArchitectureConfig);IsEditbinEnabled=False;" />
</Target>
</Project>
4 changes: 0 additions & 4 deletions CefGlue.Common.Shared/CefGlue.Common.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,4 @@
<ProjectReference Include="..\CefGlue\CefGlue.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" />
</ItemGroup>

</Project>
26 changes: 8 additions & 18 deletions CefGlue.Common/CefGlue.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\CefGlue.Packages.props" />

<PropertyGroup>
<TargetFramework>$(DotnetVersion)</TargetFramework>
<AssemblyName>Xilium.CefGlue.Common</AssemblyName>
Expand All @@ -21,10 +21,6 @@
<None Include="BaseCefBrowser.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" />
</ItemGroup>

<ItemGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(DefineConstants), '(^|;)HAS_NLOG($|;)'))">
<PackageReference Include="NLog" />
</ItemGroup>
Expand All @@ -40,12 +36,6 @@
<IncludeAssets>CefGlue.dll</IncludeAssets>
</ProjectReference>

<!-- Forces BrowserProcess build before CopyProjectReferencesToPackage target run -->
<ProjectReference Include="..\CefGlue.BrowserProcess\CefGlue.BrowserProcess.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<PrivateAssets>all</PrivateAssets>
</ProjectReference>

<None Include="build\CefGlue.Common.props" Pack="True" PackagePath="build\CefGlue.Common$(PackageSuffix).props" />
<None Include="build\CefGlue.Common.targets" Pack="True" PackagePath="build\CefGlue.Common$(PackageSuffix).targets" />
<None Include="build\CefGlue.Common.props" Pack="True" PackagePath="buildTransitive\CefGlue.Common$(PackageSuffix).props" />
Expand All @@ -56,16 +46,16 @@
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />

<TfmSpecificPackageFile Include="..\CefGlue.BrowserProcess\bin\$(Platform)\$(Configuration)\$(DotnetVersion)\win-$(ArchitectureConfig)\publish\**\*">
<PackagePath>bin\win-$(ArchitectureConfig)</PackagePath>
<TfmSpecificPackageFile Include="..\CefGlue.BrowserProcess\bin\$(Platform)\$(Configuration)\$(DotnetVersion)\win-$(ArchitectureConfig)\Xilium.CefGlue.BrowserProcess.*">
<PackagePath>runtimes\win-$(ArchitectureConfig)\native</PackagePath>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Include="..\CefGlue.BrowserProcess\bin\$(Platform)\$(Configuration)\$(DotnetVersion)\linux-$(ArchitectureConfig)\publish\**\*">
<PackagePath>bin\linux-$(ArchitectureConfig)</PackagePath>

<TfmSpecificPackageFile Include="..\CefGlue.BrowserProcess\bin\$(Platform)\$(Configuration)\$(DotnetVersion)\linux-$(ArchitectureConfig)\Xilium.CefGlue.BrowserProcess.*">
<PackagePath>runtimes\linux-$(ArchitectureConfig)\native</PackagePath>
</TfmSpecificPackageFile>

<TfmSpecificPackageFile Include="..\CefGlue.BrowserProcess\bin\$(Platform)\$(Configuration)\$(DotnetVersion)\osx-$(ArchitectureConfig)\publish\**\*">
<PackagePath>bin\osx-$(ArchitectureConfig)</PackagePath>
<TfmSpecificPackageFile Include="..\CefGlue.BrowserProcess\bin\$(Platform)\$(Configuration)\$(DotnetVersion)\osx-$(ArchitectureConfig)\Xilium.CefGlue.BrowserProcess.*">
<PackagePath>runtimes\osx-$(ArchitectureConfig)\native</PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
</Target>
Expand Down
7 changes: 3 additions & 4 deletions CefGlue.Common/CefRuntimeLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
using System.Reflection;
using Xilium.CefGlue.Common.Handlers;
using Xilium.CefGlue.Common.Shared;
using System.Runtime.InteropServices;

namespace Xilium.CefGlue.Common
{
public static class CefRuntimeLoader
{
private const string DefaultBrowserProcessDirectory = "CefGlueBrowserProcess";

private static Action<BrowserProcessHandler> _delayedInitialization;

public static void Initialize(CefSettings settings = null, KeyValuePair<string, string>[] flags = null, CustomScheme[] customSchemes = null)
Expand Down Expand Up @@ -90,12 +89,12 @@ private static void InternalInitialize(CefSettings settings = null, KeyValuePair

private static IEnumerable<string> GetSubProcessPaths(string baseDirectory)
{
yield return Path.Combine(baseDirectory, DefaultBrowserProcessDirectory, BrowserProcessFileName);
yield return Path.Combine(baseDirectory, $"runtimes/{RuntimeInformation.RuntimeIdentifier}/native", BrowserProcessFileName);
yield return Path.Combine(baseDirectory, BrowserProcessFileName);

// The executing DLL might not be in the current domain directory (plugins scenario)
baseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
yield return Path.Combine(baseDirectory, DefaultBrowserProcessDirectory, BrowserProcessFileName);
yield return Path.Combine(baseDirectory, $"runtimes/{RuntimeInformation.RuntimeIdentifier}/native", BrowserProcessFileName);
yield return Path.Combine(baseDirectory, BrowserProcessFileName);
}

Expand Down
32 changes: 23 additions & 9 deletions CefGlue.Common/build/CefGlue.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,44 @@
<!-- adding the supported indentifiers to make bundle work properly -->
<RuntimeIdentifiers>osx-x64;osx-arm64;win-x64;win-arm64;linux-x64;linux-arm64</RuntimeIdentifiers>
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)' == '' and $([MSBuild]::IsOSPlatform('Windows'))">
<CefGlueTargetPlatform Condition="'$(Platform)' == 'x64'">win-x64</CefGlueTargetPlatform>
<CefGlueTargetPlatform Condition="'$(Platform)' == 'ARM64'">win-arm64</CefGlueTargetPlatform>
<CefGlueTargetPlatform Condition="'$(CefGlueTargetPlatform)' == ''">win-x64</CefGlueTargetPlatform> <!-- fallback -->
<CefGlueTargetPlatform Condition="'$(CefGlueTargetPlatform)' == ''">win-x64</CefGlueTargetPlatform>
<!-- fallback -->
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)' == '' and $([MSBuild]::IsOSPlatform('Linux'))">
<CefGlueTargetPlatform Condition="'$(Platform)' == 'x64'">linux-x64</CefGlueTargetPlatform>
<CefGlueTargetPlatform Condition="'$(Platform)' == 'ARM64'">linux-arm64</CefGlueTargetPlatform>
<CefGlueTargetPlatform Condition="'$(CefGlueTargetPlatform)' == ''">linux-x64</CefGlueTargetPlatform> <!-- fallback -->
<CefGlueTargetPlatform Condition="'$(CefGlueTargetPlatform)' == ''">linux-x64</CefGlueTargetPlatform>
<!-- fallback -->
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)' == '' and $([MSBuild]::IsOSPlatform('OSX'))">
<CefGlueTargetPlatform Condition="'$(Platform)' == 'x64'">osx-x64</CefGlueTargetPlatform>
<CefGlueTargetPlatform Condition="'$(Platform)' == 'ARM64'">osx-arm64</CefGlueTargetPlatform>
<CefGlueTargetPlatform Condition="'$(CefGlueTargetPlatform)' == ''">osx-arm64</CefGlueTargetPlatform> <!-- fallback -->
<CefGlueTargetPlatform Condition="'$(CefGlueTargetPlatform)' == ''">osx-arm64</CefGlueTargetPlatform>
<!-- fallback -->
</PropertyGroup>

<PropertyGroup Condition="'$(RuntimeIdentifier)' != ''">
<CefGlueTargetPlatform>$(RuntimeIdentifier)</CefGlueTargetPlatform>
</PropertyGroup>

<ItemGroup Condition="'$(CefGlueTargetPlatform)' != ''">
<CefGlueBrowserProcessFiles Include="$(MSBuildThisFileDirectory)..\bin\$(CefGlueTargetPlatform)\*" />
<!-- copy lib to run BrowserProcess -->
<ItemGroup Condition="'$(RuntimeIdentifier)' == ''">
<None Include="$(MSBuildThisFileDirectory)..\lib\net8.0\Xilium.CefGlue.dll">
<Link>$(CefGlueBrowserProcessRuntimeDirectory)\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</None>
<None Include="$(MSBuildThisFileDirectory)..\lib\net8.0\Xilium.CefGlue.Common.Shared.dll">
<Link>$(CefGlueBrowserProcessRuntimeDirectory)%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</None>
</ItemGroup>
</Project>

</Project>
Loading
Loading