Skip to content

Commit

Permalink
Nuget - Copy files on Nuget install/restore
Browse files Browse the repository at this point in the history
Adding a PropertyGroup to each Chose/When block appears to be enough to get the files copied successfully.

Still needs more testing

Issue #3319
  • Loading branch information
amaitland committed Jan 9, 2021
1 parent 3bba422 commit a29a1df
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NuGet/CefSharp.Common.app.config.x64.transform
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<!-- Add the codebase section if missing. -->
<codeBase xdt:Transform="InsertIfMissing"/>
<!-- Ensure the codeBase version and href are set to the correct values. -->
<codeBase version="87.1.12.0" href="x64/CefSharp.Core.Runtime.dll" xdt:Transform="Replace"/>
<codeBase version="87.1.13.0" href="x64/CefSharp.Core.Runtime.dll" xdt:Transform="Replace"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
2 changes: 1 addition & 1 deletion NuGet/CefSharp.Common.app.config.x86.transform
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<!-- Add the codebase section if missing. -->
<codeBase xdt:Transform="InsertIfMissing"/>
<!-- Ensure the codeBase version and href are set to the correct values. -->
<codeBase version="87.1.12.0" href="x86/CefSharp.Core.Runtime.dll" xdt:Transform="Replace"/>
<codeBase version="87.1.13.0" href="x86/CefSharp.Core.Runtime.dll" xdt:Transform="Replace"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
53 changes: 53 additions & 0 deletions NuGet/CefSharp.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<Delete Files="$(OutDir)CefSharp.Core.Runtime.xml" />
</Target>

<!-- <Target Name="CefSharpAfterBuildDebug" AfterTargets="AfterBuild"> -->
<!-- <Message Importance="high" Text="CefSharp - ResourceFilesCopied = $(CefSharpResourceFilesCopied)" /> -->
<!-- </Target> -->

<PropertyGroup>
<!--
Used for AnyCPU transforming of app.config
Expand Down Expand Up @@ -80,6 +84,9 @@
<Visible>false</Visible>
</None>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</When>
<When Condition="'$(PlatformTarget)' == 'AnyCPU'">
<ItemGroup>
Expand Down Expand Up @@ -124,6 +131,9 @@
<Visible>false</Visible>
</None>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</When>
<!-- x86 and Win32-->
<Otherwise>
Expand All @@ -141,6 +151,9 @@
<Visible>false</Visible>
</None>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</Otherwise>
</Choose>
</When>
Expand All @@ -161,6 +174,9 @@
<Visible>false</Visible>
</Content>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</When>
<When Condition="'$(PlatformTarget)' == 'AnyCPU'">
<ItemGroup>
Expand Down Expand Up @@ -205,6 +221,9 @@
<Visible>false</Visible>
</Content>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</When>
<!-- x86 and Win32-->
<Otherwise>
Expand All @@ -222,6 +241,9 @@
<Visible>false</Visible>
</Content>
</ItemGroup>
<PropertyGroup>
<CefSharpResourceFilesCopied>true</CefSharpResourceFilesCopied>
</PropertyGroup>
</Otherwise>
</Choose>
</When>
Expand All @@ -241,4 +263,35 @@
<Target Name="CefSharpPlatformCheck" BeforeTargets="ResolveAssemblyReferences" Condition="!Exists('$(CefSharpTransformXmlDllPath)') AND '$(PlatformTarget)' == 'AnyCPU' AND '$(CefSharpAnyCpuSupport)' != 'true'">
<Error Text="$(MSBuildThisFileName) is unable to proceeed as your current PlatformTarget is '$(PlatformTarget)'. To target AnyCPU please read https://github.com/cefsharp/CefSharp/issues/1714. Alternatively change your PlatformTarget to x86 or x64 and the relevant files will be copied automatically." HelpKeyword="CefSharpSolutionPlatformCheck" />
</Target>

<!--
Issue https://github.com/dotnet/project-system/issues/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)
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
NOTE: Commented out for now that it's possible that including the PropertyGroup is enough to force the project to copy the files in VS2019 (not tested in any other VS version yet)
Will add/remove this if required after further testing
-->
<!-- <Target Name="CefSharpCopyFilesAfterNugetRestore32" AfterTargets="AfterBuild" Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND '$(CefSharpResourceFilesCopied)' != 'true' AND '$(CefSharpBuildAction)' != 'NoAction' AND '$(PlatformTarget)' == 'x86'"> -->
<!-- <Message Importance="high" Text="CefSharp - Files were not copied by MSBuild after Nuget install/restore, copying (x64) $(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'"> -->
<!-- <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'"> -->
<!-- <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" /> -->

<!-- <Copy SourceFiles="@(CefRedist64)" DestinationFolder="$(OutDir)$(CefSharpTargetDirAnyCpu64)" SkipUnchangedFiles="true" /> -->
<!-- <Copy SourceFiles="@(CefSharpCommonBinaries64)" DestinationFolder="$(OutDir)$(CefSharpTargetDirAnyCpu64)" SkipUnchangedFiles="true" /> -->

<!-- <Copy SourceFiles="@(CefSharpCommonManagedDlls)" DestinationFolder="$(OutDir)$(CefSharpTargetDirAnyCpu32)" SkipUnchangedFiles="true" /> -->
<!-- <Copy SourceFiles="@(CefSharpCommonManagedDlls)" DestinationFolder="$(OutDir)$(CefSharpTargetDirAnyCpu64)" SkipUnchangedFiles="true" /> -->
<!-- </Target> -->
</Project>

0 comments on commit a29a1df

Please sign in to comment.