Files
cefsharp/NuGet/PackageReference/CefSharp.Common.NETCore.targets

229 lines
13 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Map RuntimeIdentifier e.g. converts from win10-x64 to win-x64 -->
<CefSharpRuntimeIdentifier>$(RuntimeIdentifier)</CefSharpRuntimeIdentifier>
<CefSharpRuntimeIdentifier Condition="$(RuntimeIdentifier.StartsWith('win')) and $(RuntimeIdentifier.Contains('-x86'))">win-x86</CefSharpRuntimeIdentifier>
<CefSharpRuntimeIdentifier Condition="$(RuntimeIdentifier.StartsWith('win')) and $(RuntimeIdentifier.Contains('-x64'))">win-x64</CefSharpRuntimeIdentifier>
<CefSharpRuntimeIdentifier Condition="$(RuntimeIdentifier.StartsWith('win')) and $(RuntimeIdentifier.Contains('-arm64'))">win-arm64</CefSharpRuntimeIdentifier>
<CefSharpRuntimeIdentifier Condition="'$(CefSharpRuntimeIdentifierOverride)' != ''">$(CefSharpRuntimeIdentifierOverride)</CefSharpRuntimeIdentifier>
<!--
For SelfContained and SingleFile under .Net 5+ we don't include a default BrowserSubprocess files
SelfHosting of the BrowserSubprocess is required
Issue https://github.com/cefsharp/CefSharp/issues/3407
-->
<CefSharpExcludeSubProcessExe Condition="'$(CefSharpExcludeSubProcessExe)' == '' AND '$(_TargetFrameworkVersionWithoutV)' >= '5.0' AND '$(PublishSingleFile)' == 'true' AND '$(SelfContained)' == 'true'">true</CefSharpExcludeSubProcessExe>
<!--
For Library projects we don't include our additional files and packages, the transitive reference should flow directly to the consuming projects.
For class libraries that are often AnyCPU and consuming Exe/WinExe projects that are often win-x64 or win-x86 the resuiling build output
is polluted with extra copies in sub folders.
If EnableDynamicLoading = true then CefSharpBuildAction will be Default unless otherwise specified
https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support#plugin-with-library-dependencies
-->
<CefSharpBuildAction Condition="'$(CefSharpBuildAction)' == '' AND '$(OutputType)' == 'Library' AND '$(EnableDynamicLoading)' != 'true'">NoAction</CefSharpBuildAction>
<!--
Current supported values are Default, Content, and NoAction (this target doesn't copy any files.)
For backwards compatability for the older nuget packages Content will be mapped to Default
-->
<CefSharpBuildAction Condition="'$(CefSharpBuildAction)' == ''">Default</CefSharpBuildAction>
<CefSharpBuildAction Condition="'$(CefSharpBuildAction)' == 'Content'">Default</CefSharpBuildAction>
</PropertyGroup>
<ItemGroup>
<_CefSharpBrowserSubProcessFiles Include="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\runtimes\$(CefSharpRuntimeIdentifier)\native\CefSharp.BrowserSubprocess.runtimeconfig.json'))"/>
<_CefSharpBrowserSubProcessFiles Include="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\runtimes\$(CefSharpRuntimeIdentifier)\native\CefSharp.BrowserSubprocess.exe'))" Condition="'$(CefSharpExcludeSubProcessExe)' == 'true'"/>
<_CefSharpBrowserSubProcessFiles Include="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\runtimes\$(CefSharpRuntimeIdentifier)\native\CefSharp.BrowserSubprocess.dll'))" Condition="'$(CefSharpExcludeSubProcessExe)' == 'true'"/>
</ItemGroup>
<!--
For SelfContained and PublishSingleFile we remove the CefSharp.BrowserSubprocess.runtimeconfig.json file so
the BrowserSubprocess runs using the packaged .net runtime
Issue https://github.com/cefsharp/CefSharp/issues/3407
-->
<Target Name="CefSharpExcludeBrowserSubprocessRuntimeConfigAfterResolveAssemblyReferences" AfterTargets="ResolveAssemblyReferences" Condition="'$(CefSharpRuntimeIdentifier)' != '' AND '$(SelfContained)' == 'true'">
<ItemGroup>
<ReferenceCopyLocalPaths Remove="@(_CefSharpBrowserSubProcessFiles)" />
</ItemGroup>
</Target>
<Target Name="CefSharpExcludeBrowserSubprocessRuntimeConfigAfterComputeFilesToPublish" AfterTargets="ComputeFilesToPublish" Condition="'$(CefSharpRuntimeIdentifier)' != '' AND '$(SelfContained)' == 'true'">
<ItemGroup>
<ResolvedFileToPublish Remove="@(_CefSharpBrowserSubProcessFiles)" />
</ItemGroup>
</Target>
<!--
For SelfContained and SingleFile under .Net 5+ we don't include a default BrowserSubprocess files
SelfHosting of the BrowserSubprocess is required
Issue https://github.com/cefsharp/CefSharp/issues/3407
-->
<Target Name="CefSharpExcludeBrowserSubprocessRuntimeConfigBeforeComputeFilesToBundle" BeforeTargets="_ComputeFilesToBundle" Condition="'$(CefSharpRuntimeIdentifier)' != '' AND '$(SelfContained)' == 'true'">
<ItemGroup>
<ResolvedFileToPublish Remove="@(_CefSharpBrowserSubProcessFiles)" />
</ItemGroup>
</Target>
<!--
Remove from $(project).deps.json (sometimes the main deps file is reused)
-->
<Target Name="CefSharpExcludeBrowserSubprocessRuntimeConfigBeforeGenerateDependencyFile" BeforeTargets="GenerateBuildDependencyFile;GeneratePublishDependencyFile" Condition="'$(CefSharpRuntimeIdentifier)' != '' AND '$(SelfContained)' == 'true'">
<ItemGroup>
<NativeCopyLocalItems Remove="@(_CefSharpBrowserSubProcessFiles)" />
</ItemGroup>
</Target>
<!--
Add to project file for debuggint purposes
<Target Name="CefSharpAfterBuildDebug" AfterTargets="AfterBuild">
<CallTarget Targets="CefSharpAfterBuildDiagnostic"/>
</Target>
-->
<Target Name="CefSharpAfterBuildDiagnostic">
<Message Importance="high" Text="CefSharp After Build Diagnostic" />
<Message Importance="high" Text="CefSharpBuildAction = $(CefSharpBuildAction)" />
<Message Importance="high" Text="CefSharpExcludeSubProcessExe = $(CefSharpExcludeSubProcessExe)" />
<Message Importance="high" Text="RuntimeIdentifier = $(RuntimeIdentifier)" />
<Message Importance="high" Text="CefSharpRuntimeIdentifier = $(CefSharpRuntimeIdentifier)" />
<Message Importance="high" Text="Platform = $(Platform)" />
<Message Importance="high" Text="PlatformName = $(PlatformName)" />
<Message Importance="high" Text="Platforms = $(Platforms)" />
<Message Importance="high" Text="PlatformTarget = $(PlatformTarget)" />
<Message Importance="high" Text="PlatformTargetAsMSBuildArchitecture = $(PlatformTargetAsMSBuildArchitecture)" />
<Message Importance="high" Text="TargetFramework = $(TargetFramework)" />
<Message Importance="high" Text="TargetFrameworkVersion = $(TargetFrameworkVersion)" />
<Message Importance="high" Text="NuGetProjectStyle = $(NuGetProjectStyle)" />
<Message Importance="high" Text="SelfContained = $(SelfContained)" />
<Message Importance="high" Text="PublishSingleFile = $(PublishSingleFile)" />
<Message Importance="high" Text="OutDir = $(OutDir)" />
<Message Importance="high" Text="_CefSharpBrowserSubProcessFiles = @(_CefSharpBrowserSubProcessFiles)" />
<Message Importance="high" Text="IncludeAllContentForSelfExtract = $(IncludeAllContentForSelfExtract)" />
<Message Importance="high" Text="IncludeNativeLibrariesForSelfExtract = $(IncludeNativeLibrariesForSelfExtract)" />
</Target>
<Choose>
<When Condition="'$(CefSharpBuildAction)' == 'NoAction'">
<!-- Do nothing -->
</When>
<When Condition="'$(CefSharpRuntimeIdentifier)' == 'win-x64'">
<ItemGroup>
<Content Include="@(CefRuntimeWin64Locales)">
<Link>locales\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<IncludeInVsix>true</IncludeInVsix>
</Content>
</ItemGroup>
</When>
<When Condition="'$(CefSharpRuntimeIdentifier)' == 'win-x86'">
<ItemGroup>
<Content Include="@(CefRuntimeWin32Locales)">
<Link>locales\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<IncludeInVsix>true</IncludeInVsix>
</Content>
</ItemGroup>
</When>
<When Condition="'$(CefSharpRuntimeIdentifier)' == 'win-arm64'">
<ItemGroup>
<Content Include="@(CefRuntimeWinArm64Locales)">
<Link>locales\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<IncludeInVsix>true</IncludeInVsix>
</Content>
</ItemGroup>
</When>
<Otherwise>
<Choose>
<When Condition="'$(ManagePackageVersionsCentrally)' == 'true'">
<ItemGroup>
<PackageReference Include="chromiumembeddedframework.runtime.win-x64" VersionOverride="140.1.14" />
<PackageReference Include="chromiumembeddedframework.runtime.win-x86" VersionOverride="140.1.14" />
<PackageReference Include="chromiumembeddedframework.runtime.win-arm64" VersionOverride="140.1.14" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="chromiumembeddedframework.runtime.win-x64" Version="140.1.14" />
<PackageReference Include="chromiumembeddedframework.runtime.win-x86" Version="140.1.14" />
<PackageReference Include="chromiumembeddedframework.runtime.win-arm64" Version="140.1.14" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Content Include="@(CefRuntimeWin32Locales)">
<Link>runtimes\win-x86\native\locales\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<IncludeInVsix>true</IncludeInVsix>
</Content>
<Content Include="$(MSBuildThisFileDirectory)..\runtimes\win-x86\lib\net6.0\CefSharp.dll">
<Link>runtimes\win-x86\native\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<IncludeInVsix>true</IncludeInVsix>
</Content>
<Content Include="$(MSBuildThisFileDirectory)..\runtimes\win-x86\lib\net6.0\Ijwhost.dll">
<Link>runtimes\win-x86\native\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<IncludeInVsix>true</IncludeInVsix>
</Content>
<Content Include="@(CefRuntimeWin64Locales)">
<Link>runtimes\win-x64\native\locales\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<IncludeInVsix>true</IncludeInVsix>
</Content>
<Content Include="$(MSBuildThisFileDirectory)..\runtimes\win-x64\lib\net6.0\CefSharp.dll">
<Link>runtimes\win-x64\native\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<IncludeInVsix>true</IncludeInVsix>
</Content>
<Content Include="$(MSBuildThisFileDirectory)..\runtimes\win-x64\lib\net6.0\Ijwhost.dll">
<Link>runtimes\win-x64\native\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<IncludeInVsix>true</IncludeInVsix>
</Content>
<Content Include="@(CefRuntimeWinArm64Locales)">
<Link>runtimes\win-arm64\native\locales\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<IncludeInVsix>true</IncludeInVsix>
</Content>
<Content Include="$(MSBuildThisFileDirectory)..\runtimes\win-arm64\lib\net6.0\CefSharp.dll">
<Link>runtimes\win-arm64\native\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<IncludeInVsix>true</IncludeInVsix>
</Content>
<Content Include="$(MSBuildThisFileDirectory)..\runtimes\win-arm64\lib\net6.0\Ijwhost.dll">
<Link>runtimes\win-arm64\native\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PublishState>Included</PublishState>
<Visible>false</Visible>
<IncludeInVsix>true</IncludeInVsix>
</Content>
</ItemGroup>
</Otherwise>
</Choose>
</Project>