-
Notifications
You must be signed in to change notification settings - Fork 471
[Bug] Unit Test projects now reference Xamarin.Forms.Platform.WPF #985
Comments
Hey @cabal95 that is definitely not behavior I would want to force upon anyone. We need to check our dependencies here. Thanks for letting us know! |
Similar issue here. Build error in my Unit Tests project with TargetFramework netcoreapp3.1.
This workaround worked for me: |
I have this same issue in any project referencing XCT on Mac. It just won't compile due to the |
@akamud what version of XCT are you running? The |
Yes, the build fails on my unit test projects and my Xamarin.Forms project referencing XCT. |
WorkaroundThe current workaround is to add the following line to the Unit Test CSPROJ file: <GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks> Here an example of I implement this workaround in my app GitTrends: |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@brminnick Just to be clear, the original issue I posted about ONLY happens if Xamarin Community Toolkit is linked in. If I remove XCT but leave Xam5 in then the warning goes away. |
Apologies, @cabal95 - you are absolutely correct! This is caused by I was 100% mistaken. It turns out I'll hide my earlier comment to avoid any confusion 👍 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Please fix this. I run into the same issue. Workaround |
The workaround with Project.Tests.csproj:
But you should check the status of this issue and remove the workaround as soon as possible (or update the package manually, whenever XCT does). |
Has there been an update to this? The workaround everyone has mentioned doesn't work for me. |
@mgramley Ensure your Unit Test project is targeting .NET Core 3.1 and that the Unit Test CSPROJ includes We do not have a known way to fix this without removing Xamarin Community Toolkit support for WPF. We are open to pull requests. |
I already had the GenerateErrorForMissingTargetingPacks flag in my project, it did not resolve the issue for me. For now, since I only need a single view from the toolkit I will pul the latest source files into my project. |
@brminnick |
Its nice we have a workaround but this doesn't work for .net5.0 projects and thinking about .net6.0 compatibility when we eventually migrate XF projects to MAUI I'd rather be using a newer .net version than |
@jfversluis did you check with the repository owners how they want to untangle the dependency to Xamarin.Forms.Platform.WPF? From my point of view, such a dependency should never have been added. As for now since we move our test projects to net6.0, we had to get rid of XamarinCommunityToolkit. Let me know if we can use it again. |
Any update on this? Sad that we havev to run tests on netcoreapp 3.1. Especially now as net5.0-windows is officially removed from azure images, which forces us to run under netcoreapp 3.1 in Azure Devops. |
We're in the same situation as @haavamoa 😫 |
Had to remove the community toolkit due to this issue :'( |
I was running into this issue with my <Target BeforeTargets="_CheckForTransitiveWindowsDesktopDependencies" Name="_FixStupidSdkError_NETSDK1136">
<ItemGroup>
<TransitiveFrameworkReference Remove="Microsoft.WindowsDesktop.App" />
<TransitiveFrameworkReference Remove="Microsoft.WindowsDesktop.App.WPF" />
<TransitiveFrameworkReference Remove="Microsoft.WindowsDesktop.App.WindowsForms" />
</ItemGroup>
</Target> It's obviously not ideal if you actually develop for these platforms but that wasn't a problem in my case. I originally tried something like this to force the use of a different target framework without the WPF dependency but it appears the aforementioned target still runs regardless of the |
Ty @gtbuchanan finally a workaround that fixes it. It was really a pain ! |
Description
I'm not sure if this is a bug per-se, but I couldn't find any previous discussion of it so thought I would mention it as it doesn't "feel right". For our Xamarin Forms project, we have some unit tests that verify some of the business logic works and doesn't break between various upgrades. These are not UI tests. Just a standard netcoreapp3.1 project type for unit testing.
Today I installed Xamarin Community Toolkit and noticed the following warnings appeared:
My tests still execute and work fine, but it doesn't seem right that my unit tests project would now be forced to reference a platform lib. I downloaded the latest code from here and verified that the unit test project here does the same.
Is this actually a bug or something we have to live with due to no other way to differentiate WPF from a "generic non-platform" project?
Steps to Reproduce
Expected Behavior
No reference to a platform I'm not using and is not valid for unit testing.
Actual Behavior
Xamarin.Forms.Platform.WPF gets added as a dependency of my Unit Tests project, which chains to the OpenTK package as well.
Basic Information
Workaround
None so far.
Reproduction imagery
Reproduction Link
Let me know if I need to add one, since the unit tests in XCF exhibit the same behavior.
The text was updated successfully, but these errors were encountered: