Skip to content

build: fix Visual Studio build #4300

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 2 commits into from
Jun 24, 2025
Merged

build: fix Visual Studio build #4300

merged 2 commits into from
Jun 24, 2025

Conversation

jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Jun 22, 2025

System.Runtime.InteropServices.RuntimeInformation::RuntimeIdentifier is only available in .NET 5.0 and later. While dotnet build on the command line works, building Sentry from within Visual Studio throws such errors:

Sentry.Native.targets(37,14): error MSB4186: Invalid static method invocation syntax:
  "[System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier".
  Method 'System.Runtime.InteropServices.RuntimeInformation.RuntimeIdentifier' not found.
  Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)).
  Check that all parameters are defined, are of the correct type, and are specified in the right order.

TODO: Is $(NETCoreSdkRuntimeIdentifier) guaranteed to be set on all supported platforms and configurations, or do we need some manual fallback resolution based on the host OS and arch?

See also:

#skip-changelog

jpnurmi added 2 commits June 22, 2025 17:08
> Sentry.Native.targets(37,14): error MSB4186: Invalid static method invocation syntax:
> "[System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier".
> Method 'System.Runtime.InteropServices.RuntimeInformation.RuntimeIdentifier' not found.
> Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)).
> Check that all parameters are defined, are of the correct type, and are specified in the right order.
@Flash0ver
Copy link
Member

Thanks @jpnurmi for looking into this ... I'm facing this issue on my Windows-machine right now.

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Jun 22, 2025

@Flash0ver Did you experiment with MSBuild in some branch for the other build problem you investigated earlier? Was it something like this you had in mind?

@Flash0ver
Copy link
Member

Flash0ver commented Jun 22, 2025

@jpnurmi ... no ... IIRC ... this is something different ... but I may misunderstand something here

  • this PR fixes the build of the sentry-dotnet source from Visual Studio and the non-.NET-SDK MSBuild
  • test(ci): Visual Studio MSBuild on Windows #4299 refers to issues of building projects consuming a Sentry-Package via Visual Studio and the non-.NET-SDK MSBuild

I have just recently started experimenting with either scenario of building with Visual Studio / the non-.NET-SDK MSBuild.

Locally only.
I created no branch so far.

I tried

-<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)' == 'win-x64'">
+<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$(NETCoreSdkRuntimeIdentifier)' == 'win-x64'">

with the latest stable Visual Studio ... which seems to fix the build issue.
But I haven't checked yet, whether all Native features still work as expected.

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Jun 22, 2025

I got the same error while experimenting with WinUI (#4297) and tried adding Sentry as a project reference for prototyping purposes. Makes me wonder if this change should be marked as a fix instead because it impacts those who might be using Sentry as a project reference. Not sure how common it is to do that outside the Sentry project tree, though.

@Flash0ver
Copy link
Member

I don't think it's of type fix:, as I don't have the feeling this warrants a CHANGELOG entry.
Not sure if build: would be applicable here. But also not quite a chore:.
Hmm ... I'm uncertain ... I guess either of these is fine.

@jpnurmi jpnurmi changed the title chore: fix Visual Studio build build: fix Visual Studio build Jun 22, 2025
@jpnurmi jpnurmi marked this pull request as ready for review June 22, 2025 20:13
@jpnurmi jpnurmi merged commit cb61400 into main Jun 24, 2025
32 checks passed
@jpnurmi jpnurmi deleted the fix/vs-host-rid branch June 24, 2025 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants