wp-net / WordPressPCL

This is a portable library for consuimg the WordPress REST-API in (almost) any C# application
MIT License
335 stars 131 forks source link

Unable to install into VS2015 project targeting .NET Framework 4.8 #328

Open mmacneill123 opened 1 year ago

mmacneill123 commented 1 year ago

Hi All

Trying to get this into a VS2015 project targetting .NET Framework 4.8 (which from the docs looks like it should be no problem) but get this when trying to install:

PM> Install-Package WordPressPCL

Attempting to gather dependency information for package 'WordPressPCL.2.0.0' with respect to project 'AutomationDashboard', targeting '.NETFramework,Version=v4.8' Gathering dependency information took 390.56 ms Attempting to resolve dependencies for package 'WordPressPCL.2.0.0' with DependencyBehavior 'Lowest' Resolving dependency information took 0 ms Resolving actions to install package 'WordPressPCL.2.0.0' Resolved actions to install package 'WordPressPCL.2.0.0' Retrieving package 'WordPressPCL 2.0.0' from 'nuget.org'. Install failed. Rolling back... Package 'WordPressPCL.2.0.0' does not exist in project 'AutomationDashboard' Package 'WordPressPCL.2.0.0' does not exist in folder 'C:\KCMCode\Dashboard\AutomationDashboard\packages' Executing nuget actions took 177.56 ms Install-Package : Could not install package 'WordPressPCL 2.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.8', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. At line:1 char:1

Time Elapsed: 00:00:02.0701742

Short of downloading the entire package and trying to recompile, I am not sure what to do here....any suggestions?

ThomasPe commented 1 year ago

according to the .netstandard compatibility list this should be supported: https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0 Unfortunately I can't provide support for such old frameworks & dev tools, sorry. You could try to install the latest 1.x version of the package, maybe you have more luck with that.

mmacneill123 commented 1 year ago

Thanks Thomas for the reply,

I did get it up and going (I am sure I had sat down to annotate this message!), I had to update the version of NuGet, install an official MS package to support .NET 2 Standard and then it would install. The rather obscure reason for using VS2015 is that this was the last version of VS that did not charge for all the really useful features (the Community and Pro versions were identical), if there is no .NET core stuff in the project, this works well 😊

The package itself has proved very useful but I was unable to work out what DTOs I would need for an ACF based post-type as the docs are very slim on the details there, if there are experts out there, it would be good to connect!

Cheers

From: Thomas Pentenrieder @.> Sent: 23 November 2022 20:09 To: wp-net/WordPressPCL @.> Cc: Michael Macneil @.>; Author @.> Subject: Re: [wp-net/WordPressPCL] Unable to install into VS2015 project targeting .NET Framework 4.8 (Issue #328)

according to the .netstandard compatibility list this should be supported: https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0 Unfortunately I can't provide support for such old frameworks & dev tools, sorry. You could try to install the latest 1.x version of the package, maybe you have more luck with that.

— Reply to this email directly, view it on GitHubhttps://github.com/wp-net/WordPressPCL/issues/328#issuecomment-1325602655, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARDGNWM6XS6EPIRCNIL5TY3WJZ2UVANCNFSM6AAAAAAQRNHVIQ. You are receiving this because you authored the thread.Message ID: @.**@.>>

Kenneth Copeland Ministries is a registered Company in England and Wales. Registered Company No. 01722542 Registered UK Charity No. 326392 Registered Office: 85-87 Locksbrook Road, Lower Weston, Bath, N.E Somerset BA1 3EN Website: www.kcm.org.uk Telephone: +44 (0) 1225 787310 Facsimile: +44 (0) 1225 335983

CONFIDENTIALITY. This e-mail is from Kenneth Copeland Ministries. The contents are confidential and are intended only for the named recipient of this e-mail. If you are not the intended recipient you are notified that any use, reproduction, disclosure or distribution of the information contained in the e-mail is prohibited. If you have received this e-mail in error, please reply to us immediately and delete the document. Although Kenneth Copeland Ministries has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments.

ThomasPe commented 1 year ago

sorry for the late reply, you can see in the tests how accessing contact forms "should" work. https://github.com/wp-net/WordPressPCL/blob/master/WordPressPCL.Tests.Selfhosted/CustomRequests_Tests.cs

I agree we should add this to the docs.

mmacneill123 commented 1 year ago

Thanks Thomas

No problem, I appreciate the insight.

I got it working with the first layer of ACF objects on a page no problem with the library but am wondering how you construct the DTO when you have a page with an ACF object with a repeater and then items within the repeater 😊

I had to take the plan B which was reverse engineering what I saw in the database and using C# to generate the PHP code and defining the meta which holds all the ACF data:

// Create post object $new_post = array( 'post_title' => $post_title, 'post_content' => $broadcast_description, 'post_status' => 'draft', 'post_type' => 'video', 'post_author' => 7567, 'tax_input' => $tax_input, 'meta_input' => array( '_tv_offer' => 'field_59f8588aa820b', 'tv_offer' => $tv_offer, 'study_notes' => $study_notes, '_study_notes' => 'field_59f858dea820c', '_video' => 'field_59f85930a820d', 'video' => '5', 'video_0_vid_day' => $video_0_vid_day, 'video_1_vid_day' => $video_1_vid_day, 'video_2_vid_day' => $video_2_vid_day, 'video_3_vid_day' => $video_3_vid_day, 'video_4_vid_day' => $video_4_vid_day, '_video_0_vid_day' => 'field_59f8594fa820e', '_video_1_vid_day' => 'field_59f8594fa820e', '_video_2_vid_day' => 'field_59f8594fa820e', '_video_3_vid_day' => 'field_59f8594fa820e', '_video_4_vid_day' => 'field_59f8594fa820e', 'video_0_vid_subtitle' => $video_0_vid_subtitle, 'video_1_vid_subtitle' => $video_1_vid_subtitle, 'video_2_vid_subtitle' => $video_2_vid_subtitle, 'video_3_vid_subtitle' => $video_3_vid_subtitle, 'video_4_vid_subtitle' => $video_4_vid_subtitle, '_video_0_vid_subtitle' => 'field_59f8599da8210', '_video_1_vid_subtitle' => 'field_59f8599da8210', '_video_2_vid_subtitle' => 'field_59f8599da8210', '_video_3_vid_subtitle' => 'field_59f8599da8210', '_video_4_vid_subtitle' => 'field_59f8599da8210', 'video_0_vid_id' => $video_0_vid_id, 'video_1_vid_id' => $video_1_vid_id, 'video_2_vid_id' => $video_2_vid_id, 'video_3_vid_id' => $video_3_vid_id, 'video_4_vid_id' => $video_4_vid_id, '_video_0_vid_id' => 'field_59f85980a820f', '_video_1_vid_id' => 'field_59f85980a820f', '_video_2_vid_id' => 'field_59f85980a820f', '_video_3_vid_id' => 'field_59f85980a820f', '_video_4_vid_id' => 'field_59f85980a820f', 'video_0_vid_description' => $video_0_vid_description, 'video_1_vid_description' => $video_1_vid_description, 'video_2_vid_description' => $video_2_vid_description, 'video_3_vid_description' => $video_3_vid_description, 'video_4_vid_description' => $video_4_vid_description, '_video_0_vid_description' => 'field_59f859b2a8211', '_video_1_vid_description' => 'field_59f859b2a8211', '_video_2_vid_description' => 'field_59f859b2a8211', '_video_3_vid_description' => 'field_59f859b2a8211', '_video_4_vid_description' => 'field_59f859b2a8211', '_audio_mp3' => 'field_61e800bd763c0', 'audio_mp3' => array("title" => "","url" => $mp3_audio_link, "target" => "" ), '_translation_disclaimer' => 'field_6272b5993ab41', 'translation_disclaimer' => $translation_disclaimer, '_yoast_wpseo_focuskeywords' => $yoast_wpseo_focuskeywords, '_yoast_wpseo_focuskw' => $yoast_wpseo_focuskw, '_yoast_wpseo_keywordsynonyms' => $yoast_wpseo_keywordsynonyms, '_yoast_wpseo_metadesc' => $yoast_wpseo_metadesc, '_yoast_wpseo_primary_video-speaker' => $yoast_wpseo_primary_video_speaker, '_yoast_wpseo_primary_video-topic' => $yoast_wpseo_primary_video_topic, '_thumbnail_id' => $thumbnail_id ), );

I am still really interested in getting this working with the PCL as it is a cleaner solution, I do not really want to be trying to handcraft JSON posts directly in an HTTP request assuming I could inspect it and work out what was being posted, there is too much to go wrong 😊

Cheers

Michael Macneil

From: Thomas Pentenrieder @.> Sent: 21 December 2022 20:05 To: wp-net/WordPressPCL @.> Cc: Michael Macneil @.>; Author @.> Subject: Re: [wp-net/WordPressPCL] Unable to install into VS2015 project targeting .NET Framework 4.8 (Issue #328)

sorry for the late reply, you can see in the tests how accessing contact forms "should" work. https://github.com/wp-net/WordPressPCL/blob/master/WordPressPCL.Tests.Selfhosted/CustomRequests_Tests.cs

I agree we should add this to the docs.

— Reply to this email directly, view it on GitHubhttps://github.com/wp-net/WordPressPCL/issues/328#issuecomment-1362030762, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARDGNWJBE344NGJ5HY55BP3WONPH7ANCNFSM6AAAAAAQRNHVIQ. You are receiving this because you authored the thread.Message ID: @.**@.>>

Kenneth Copeland Ministries is a registered Company in England and Wales. Registered Company No. 01722542 Registered UK Charity No. 326392 Registered Office: 85-87 Locksbrook Road, Lower Weston, Bath, N.E Somerset BA1 3EN Website: www.kcm.org.uk Telephone: +44 (0) 1225 787310 Facsimile: +44 (0) 1225 335983

CONFIDENTIALITY. This e-mail is from Kenneth Copeland Ministries. The contents are confidential and are intended only for the named recipient of this e-mail. If you are not the intended recipient you are notified that any use, reproduction, disclosure or distribution of the information contained in the e-mail is prohibited. If you have received this e-mail in error, please reply to us immediately and delete the document. Although Kenneth Copeland Ministries has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments.