Rg.Plugins.Popup
Rg.Plugins.Popup copied to clipboard
Unit Tests Projects won't build on Mac
🐛 Bug Report
I have Xamarin Forms Application with an .net core Test library for my shared project. When I add Rg.Plugins.Popup I'm no longer able to build my test project on MacOS because it tries to load a WPF component which fails on MacOS.
Expected behavior
Unit Test Projects are buildable and Tests can be executed.
Reproduction steps
Start attached reproduction project and try to build / run unit test.
Configuration
Version: 2.0.0.2
Platform:
- [x] :iphone: iOS
- [ ] :robot: Android
- [ ] :checkered_flag: WPF
- [ ] :earth_americas: UWP
- [x] :apple: MacOS
- [ ] :tv: tvOS
- [x] :monkey: Xamarin.Forms
Having this problem too. WPF dependencies won't build on mac systems, which makes this package not buildable for Xamarin Forms. The build chugs along, but this is the task and error that fails:
Target ResolveTargetingPackAssets:
/usr/local/share/dotnet/sdk/3.1.302/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(283,5): error NETSDK1073: The FrameworkReference 'Microsoft.WindowsDesktop.App.WPF' was not recognized
I have stumbled upon the same issue. My test project works fine on Windows, but throws "Error NETSDK1073: The FrameworkReference 'Microsoft.WindowsDesktop.App.WPF' was not recognized (NETSDK1073)" when trying from MAC.
Is there any workaround for this issue?
OK it is a problem with the Rg.Plugins.Pop NuGet package. In its .nuspec it always includes WPF:
<frameworkReferences>
<group targetFramework=".NETCoreApp3.1">
<frameworkReference name="Microsoft.WindowsDesktop.App.WPF" />
</group>
</frameworkReferences>
Since your NUnit test project targets .NET Core app 3.1 it adds that Framework Reference which is not supported on the Mac. source
<PackageReference Include="Rg.Plugins.Popup" Version="2.0.0.3">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
https://stackoverflow.com/a/62341670/1155650
I tried @rohitvipin 's solution in all of the project files that reference Rg.Plugins.Popup.
It did seem to make my projects build but now my test runner in VS is completely mucked up. It won't load even previous versions of the test project. I'm going to try a reboot and hope that works.
@rohitvipin When I tried giving PrivateAssets "all" to the csproj files which reference the plugin, I'm getting compiler error in my test class files which has "using Rg.Plugins.Popup".
The PrivateAssets
tag didn't do anything for me either.
I think I've found the solution for this! The PrivateAssets
tag by itself was not enough in our case. We have a shared .NET Standard library and a .NET Core unit test project, and even with that tag in both projects we couldn't compile the unit tests.
The answer for us seems to be adding the following additional tag to the unit tests:
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
I just put this in the first PropertyGroup
in the unit test csproj
(the one that has things like TargetFramework
)
We just updated our unit test project to 3.1 and encountered the same problem with the Microsoft.WindowsDesktop.App.WPF framework reference that @spottedmahn identified. Thanks to @davidaramant for providing an effective workaround.
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
...
The workaround works for 3.1, but not for 5.0 and 6.0-Preview
To workaround the issue, add this target at the end of the csproj
<Target BeforeTargets="_CheckForTransitiveWindowsDesktopDependencies" Name="RemoveWpf">
<ItemGroup>
<TransitiveFrameworkReference Remove="Microsoft.WindowsDesktop.App.WPF" />
</ItemGroup>
</Target>