Skip to content

Mark referenced packages in SDK as implicitly defined #105819

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

Merged
merged 1 commit into from
May 15, 2025

Conversation

hexog
Copy link
Contributor

@hexog hexog commented Apr 27, 2025

Add IsImplicitlyDefined="true" to PackageReference tags in Sdk.targets.

Will fix two problems i had with C# scripting.

1. Prevent Package Manager in Visual Studio from trying to update SDK packages

When viewing installed packages in IDE, Package Manager suggests updating Godot.SourceGenerators, GodotSharp and GodotSharpEditor to the latest version. Looks like this action doesn't do anything, but it can mislead user into thinking they upgraded their environment to the latest version.

Adding IsImplicitlyDefined should prevent IDE from changing versions of these packages.

Screenshots

Before:

vs-packagemanager-bugged

After:

vs-packagemanager-fixed

2. Restore in Godot project fails when Central Package Management enabled

When using CPM with Godot, restore fails with error:

/path/cpm-test/CPM Test.csproj : error NU1008: Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion items: Godot.SourceGenerators;GodotSharp;GodotSharpEditor.

Example repository

With IsImplicitlyDefined="true", NuGet will not try to manage the SDK packages, resolving this error.


This change is backwards compatible and should not break anything in existing projects. However, since IsImplicitlyDefined is not properly documented, I’d appreciate it if someone more knowledgeable in MSBuild could ensure that nothing will break unexpectedly.

What i found about IsImplicitlyDefined:

NuGet/Home#13529
https://github.com/dotnet/sdk/pull/43151/files#r1746148520

@hexog hexog requested a review from a team as a code owner April 27, 2025 11:29
@AThousandShips AThousandShips added this to the 4.x milestone Apr 27, 2025
@raulsntos raulsntos modified the milestones: 4.x, 4.5 May 14, 2025
Copy link
Member

@raulsntos raulsntos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to the .NET module.

I'm not very familiar with this MSBuild property and, as you mention, it seems to be undocumented. However, the provided links about it were very helpful, and it seems harmless.

I tested this in Visual Studio and using the .NET CLI (dotnet list package --outdated) and it seems to works as described, so it looks good to me.

@Repiteo Repiteo merged commit b7c4f23 into godotengine:master May 15, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented May 15, 2025

Thanks! Congratulations on your first merged contribution! 🎉

@hexog hexog deleted the implicit-package-references branch May 16, 2025 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants