Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Annoying warning on .NET Framework 4.8 project with SkiaSharp 2.88.6 or 2.88.7 #2824

Closed
1 task done
rozeboosje opened this issue Apr 8, 2024 · 17 comments
Closed
1 task done
Labels

Comments

@rozeboosje
Copy link

Description

Created a WPF project targeting .NET Framework 4.8 with no additional code, only nuget references to SkiaSharp 2.88.6 and also when upgrading this to 2.88.7

At first this builds without any errors but if you then save the project and reopen it later the following warning starts appearing in the Error List:

Severity Code Description Project File Line Suppression State Details
Warning The referenced component 'C:\Users[*****]\packages\SkiaSharp.NativeAssets.macOS.2.88.7\build\net462....\runtimes\osx\native\libSkiaSharp.dylib' could not be found. Foo

Can something be done about this, please?

Additional information: Version 2.88.7 of SkiaSharp is presented as "Latest stable" in nuget. Also, we don't even use SkiaSharp ourselves; this is included in our project after installing a 3rd party nuget package which depends on SkiaSharp 2.88.6 ... However, even after removing the 3rd party software and leaving only SkiaSharp and its dependencies, the warning persists.

Code

The best way to share code for larger projects is a link to a GitHub repository: https://github.com/user/repo/tree/bug-123

But, you can also share a short block of code here:

// some C# code here

You can also share some XAML:

<!-- xaml code here -->

Expected Behavior

Project should simply build without any warnings.

Actual Behavior

Warning is shown.

Version of SkiaSharp

2.88.3 (Current)

Last Known Good Version of SkiaSharp

2.88.2 (Previous)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

Windows

Devices

Laptop

Relevant Screenshots

image

Relevant Log Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@lbras
Copy link

lbras commented Apr 12, 2024

I get this as well. It has been around for a while #2223. Using VS2019 16.11.35.

@rozeboosje
Copy link
Author

It's, at the very least, annoying. But it also leaves me wondering what I need to distribute in order to ensure that the software works without issues.

Please address this.

@rozeboosje
Copy link
Author

Any chance of a response from the Team? Even merely an acknowledgement that the issue has been noted and understood?

@rozeboosje
Copy link
Author

Issue still persists in the nuget packages for skiasharp 2.88.8

@mattleibow
Copy link
Contributor

This is the code that is importing the native reference:

https://github.com/mono/SkiaSharp/blob/release/2.x/binding/SkiaSharp/nuget/build/net462/SkiaSharp.targets#L11-L16

It has a condition that is not ever true on Windows, VS for Windows or WPF. Yet somehow the IDE is seeing it.

It does seem to only happen in the classic projects, so a workaround may be to upgrade to the SDK-style projects.

@rozeboosje
Copy link
Author

Sorry can you explain what you mean by "classic" and "SDK-style" projects?

We are using a product called Aspose.Words in a Solution with 84 projects in it. That product has now been changed to include references to SkiaSharp and that's how the nuget packages for SkiaSharp ended up pulled into our Solution. I am not sure that we can justify the amount of work involved in the workaround...

@mattleibow
Copy link
Contributor

This appears to be a IDE warning, and not a compile warning. So the IDE is doing this all on its own and we have no way to control it. It should not be happening as there is a condition around it that is false. Looking at a binlog, this warning does not exist - and it does not have a code either so we cannot ignore or even do anything.

@mattleibow
Copy link
Contributor

mattleibow commented Apr 24, 2024

SDK style projects are the new way to write csproj: https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview

For example, a File | New project will look like this:

<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<OutputType>WinExe</OutputType>
		<TargetFramework>net48</TargetFramework>
		<UseWPF>true</UseWPF>
	</PropertyGroup>

</Project>

All the clutter has been removed.

@mattleibow
Copy link
Contributor

You can also easily update from the old projects to the new project with the .net upgrade assistant: https://dotnet.microsoft.com/en-us/platform/upgrade-assistant

This will not actually upgrade anything with your app, just the csproj format.

Running a test now to confirm...

@rozeboosje
Copy link
Author

rozeboosje commented Apr 24, 2024

Okay but this is a years old solution and we're stuck in .NET Framework 4.8 world so a move to .NET Core is not going to happen any time soon.

I had a look at the code you posted, though ... and I think I can see what the problem is.

<ShouldIncludeNativeSkiaSharp Condition=" '$(ShouldIncludeNativeSkiaSharp)' == '' ">True</ShouldIncludeNativeSkiaSharp>

So there is a condition under which the value is set to True, but there is no condition under which the value is set to False, so as far as I can tell from the code snippet, the value could be anything: '', 'george', 'something' or even null.

Similarly, the _AppIsFullMac value is set on the basis of various values != to some values, and again, I bet those values are not the "opposites" you're expecting them to be.

@mattleibow
Copy link
Contributor

The condition is working as the second part ``'$(_AppIsFullMac)' == 'True' is false. When running a build, there is no warning and there is also all the cases where the checks are running and there are no native references:

image

Also, switching to SDK-style projects does not mean switching to .net core, you can just convert the xml to the modern format, and keep the same net46/net47/net48 that you already have - and you can mix it up as well.

But again, this is not a build issue - just the IDE/solution explorer bug.

@rozeboosje
Copy link
Author

Okay but it pollutes our "Error list" with spurious warnings. We are not in the habit of ignoring warnings as we've been bitten a few times before when an ignored warning led to an actual problem. With all these warnings cluttering the Error List we're risking missing one that DOES require our attention. If it's an IDE bug, where can I report that and ask the makers of Visual Studio to address it?

@mattleibow
Copy link
Contributor

I even wrapped the whole <NativeReference> item in a <ItemGroup Condition=" 'cat' == 'dog' "> and the IDE still sees it.

You can use the VS feedback in the help menu or the
image

I will try replicate this in a simple project for you to add a code snippet.

@mattleibow
Copy link
Contributor

Managed to reproduce this with the simplest thing:

<ItemGroup Condition=" 'dog' == 'cat' ">
  <NativeReference Include="BadFile.dylib" />
</ItemGroup>

Add that near the end of your csproj and the warning will appear. The condition directly excludes this, yet it is still there in the IDE.

@mattleibow
Copy link
Contributor

I think I found a hack to fix it:

<ItemGroup Condition=" 'dog' == 'cat' ">
  <NativeReference Include="BadFile.dylib" />
</ItemGroup>
<ItemGroup Condition=" 'dog' != 'cat' ">
  <NativeReference Remove="BadFile.dylib" />
</ItemGroup>

This is all sorts of wrong, but the IDE seems happier.

@mattleibow
Copy link
Contributor

Let's see.

@rozeboosje
Copy link
Author

Thank you so much for putting effort into this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants