Skip to content

Commit

Permalink
Fixes packages not working for exported apps
Browse files Browse the repository at this point in the history
This commit also drops the VL.CEF.Renderer package. All its contents are now included by the main package.
  • Loading branch information
azeno committed Sep 18, 2023
1 parent af56250 commit f0743e2
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 108 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<!-- Version information -->
<Year>$([System.DateTime]::Now.ToString('yyyy'))</Year>
<Version>0.5.0-preview.4</Version>
<Version>0.5.0-preview.5</Version>

<!-- Package properties -->
<Authors>vvvv group</Authors>
Expand Down
44 changes: 5 additions & 39 deletions VL.CEF.Renderer/VL.CEF.Renderer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Platforms>x64;x86</Platforms>
<SelfContained>false</SelfContained>
<OutputPath>..\VL.CEF\lib\$(TargetFramework)\renderer\</OutputPath>
<OutputPath>bin</OutputPath>

<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<IsPackable>false</IsPackable>

<!-- Disable pack warning about dlls being in wrong folder - this package delivers the whole renderer app -->
<NoWarn>NU5128;NU5100</NoWarn>
</PropertyGroup>

<!-- Manually include cef dlls and resources in nu packages and copy them to build directory -->
<!-- Copy CEF dlls and resources to build directory -->
<ItemGroup>
<None Include="$(SolutionDir)deps\cef\**">
<None Include="$(SolutionDir)deps\cef\**" Exclude="$(SolutionDir)deps\cef\.git*;$(SolutionDir)deps\cef\*.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</None>
Expand All @@ -25,39 +26,4 @@
<ProjectReference Include="..\deps\cef_glue\CefGlue\CefGlue.csproj" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<None Update="buildTransitive\*" Pack="true" PackagePath="" />
</ItemGroup>

<PropertyGroup>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>

<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
</ItemGroup>
</Target>

<PropertyGroup>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);GetCustomContentPackageFiles</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>

<Target Name="GetCustomContentPackageFiles" DependsOnTargets="ResolveAssemblyReferences;BuiltProjectOutputGroup;GetCopyToOutputDirectoryItems">
<ItemGroup>
<!-- The dll of this project -->
<TfmSpecificPackageFile Include="@(BuiltProjectOutputGroupOutput)">
<PackagePath>renderer</PackagePath>
</TfmSpecificPackageFile>
<!-- The referenced dlls of this project -->
<TfmSpecificPackageFile Include="@(ReferenceCopyLocalPaths)">
<PackagePath>renderer</PackagePath>
</TfmSpecificPackageFile>
<!-- The apphost.exe used as exe for this project as well as all files to be copied to output (native CEF dlls, see None include above) -->
<TfmSpecificPackageFile Include="@(AllItemsFullPathWithTargetPath)">
<PackagePath>renderer\%(AllItemsFullPathWithTargetPath.TargetPath)</PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
</Target>

</Project>
2 changes: 1 addition & 1 deletion VL.CEF.Renderer/WebRendererApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class WebRendererApp : CefApp
[STAThread]
public static int Main(string[] args)
{
CefRuntime.EnableHighDpiSupport();
CefRuntime.Load();
CefRuntime.EnableHighDpiSupport();

var app = new WebRendererApp();
var mainArgs = new CefMainArgs(args);
Expand Down
5 changes: 1 addition & 4 deletions VL.CEF.Skia/src/VL.CEF.Skia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<OutputPath>..\lib</OutputPath>
<Platforms>x64;x86</Platforms>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<!-- Package properties -->
Expand All @@ -17,10 +16,8 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\deps\cef_glue\CefGlue\CefGlue.csproj" PrivateAssets="all" />
<ProjectReference Include="..\..\VL.CEF\src\VL.CEF.csproj">
<ExcludeAssets>runtime</ExcludeAssets>
<Private>False</Private>
<Private>false</Private>
</ProjectReference>
</ItemGroup>

Expand Down
3 changes: 0 additions & 3 deletions VL.CEF.Stride/src/VL.CEF.Stride.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputPath>..\lib</OutputPath>
<Platforms>x64;x86</Platforms>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<!-- Package properties -->
Expand All @@ -25,9 +24,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\deps\cef_glue\CefGlue\CefGlue.csproj" PrivateAssets="all" />
<ProjectReference Include="..\..\VL.CEF\src\VL.CEF.csproj">
<ExcludeAssets>runtime</ExcludeAssets>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
Expand Down
32 changes: 16 additions & 16 deletions VL.CEF.sln
Original file line number Diff line number Diff line change
Expand Up @@ -43,50 +43,50 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Debug|Any CPU.ActiveCfg = Debug|x64
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Debug|Any CPU.Build.0 = Debug|x64
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Debug|x64.ActiveCfg = Debug|x64
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Debug|x64.Build.0 = Debug|x64
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Debug|x86.ActiveCfg = Debug|x86
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Debug|x86.Build.0 = Debug|x86
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Release|Any CPU.ActiveCfg = Release|x64
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Release|Any CPU.Build.0 = Release|x64
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Release|Any CPU.Build.0 = Release|Any CPU
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Release|x64.ActiveCfg = Release|x64
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Release|x64.Build.0 = Release|x64
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Release|x86.ActiveCfg = Release|x86
{D13D1441-EDD2-4EFC-ADAE-4373D8EAB626}.Release|x86.Build.0 = Release|x86
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Debug|Any CPU.ActiveCfg = Debug|x64
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Debug|Any CPU.Build.0 = Debug|x64
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Debug|x64.ActiveCfg = Debug|x64
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Debug|x64.Build.0 = Debug|x64
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Debug|x86.ActiveCfg = Debug|x86
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Debug|x86.Build.0 = Debug|x86
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Release|Any CPU.ActiveCfg = Release|x64
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Release|Any CPU.Build.0 = Release|x64
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Release|Any CPU.Build.0 = Release|Any CPU
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Release|x64.ActiveCfg = Release|x64
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Release|x64.Build.0 = Release|x64
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Release|x86.ActiveCfg = Release|x86
{8E01702E-D677-4CE8-8072-FCAC5DE01163}.Release|x86.Build.0 = Release|x86
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Debug|Any CPU.ActiveCfg = Debug|x64
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Debug|Any CPU.Build.0 = Debug|x64
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Debug|x64.ActiveCfg = Debug|x64
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Debug|x64.Build.0 = Debug|x64
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Debug|x86.ActiveCfg = Debug|x86
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Debug|x86.Build.0 = Debug|x86
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Release|Any CPU.ActiveCfg = Release|x64
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Release|Any CPU.Build.0 = Release|x64
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Release|Any CPU.Build.0 = Release|Any CPU
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Release|x64.ActiveCfg = Release|x64
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Release|x64.Build.0 = Release|x64
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Release|x86.ActiveCfg = Release|x86
{438919E3-FD57-4462-BF43-BCAD49881B5C}.Release|x86.Build.0 = Release|x86
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Debug|Any CPU.ActiveCfg = Debug|x64
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Debug|Any CPU.Build.0 = Debug|x64
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Debug|x64.ActiveCfg = Debug|x64
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Debug|x64.Build.0 = Debug|x64
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Debug|x86.ActiveCfg = Debug|x86
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Debug|x86.Build.0 = Debug|x86
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Release|Any CPU.ActiveCfg = Release|x64
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Release|Any CPU.Build.0 = Release|x64
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Release|Any CPU.Build.0 = Release|Any CPU
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Release|x64.ActiveCfg = Release|x64
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Release|x64.Build.0 = Release|x64
{5A596246-CDC6-49B4-BF76-CB497A438BE7}.Release|x86.ActiveCfg = Release|x86
Expand Down
50 changes: 22 additions & 28 deletions VL.CEF/src/CefExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -16,44 +17,37 @@ namespace VL.CEF
{
public static class CefExtensions
{
static string resolvedRendererPath;
static string? resolvedRendererPath;
static int initCount;

static CefExtensions()
{
const string rendererAssemblyName = "VL.CEF.Renderer";
const string rendererExeName = $"{rendererAssemblyName}.exe";
const string renderer = "renderer";

var thisDirectory = Path.GetDirectoryName(typeof(CefExtensions).Assembly.Location);
// In standalone the webrenderer is in the renderer subfolder
var standalonePath = Path.Combine(thisDirectory, renderer, rendererExeName);
if (File.Exists(standalonePath))
foreach (var rendererExe in GetPotentialRendererExeLocations())
{
resolvedRendererPath = standalonePath;
if (File.Exists(rendererExe))
{
resolvedRendererPath = Path.GetFullPath(rendererExe);
break;
}
}
else

static IEnumerable<string> GetPotentialRendererExeLocations()
{
// Check if we're in package (different folder layout)
var rendererExeAssembly = Assembly.Load(rendererAssemblyName);
if (rendererExeAssembly is null)
throw new FileNotFoundException($"Couldn't find {rendererAssemblyName}");
// Exported app?
var processDir = Path.GetDirectoryName(Environment.ProcessPath);
if (processDir != null)
yield return Path.Combine(processDir, "renderer", "VL.CEF.Renderer.exe");

var packagePath = Path.Combine(Path.GetDirectoryName(rendererExeAssembly.Location), "..", "..", renderer, rendererExeName);
if (File.Exists(packagePath))
var assemblyDir = Path.GetDirectoryName(typeof(CefExtensions).Assembly.Location);
if (assemblyDir != null)
{
resolvedRendererPath = Path.GetFullPath(packagePath);
// Source package?
yield return Path.Combine(assemblyDir, "..", "..", "..", "VL.CEF.Renderer", "bin", "VL.CEF.Renderer.exe");
// Installed package?
yield return Path.Combine(assemblyDir, "..", "..", "renderer", "VL.CEF.Renderer.exe");

}
}

if (resolvedRendererPath is null)
throw new FileNotFoundException("Can't find VL.CEF.Renderer.exe");

// Ensure native libs can be found
var browserDir = Path.GetDirectoryName(resolvedRendererPath);
var pathVariable = Environment.GetEnvironmentVariable("PATH");
if (!pathVariable.Contains(browserDir))
Environment.SetEnvironmentVariable("PATH", $"{pathVariable};{browserDir}");
}

public static IResourceProvider<IDisposable> GetRuntimeProvider()
Expand Down
36 changes: 20 additions & 16 deletions VL.CEF/src/VL.CEF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,42 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputPath>..\lib</OutputPath>
<Platforms>x64;x86</Platforms>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<!-- Package properties -->
<NoWarn>NU5100</NoWarn>
<Description>Chromium Embedded Framework (CEF) for VL</Description>
<PackageReleaseNotes>Popular nodes: WebRenderer</PackageReleaseNotes>
<PackageTags>VL;web;html;texture;vvvv</PackageTags>

<!-- We want our package to have a dependency on VL.CEF.Renderer without the assembly referencing it -->
<!-- Couldn't find a way to express this via project file, therefor we go the manual route here and specify our own nuspec file -->
<NuspecFile>$(MSBuildProjectName).nuspec</NuspecFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="VL.Core" Version="$(VLVersion)" PrivateAssets="all" />
<PackageReference Include="VL.Core" Version="$(VLVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\deps\cef_glue\CefGlue\CefGlue.csproj" PrivateAssets="all" />
<ProjectReference Include="..\..\deps\cef_glue\CefGlue\CefGlue.csproj" />
<ProjectReference Include="..\..\VL.CEF.Renderer\VL.CEF.Renderer.csproj">
<ExcludeAssets>runtime</ExcludeAssets>
<Private>False</Private>
<Private>false</Private>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>

<PropertyGroup>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);GetCustomContentPackageFiles</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>

<Target Name="GetCustomContentPackageFiles" DependsOnTargets="BuiltProjectOutputGroup;GenerateBuildDependencyFile">
<ItemGroup>
<!-- VL files -->
<TfmSpecificPackageFile Include="..\**\*.vl">
<PackagePath></PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
<Target Name="SetNuspecProperties" BeforeTargets="GenerateNuspec">
<PropertyGroup>
<NuspecProperties>
id=$(PackageId);
version=$(PackageVersion);
authors=$(Authors);
license=$(PackageLicenseExpression);
description=$(PackageDescription);
projecturl=$(PackageProjectUrl);
</NuspecProperties>
</PropertyGroup>
</Target>

</Project>
26 changes: 26 additions & 0 deletions VL.CEF/src/VL.CEF.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>$id$</id>
<version>$version$</version>
<authors>$authors$</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">$license$</license>
<projectUrl>$projectUrl$</projectUrl>
<description>$description$</description>
<copyright>$copyright$</copyright>
<tags>$tags$</tags>
<dependencies>
<group targetFramework="net6.0">
</group>
</dependencies>
</metadata>
<files>
<file src="..\lib\net6.0\VL.CEF.dll" target="lib\net6.0" />
<file src="..\lib\net6.0\Xilium.CefGlue.dll" target="lib\net6.0" />
<file src="..\*.vl" target="" />
<file src="..\help\**" target="help" />
<file src="..\..\VL.CEF.Renderer\bin\**" target="renderer" />
<file src="buildTransitive\**" target="buildTransitive" />
</files>
</package>
File renamed without changes.

0 comments on commit f0743e2

Please sign in to comment.