Skip to content

Commit 354d88b

Browse files
committed
Nuget - Improve package.config support
- Add debugging target (optional) - Add check for file exists on disk to perform copy if required
1 parent a04af91 commit 354d88b

File tree

2 files changed

+26
-33
lines changed

2 files changed

+26
-33
lines changed

NuGet/CefSharp.Common.nuspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<file src="..\CefSharp.Core\bin\Release\CefSharp.Core.pdb" target="lib\net452"/>
2626

2727
<!-- Net Core Libs -->
28+
<!-- These are actually our net452 libs, we just put them in the netcoreapp3 folder for better support -->
2829
<file src="..\CefSharp\bin\Release\CefSharp.dll" target="ref\netcoreapp3.0"/>
2930
<file src="..\CefSharp.Core\bin\Release\CefSharp.Core.dll" target="ref\netcoreapp3.0"/>
3031

NuGet/CefSharp.Common.targets

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,25 @@
1111
<Delete Files="$(OutDir)CefSharp.Core.Runtime.xml" />
1212
</Target>
1313

14-
<!-- <Target Name="CefSharpAfterBuildDebug" AfterTargets="AfterBuild"> -->
15-
<!-- <Message Importance="high" Text="CefSharp - ResourceFilesCopied = $(CefSharpResourceFilesCopied)" /> -->
16-
<!-- </Target> -->
14+
<!--
15+
Add to project file for debuggint purposes
16+
<Target Name="CefSharpAfterBuildDebug" AfterTargets="AfterBuild">
17+
<CallTarget Targets="CefSharpAfterBuildDiagnostic"/>
18+
</Target>
19+
-->
20+
<Target Name="CefSharpAfterBuildDiagnostic">
21+
<Message Importance="high" Text="CefSharp After Build Diagnostic" />
22+
<Message Importance="high" Text="CefSharpBuildAction = $(CefSharpBuildAction)" />
23+
<Message Importance="high" Text="CefSharpTargetDir = $(CefSharpTargetDir)" />
24+
<Message Importance="high" Text="CefSharpTargetDirAnyCpu32 = $(CefSharpTargetDirAnyCpu32)" />
25+
<Message Importance="high" Text="CefSharpTargetDirAnyCpu64 = $(CefSharpTargetDirAnyCpu64)" />
26+
<Message Importance="high" Text="RuntimeIdentifier = $(RuntimeIdentifier)" />
27+
<Message Importance="high" Text="TargetFramework = $(PlatformTarget)" />
28+
<Message Importance="high" Text="libcef.dll exists = $(OutDir)$(CefSharpTargetDir)libcef.dll" Condition="Exists('$(OutDir)$(CefSharpTargetDir)libcef.dll')" />
29+
<Message Importance="high" Text="libcef.dll exists AnyCPU(x86) = $(OutDir)$(CefSharpTargetDirAnyCpu32)libcef.dll" Condition="Exists('$(OutDir)$(CefSharpTargetDirAnyCpu32)libcef.dll')" />
30+
<Message Importance="high" Text="libcef.dll exists AnyCPU(x64) = $(OutDir)$(CefSharpTargetDirAnyCpu64)libcef.dll" Condition="Exists('$(OutDir)$(CefSharpTargetDirAnyCpu64)libcef.dll')" />
31+
<Message Importance="high" Text="CefSharpTransformXmlDllPath = $(CefSharpTransformXmlDllPath)" />
32+
</Target>
1733

1834
<PropertyGroup>
1935
<!--
@@ -28,9 +44,9 @@
2844

2945
<PropertyGroup>
3046
<!--
31-
Allowable options are None, Content, NoAction (anything other than None/Content
32-
is the same as NoAction. None is the default (same as selecting the None Build Action in Visual Studio).
33-
For SdkStyle projects (packagereference) set the default build action to Content.
47+
Allowable options are None, Content, NoAction.
48+
None is the default (same as selecting the None Build Action in Visual Studio) for Non-SdkStyle (packages.config)
49+
Content is the default (same as selecting the None Build Action in Visual Studio) for SdkStyle projects (PackageReference)
3450
-->
3551
<CefSharpBuildAction Condition="'$(CefSharpBuildAction)' == '' AND '$(UsingMicrosoftNETSdk)' != 'true'">None</CefSharpBuildAction>
3652
<CefSharpBuildAction Condition="'$(CefSharpBuildAction)' == '' AND '$(UsingMicrosoftNETSdk)' == 'true'">Content</CefSharpBuildAction>
@@ -82,9 +98,6 @@
8298
<Visible>false</Visible>
8399
</None>
84100
</ItemGroup>
85-
<PropertyGroup>
86-
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
87-
</PropertyGroup>
88101
</When>
89102
<When Condition="'$(CefSharpBuildAction)' == 'Content'">
90103
<ItemGroup>
@@ -95,9 +108,6 @@
95108
<Visible>false</Visible>
96109
</Content>
97110
</ItemGroup>
98-
<PropertyGroup>
99-
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
100-
</PropertyGroup>
101111
</When>
102112
</Choose>
103113
</When>
@@ -121,9 +131,6 @@
121131
<Visible>false</Visible>
122132
</None>
123133
</ItemGroup>
124-
<PropertyGroup>
125-
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
126-
</PropertyGroup>
127134
</When>
128135
<When Condition="'$(PlatformTarget)' == 'AnyCPU'">
129136
<ItemGroup>
@@ -168,9 +175,6 @@
168175
<Visible>false</Visible>
169176
</None>
170177
</ItemGroup>
171-
<PropertyGroup>
172-
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
173-
</PropertyGroup>
174178
</When>
175179
<!-- x86 and Win32-->
176180
<Otherwise>
@@ -188,9 +192,6 @@
188192
<Visible>false</Visible>
189193
</None>
190194
</ItemGroup>
191-
<PropertyGroup>
192-
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
193-
</PropertyGroup>
194195
</Otherwise>
195196
</Choose>
196197
</When>
@@ -211,9 +212,6 @@
211212
<Visible>false</Visible>
212213
</Content>
213214
</ItemGroup>
214-
<PropertyGroup>
215-
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
216-
</PropertyGroup>
217215
</When>
218216
<When Condition="'$(PlatformTarget)' == 'AnyCPU'">
219217
<ItemGroup>
@@ -258,9 +256,6 @@
258256
<Visible>false</Visible>
259257
</Content>
260258
</ItemGroup>
261-
<PropertyGroup>
262-
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
263-
</PropertyGroup>
264259
</When>
265260
<!-- x86 and Win32-->
266261
<Otherwise>
@@ -278,9 +273,6 @@
278273
<Visible>false</Visible>
279274
</Content>
280275
</ItemGroup>
281-
<PropertyGroup>
282-
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
283-
</PropertyGroup>
284276
</Otherwise>
285277
</Choose>
286278
</When>
@@ -306,19 +298,19 @@
306298
The None/Content entries aren't picked up as the .targets file doesn't exist before the Nuget restore (only when using packages.config)
307299
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
308300
-->
309-
<Target Name="CefSharpCopyFilesAfterNugetRestore32" AfterTargets="AfterBuild" Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND '$(CefSharpResourceFilesCopied)' != 'true' AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(PlatformTarget)' == 'x86'">
301+
<Target Name="CefSharpCopyFilesAfterNugetRestore32" AfterTargets="AfterBuild" Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND !Exists('$(OutDir)$(CefSharpTargetDir)libcef.dll') AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(PlatformTarget)' == 'x86'">
310302
<Message Importance="high" Text="CefSharp - Files were not copied by MSBuild after Nuget install/restore, copying (x86) $(OutDir)$(CefSharpTargetDir)" />
311303
<Copy SourceFiles="@(CefRedist32)" DestinationFolder="$(OutDir)$(CefSharpTargetDir)" SkipUnchangedFiles="true" />
312304
<Copy SourceFiles="@(CefSharpCommonBinaries32)" DestinationFolder="$(OutDir)$(CefSharpTargetDir)" SkipUnchangedFiles="true" />
313305
</Target>
314306

315-
<Target Name="CefSharpCopyFilesAfterNugetRestore64" AfterTargets="AfterBuild" Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND '$(CefSharpResourceFilesCopied)' != 'true' AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(PlatformTarget)' == 'x64'">
307+
<Target Name="CefSharpCopyFilesAfterNugetRestore64" AfterTargets="AfterBuild" Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND !Exists('$(OutDir)$(CefSharpTargetDir)libcef.dll') AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(PlatformTarget)' == 'x64'">
316308
<Message Importance="high" Text="CefSharp - Files were not copied by MSBuild after Nuget install/restore, copying (x64) $(OutDir)$(CefSharpTargetDir)" />
317309
<Copy SourceFiles="@(CefRedist64)" DestinationFolder="$(OutDir)$(CefSharpTargetDir)" SkipUnchangedFiles="true" />
318310
<Copy SourceFiles="@(CefSharpCommonBinaries64)" DestinationFolder="$(OutDir)$(CefSharpTargetDir)" SkipUnchangedFiles="true" />
319311
</Target>
320312

321-
<Target Name="CefSharpCopyFilesAfterNugetRestoreAnyCPU" AfterTargets="AfterBuild" Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND '$(CefSharpResourceFilesCopied)' != 'true' AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(PlatformTarget)' == 'AnyCPU'">
313+
<Target Name="CefSharpCopyFilesAfterNugetRestoreAnyCPU" AfterTargets="AfterBuild" Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND !Exists('$(OutDir)$(CefSharpTargetDirAnyCpu32)libcef.dll') AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(PlatformTarget)' == 'AnyCPU'">
322314
<Message Importance="high" Text="CefSharp - Files were not copied by MSBuild after Nuget install/restore, copying (AnyCPU) $(OutDir)$(CefSharpTargetDir)" />
323315
<Copy SourceFiles="@(CefRedist32)" DestinationFolder="$(OutDir)$(CefSharpTargetDirAnyCpu32)" SkipUnchangedFiles="true" />
324316
<Copy SourceFiles="@(CefSharpCommonBinaries32)" DestinationFolder="$(OutDir)$(CefSharpTargetDirAnyCpu32)" SkipUnchangedFiles="true" />

0 commit comments

Comments
 (0)