-
-
Notifications
You must be signed in to change notification settings - Fork 220
build: Fix reference to Sentry.SourceGenerators #4307
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
base: main
Are you sure you want to change the base?
Conversation
@sentry review |
On it! We are reviewing the PR and will provide feedback shortly. |
PR DescriptionThis pull request aims to improve the packaging of the Sentry.SourceGenerators project as a Roslyn analyzer within the main Sentry NuGet package. The goal is to ensure that the source generators are correctly included and function as expected during the build process of projects that consume the Sentry SDK. Click to see moreKey Technical ChangesThe primary technical change is the replacement of a direct file inclusion (of the compiled Sentry.SourceGenerators.dll) with an MSBuild target-based approach. This involves using a Architecture DecisionsThe architectural decision is to leverage MSBuild's extensibility to dynamically build and package the analyzer. This approach avoids hardcoding file paths and ensures that the analyzer is always built with the correct configuration for the target environment. This also allows for better control over the build process and potential customization in the future. Dependencies and InteractionsThis change introduces a dependency on the MSBuild system to correctly build and package the analyzer. It interacts with the NuGet packaging process by adding the analyzer assembly to the appropriate directory within the package. It depends on the Sentry.SourceGenerators project being buildable and producing a valid analyzer assembly. Risk ConsiderationsPotential risks include issues with the MSBuild target not correctly building or packaging the analyzer, leading to projects consuming the Sentry SDK not benefiting from the source generators. There's also a risk that changes to the Sentry.SourceGenerators project could break the build process if the MSBuild target is not updated accordingly. The Notable Implementation DetailsThe |
src/Sentry/Sentry.csproj
Outdated
Pack="true" | ||
PackagePath="analyzers/dotnet/cs" | ||
Visible="false" /> | ||
<ProjectReference Include="..\Sentry.SourceGenerators\Sentry.SourceGenerators.csproj" OutputItemType="" ReferenceOutputAssembly="false" PrivateAssets="all" SetTargetFramework="TargetFramework=netstandard2.0" SentryAnalyzersPack="true" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: parallel builds
Workflows sometimes run into:
/Users/runner/.dotnet/sdk/9.0.301/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(323,5): error MSB4018: System.IO.IOException: The process cannot access the file '/Users/runner/work/sentry-dotnet/sentry-dotnet/src/Sentry.SourceGenerators/bin/Release/netstandard2.0/Sentry.SourceGenerators.deps.json' because it is being used by another process. [/Users/runner/work/sentry-dotnet/sentry-dotnet/src/Sentry.SourceGenerators/Sentry.SourceGenerators.csproj]
@@ -206,11 +206,12 @@ | |||
<!-- See https://learn.microsoft.com/dotnet/core/project-sdk/overview --> | |||
<!-- See also https://github.com/ViktorHofer/PackAsAnalyzer --> | |||
<ItemGroup> | |||
<ProjectReference Include="..\Sentry.SourceGenerators\Sentry.SourceGenerators.csproj" OutputItemType="" ReferenceOutputAssembly="false" PrivateAssets="all" SetTargetFramework="TargetFramework=netstandard2.0" SentryAnalyzersPack="true" /> | |||
<SentryAnalyzerProjectReference Include="..\Sentry.SourceGenerators\Sentry.SourceGenerators.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've got this in various other places throughout the solution. I'm wondering if it should be in one or more of the Directory.Build.props files (e.g. the one in the Samples directory, at the very least).
sentry-dotnet/test/Sentry.SourceGenerators.Tests/Sentry.SourceGenerators.Tests.csproj
Line 17 in 0514bfe
<ProjectReference Include="..\..\src\Sentry.SourceGenerators\Sentry.SourceGenerators.csproj"/> |
sentry-dotnet/samples/Sentry.Samples.Android/Sentry.Samples.Android.csproj
Lines 15 to 17 in 0514bfe
<ProjectReference Include="..\..\src\Sentry.SourceGenerators\Sentry.SourceGenerators.csproj" | |
OutputItemType="Analyzer" | |
ReferenceOutputAssembly="false"/> |
sentry-dotnet/samples/Sentry.Samples.Ios/Sentry.Samples.Ios.csproj
Lines 47 to 49 in 0514bfe
<ProjectReference Include="..\..\src\Sentry.SourceGenerators\Sentry.SourceGenerators.csproj" | |
OutputItemType="Analyzer" | |
ReferenceOutputAssembly="false"/> |
sentry-dotnet/samples/Sentry.Samples.MacCatalyst/Sentry.Samples.MacCatalyst.csproj
Lines 47 to 49 in 0514bfe
<ProjectReference Include="..\..\src\Sentry.SourceGenerators\Sentry.SourceGenerators.csproj" | |
OutputItemType="Analyzer" | |
ReferenceOutputAssembly="false"/> |
supersedes #4290
before:
error : Could not find a part of the path './sentry-dotnet/src/Sentry.SourceGenerators/bin/Release/netstandard2.0'
after:
Build succeeded
#skip-changelog