Nuget - Improve package.config support

- Add debugging target (optional)
- Add check for file exists on disk to perform copy if required
This commit is contained in:
Alex Maitland
2021-01-27 15:29:10 +10:00
parent a04af915e1
commit 354d88b072
2 changed files with 26 additions and 33 deletions
+1
View File
@@ -25,6 +25,7 @@
<file src="..\CefSharp.Core\bin\Release\CefSharp.Core.pdb" target="lib\net452"/>
<!-- Net Core Libs -->
<!-- These are actually our net452 libs, we just put them in the netcoreapp3 folder for better support -->
<file src="..\CefSharp\bin\Release\CefSharp.dll" target="ref\netcoreapp3.0"/>
<file src="..\CefSharp.Core\bin\Release\CefSharp.Core.dll" target="ref\netcoreapp3.0"/>
+25 -33
View File
@@ -11,9 +11,25 @@
<Delete Files="$(OutDir)CefSharp.Core.Runtime.xml" />
</Target>
<!-- <Target Name="CefSharpAfterBuildDebug" AfterTargets="AfterBuild"> -->
<!-- <Message Importance="high" Text="CefSharp - ResourceFilesCopied = $(CefSharpResourceFilesCopied)" /> -->
<!-- </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="CefSharpTargetDir = $(CefSharpTargetDir)" />
<Message Importance="high" Text="CefSharpTargetDirAnyCpu32 = $(CefSharpTargetDirAnyCpu32)" />
<Message Importance="high" Text="CefSharpTargetDirAnyCpu64 = $(CefSharpTargetDirAnyCpu64)" />
<Message Importance="high" Text="RuntimeIdentifier = $(RuntimeIdentifier)" />
<Message Importance="high" Text="TargetFramework = $(PlatformTarget)" />
<Message Importance="high" Text="libcef.dll exists = $(OutDir)$(CefSharpTargetDir)libcef.dll" Condition="Exists('$(OutDir)$(CefSharpTargetDir)libcef.dll')" />
<Message Importance="high" Text="libcef.dll exists AnyCPU(x86) = $(OutDir)$(CefSharpTargetDirAnyCpu32)libcef.dll" Condition="Exists('$(OutDir)$(CefSharpTargetDirAnyCpu32)libcef.dll')" />
<Message Importance="high" Text="libcef.dll exists AnyCPU(x64) = $(OutDir)$(CefSharpTargetDirAnyCpu64)libcef.dll" Condition="Exists('$(OutDir)$(CefSharpTargetDirAnyCpu64)libcef.dll')" />
<Message Importance="high" Text="CefSharpTransformXmlDllPath = $(CefSharpTransformXmlDllPath)" />
</Target>
<PropertyGroup>
<!--
@@ -28,9 +44,9 @@
<PropertyGroup>
<!--
Allowable options are None, Content, NoAction (anything other than None/Content
is the same as NoAction. None is the default (same as selecting the None Build Action in Visual Studio).
For SdkStyle projects (packagereference) set the default build action to Content.
Allowable options are None, Content, NoAction.
None is the default (same as selecting the None Build Action in Visual Studio) for Non-SdkStyle (packages.config)
Content is the default (same as selecting the None Build Action in Visual Studio) for SdkStyle projects (PackageReference)
-->
<CefSharpBuildAction Condition="'$(CefSharpBuildAction)' == '' AND '$(UsingMicrosoftNETSdk)' != 'true'">None</CefSharpBuildAction>
<CefSharpBuildAction Condition="'$(CefSharpBuildAction)' == '' AND '$(UsingMicrosoftNETSdk)' == 'true'">Content</CefSharpBuildAction>
@@ -82,9 +98,6 @@
<Visible>false</Visible>
</None>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</When>
<When Condition="'$(CefSharpBuildAction)' == 'Content'">
<ItemGroup>
@@ -95,9 +108,6 @@
<Visible>false</Visible>
</Content>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</When>
</Choose>
</When>
@@ -121,9 +131,6 @@
<Visible>false</Visible>
</None>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</When>
<When Condition="'$(PlatformTarget)' == 'AnyCPU'">
<ItemGroup>
@@ -168,9 +175,6 @@
<Visible>false</Visible>
</None>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</When>
<!-- x86 and Win32-->
<Otherwise>
@@ -188,9 +192,6 @@
<Visible>false</Visible>
</None>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</Otherwise>
</Choose>
</When>
@@ -211,9 +212,6 @@
<Visible>false</Visible>
</Content>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</When>
<When Condition="'$(PlatformTarget)' == 'AnyCPU'">
<ItemGroup>
@@ -258,9 +256,6 @@
<Visible>false</Visible>
</Content>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</When>
<!-- x86 and Win32-->
<Otherwise>
@@ -278,9 +273,6 @@
<Visible>false</Visible>
</Content>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</Otherwise>
</Choose>
</When>
@@ -306,19 +298,19 @@
The None/Content entries aren't picked up as the .targets file doesn't exist before the Nuget restore (only when using packages.config)
So in that scenario we use a Target to copy the files. Close/reopen the project and the None/Content entries will work as above
-->
<Target Name="CefSharpCopyFilesAfterNugetRestore32" AfterTargets="AfterBuild" Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND '$(CefSharpResourceFilesCopied)' != 'true' AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(PlatformTarget)' == 'x86'">
<Target Name="CefSharpCopyFilesAfterNugetRestore32" AfterTargets="AfterBuild" Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND !Exists('$(OutDir)$(CefSharpTargetDir)libcef.dll') AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(PlatformTarget)' == 'x86'">
<Message Importance="high" Text="CefSharp - Files were not copied by MSBuild after Nuget install/restore, copying (x86) $(OutDir)$(CefSharpTargetDir)" />
<Copy SourceFiles="@(CefRedist32)" DestinationFolder="$(OutDir)$(CefSharpTargetDir)" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(CefSharpCommonBinaries32)" DestinationFolder="$(OutDir)$(CefSharpTargetDir)" SkipUnchangedFiles="true" />
</Target>
<Target Name="CefSharpCopyFilesAfterNugetRestore64" AfterTargets="AfterBuild" Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND '$(CefSharpResourceFilesCopied)' != 'true' AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(PlatformTarget)' == 'x64'">
<Target Name="CefSharpCopyFilesAfterNugetRestore64" AfterTargets="AfterBuild" Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND !Exists('$(OutDir)$(CefSharpTargetDir)libcef.dll') AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(PlatformTarget)' == 'x64'">
<Message Importance="high" Text="CefSharp - Files were not copied by MSBuild after Nuget install/restore, copying (x64) $(OutDir)$(CefSharpTargetDir)" />
<Copy SourceFiles="@(CefRedist64)" DestinationFolder="$(OutDir)$(CefSharpTargetDir)" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(CefSharpCommonBinaries64)" DestinationFolder="$(OutDir)$(CefSharpTargetDir)" SkipUnchangedFiles="true" />
</Target>
<Target Name="CefSharpCopyFilesAfterNugetRestoreAnyCPU" AfterTargets="AfterBuild" Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND '$(CefSharpResourceFilesCopied)' != 'true' AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(PlatformTarget)' == 'AnyCPU'">
<Target Name="CefSharpCopyFilesAfterNugetRestoreAnyCPU" AfterTargets="AfterBuild" Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND !Exists('$(OutDir)$(CefSharpTargetDirAnyCpu32)libcef.dll') AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(PlatformTarget)' == 'AnyCPU'">
<Message Importance="high" Text="CefSharp - Files were not copied by MSBuild after Nuget install/restore, copying (AnyCPU) $(OutDir)$(CefSharpTargetDir)" />
<Copy SourceFiles="@(CefRedist32)" DestinationFolder="$(OutDir)$(CefSharpTargetDirAnyCpu32)" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(CefSharpCommonBinaries32)" DestinationFolder="$(OutDir)$(CefSharpTargetDirAnyCpu32)" SkipUnchangedFiles="true" />