Skip to content

Commit 0504c33

Browse files
committed
Nuget - Manually copy files after initial Nuget restore
One final attempt to workaround dotnet/project-system#4158 The None/Content entries aren't picked up as the .targets file doesn't exist before the Nuget restore (only when using packages.config) Attempt to copy the files via calling CefRedist32CopyResources/CefRedist64CopyResources tasks. Properties aren't accessible, I believe that tasks should be, so hopefully this copies the files. Build actions like Publish are very unlikely to work correctly as the files won't have been included via the <Content/> entries.
1 parent 3a6334a commit 0504c33

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

NuGet/CefSharp.Common.targets

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,30 @@
379379
So in that scenario we display a message to the user. Close/reopen the project and the None/Content entries will work as above.
380380
I have attempted to copy the files via a Copy Task, unfortunately the .props entries aren't accessible either so that's not feasible.
381381
-->
382-
<Target Name="CefSharpCopyFilesAfterNugetRestore32" AfterTargets="Build" Condition="'$(NuGetProjectStyle)' != 'PackageReference' AND !Exists('$(OutDir)$(CefSharpTargetDir)libcef.dll') AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(CefSharpPlatformTarget)' == 'x86'">
383-
<Message Importance="high" Text="CefSharp - Files were not copied by MSBuild after Nuget install/restore! Please close and re-open $(MSBuildProjectFile)." />
382+
<Target Name="CefSharpCopyFilesAfterNugetRestore32" AfterTargets="Build" Condition="'$(NuGetProjectStyle)' != 'PackageReference' AND !Exists('$(TargetDir)$(CefSharpTargetDir)libcef.dll') AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(CefSharpPlatformTarget)' == 'x86'">
383+
<PropertyGroup>
384+
<CefRedist32TargetDir Condition="'$(CefRedist32TargetDir)' == ''">$(TargetDir)$(CefSharpTargetDir)</CefRedist32TargetDir>
385+
</PropertyGroup>
386+
<Message Importance="high" Text="CefSharp - Files were not copied by MSBuild after Nuget install/restore! Manually copying files to $(CefRedist32TargetDir) as workaround. Please close and re-open $(MSBuildProjectFile)." />
387+
<CallTarget Targets="CefRedist32CopyResources"/>
384388
</Target>
385389

386-
<Target Name="CefSharpCopyFilesAfterNugetRestore64" AfterTargets="Build" Condition="'$(NuGetProjectStyle)' != 'PackageReference' AND !Exists('$(OutDir)$(CefSharpTargetDir)libcef.dll') AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(CefSharpPlatformTarget)' == 'x64'">
387-
<Message Importance="high" Text="CefSharp - Files were not copied by MSBuild after Nuget install/restore! Please close and re-open $(MSBuildProjectFile)." />
390+
<Target Name="CefSharpCopyFilesAfterNugetRestore64" AfterTargets="Build" Condition="'$(NuGetProjectStyle)' != 'PackageReference' AND !Exists('$(TargetDir)$(CefSharpTargetDir)libcef.dll') AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(CefSharpPlatformTarget)' == 'x64'">
391+
<PropertyGroup>
392+
<CefRedist64TargetDir Condition="'$(CefRedist64TargetDir)' == ''">$(TargetDir)$(CefSharpTargetDir)</CefRedist64TargetDir>
393+
</PropertyGroup>
394+
<Message Importance="high" Text="CefSharp - Files were not copied by MSBuild after Nuget install/restore! Manually copying files to $(CefRedist64TargetDir) as workaround. Please close and re-open $(MSBuildProjectFile)." />
395+
<CallTarget Targets="CefRedist64CopyResources"/>
388396
</Target>
389397

390-
<Target Name="CefSharpCopyFilesAfterNugetRestoreAnyCPU" AfterTargets="Build" Condition="'$(NuGetProjectStyle)' != 'PackageReference' AND !Exists('$(OutDir)$(CefSharpTargetDirAnyCpu32)libcef.dll') AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(CefSharpPlatformTarget)' == 'AnyCPU'">
391-
<Message Importance="high" Text="CefSharp - Files were not copied by MSBuild after Nuget install/restore! Please close and re-open $(MSBuildProjectFile)." />
398+
<Target Name="CefSharpCopyFilesAfterNugetRestoreAnyCPU" AfterTargets="Build" Condition="'$(NuGetProjectStyle)' != 'PackageReference' AND !Exists('$(TargetDir)$(CefSharpTargetDirAnyCpu32)libcef.dll') AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(CefSharpPlatformTarget)' == 'AnyCPU'">
399+
<PropertyGroup>
400+
<CefRedist32TargetDir Condition="'$(CefRedist32TargetDir)' == ''">$(TargetDir)$(CefSharpTargetDirAnyCpu32)</CefRedist32TargetDir>
401+
<CefRedist64TargetDir Condition="'$(CefRedist64TargetDir)' == ''">$(TargetDir)$(CefSharpTargetDirAnyCpu64)</CefRedist64TargetDir>
402+
</PropertyGroup>
403+
<Message Importance="high" Text="CefSharp - Files were not copied by MSBuild after Nuget install/restore! Manually copying files to output folder as workaround. Please close and re-open $(MSBuildProjectFile)." />
404+
<CallTarget Targets="CefRedist32CopyResources"/>
405+
<CallTarget Targets="CefRedist64CopyResources"/>
392406
</Target>
393407

394408
<!--

0 commit comments

Comments
 (0)