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

Prevent AnyCPU builds on .NET Framework #150

Merged
merged 2 commits into from
Mar 1, 2021
Merged

Conversation

Davipb
Copy link
Contributor

@Davipb Davipb commented Jan 11, 2020

As discussed in SFML/SFML.Net#174, the Nuget CSFML package doesn't copy its native files correctly when building with AnyCPU on the .NET Framework.

Given that the .NET Framework is being deprecated soon, this PR adds an MSBuild file to the package that detects when AnyCPU is being used and instructs the user to either switch to .NET Core or change platforms to x86/x64, failing the build.

A property is provided to override this error in case the user wants to copy and load CSFML's files manually at runtime.

Additionally, the deprecated PackageIconUrl property was replaced with PackageIcon pointing to a local PNG.

This should fix #149 and SFML/SFML.Net#174

@Balnian Balnian mentioned this pull request Mar 28, 2020
@eXpl0it3r eXpl0it3r merged commit ea80483 into SFML:master Mar 1, 2021
@eXpl0it3r
Copy link
Member

I'm running into the issue now even for .NET Core (.NET 5 / .NET Standard 2.0) that the error is triggered.
I also don't see any filtering for .NET framework, is that something you forgot in the end or some target magic where that shouldn't be called for .NET Core?

@Davipb
Copy link
Contributor Author

Davipb commented May 10, 2021

The .props files are inside of the net folder, which used to be the Target Framework Moniker for the .NET Framework (while netcoreapp was the TFM for .NET Core), meaning that they would only be loaded while building for the .NET Framework.

But now with the rebranding of .NET Core to just .NET going forward, it seems like they decided to also rename the TFM for .NET Core to just net, meaning it now refers to both the .NET Framework and .NET 5+. This is a really baffling move that I just discovered while researching the cause of this issue and is probably going to break a lot of stuff.

It seems like you can target just the .NET Framework now by using the netframework TFM, but I need to do some experimenting to confirm this. I'll reply back when I know more.

@Davipb Davipb deleted the nuget-anycpu branch May 11, 2021 22:32
@Davipb
Copy link
Contributor Author

Davipb commented May 11, 2021

I can confirm using netframework now works as expected: Errors out on the .NET Framework but not on .NET 5.

@eXpl0it3r
Copy link
Member

Thanks for looking into it. Do you want to send a PR or should I write it?

@Davipb
Copy link
Contributor Author

Davipb commented May 11, 2021

Fastest PR in the west 🤠

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

Successfully merging this pull request may close these issues.

CSFML NuGet Packages
2 participants