Baseflow / LottieXamarin

Render After Effects animations natively on Android, iOS, MacOS and TvOS for Xamarin
https://baseflow.com
Apache License 2.0
1.22k stars 261 forks source link

Compilation error in Unit Test project on Mac when using Lottie 4.0.x version #294

Open Sergiu-Cosmin opened 3 years ago

Sergiu-Cosmin commented 3 years ago

🐛 Bug Report

We are currently developing an application in Xamarin Forms on MAC using Visual Studio for Mac and use the lottie animation in a .NET Standard 2.1 common project, to unit test this common project we have a separate project targeting .NET Core 3.1. Everything was ok until we updated from Lottie 3.1.0 to Lottie 4.0.4 and also tried 4.0.6. After the update we have build errors on the unit test project:

/usr/local/share/dotnet/sdk/3.1.402/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(5,5): Error NETSDK1073: The FrameworkReference 'Microsoft.WindowsDesktop.App.WPF' was not recognized (NETSDK1073) (CommonProject.Tests) /usr/local/share/dotnet/sdk/3.1.402/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(5,5): Error NETSDK1073: The FrameworkReference 'Microsoft.WindowsDesktop.App.WindowsForms' was not recognized (NETSDK1073) (CommonProject.Tests)

Expected behavior

No errors when building

Reproduction steps

Create a Xamarin.Forms Shell Project Add Lottie 4.0.6 to the .NET Standard 2.1 common project Create a NUnit test project with type .NET Core 3.1 Add .NET Standard 2.1 common project as reference to the NET Core 3.1 project Try to build the test project

Configuration

You can check the project below for a faster view of the configuration and problem TestLottie.zip

Version: 4.0.6

Platform:

martijn00 commented 3 years ago

Not sure this is an issue. Since Lottie 4.x it targets WPF on .NET and .NET core as well. That's why it is imported.

Sergiu-Cosmin commented 3 years ago

@martijn00 so then is there a way to fix this ? did you test the TestLottie.zip on a mac ? we cannot run any unit tests locally anymore because of this issue, our CI/CD pipelines fail as well :(

mauro-dasilva commented 3 years ago

@Sergiu-Cosmin I take it your Unit Test Project is referencing the Main Project. If that is the case, then in the Main Project, open up the .csproj file and mark the Lottie NuGet package as a private asset. In that way it wont be imported when running the unit tests. That worked for us. IE.

`

all
</PackageReference>`
Sergiu-Cosmin commented 3 years ago

@mauro-dasilva thank you for the advice, that is what we did but that leads to other problems, if we make it a a private asset we cannot use it as a reference in other projects anymore

our app has a separate module where all our ui components are stored, which uses also lottie for animations this is constructed as a nuget package that we use in out main app, but our main app also needs to use lottie for other animations which are not in the UI Components, so we use the reference from the UI Components module so we don't have to keep them in sync (UI Components and main app Lottie nugets) what we actually use is a little bit more complex with more modules but the explanation above describes it pretty well, now the problem is that if we set it to PrivateAssets we lose the ability to take the reference from the UI Components nuget and we have to add the Lottie nuget everywhere we need it

ChristopherStephan commented 3 years ago

This can be resolved by adding the following to the PropertyGroup in the .csproj file:

<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>