-
Notifications
You must be signed in to change notification settings - Fork 64
Add SBRP attribute #794
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
Add SBRP attribute #794
Conversation
7bfcda9
to
88b8727
Compare
The duplication error from AzDo is not appearing locally. https://dev.azure.com/dnceng-public/public/_build/results?buildId=425057&view=logs&j=2f0d093c-1064-5c86-fc5b-b7b1eca8e66a&t=d2b639a6-cb19-5f1f-66fd-8047f66b3026&l=102 |
src/referencePackages/src/humanizer.core/2.2.0/lib/netstandard1.0/Humanizer.cs
Outdated
Show resolved
Hide resolved
src/packageSourceGenerator/PackageSourceGeneratorTask/AddSbrpAttribute.cs
Outdated
Show resolved
Hide resolved
src/packageSourceGenerator/PackageSourceGeneratorTask/AddSbrpAttribute.cs
Outdated
Show resolved
Hide resolved
src/packageSourceGenerator/PackageSourceGeneratorTask/AddSbrpAttribute.cs
Outdated
Show resolved
Hide resolved
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.
I'm not sure why we need to add this item to the generated compile source. Why can't we just define that attribute in a separate C# file and pass it to the compiler? Doing that will avoid these 600+ file changes and keep the logic contained in a single place.
EDIT: Even better, just add this this attribute via an msbuild item here: https://github.com/dotnet/source-build-reference-packages/blob/main/src/referencePackages/Directory.Build.props
<AssemblyAttribute Include="System.Reflection.AssemblyMetadata">
<_Parameter1>source</_Parameter1>
<_Parameter2>source-build-reference-packages</_Parameter2>
</AssemblyAttribute>
src/packageSourceGenerator/PackageSourceGeneratorTask/AddAttributes.cs
Outdated
Show resolved
Hide resolved
2eb25d1
to
dc62e8b
Compare
523c09d
to
b0d320b
Compare
After testing the proposed implementation change, I found that the rebuilt assemblies did not include the attribute. To investigate this, I created a "dummy" dotnet app with the same code to inject the attribute and found that the attribute was added to the assemblies as intended, indicating that the proposed changes do inject the attribute as intended, but something in the build of SBRP was causing the attribute to not appear. I discovered that this issue is the result of setting GenerateAssemblyInfo to false. As described in this issue, when GenerateAssemblyInfo is false, the project file and the project properties become out of sync. I tested this with my "dummy" dotnet app by setting "GenerateAssemblyInfo" to false and verified that the attribute does not appear in the built assembly. However, setting GenerateAssemblyInfo to true in SBRP caused a myriad of issues, including complaints about duplicate attributes. I have two proposed changes to address this issue:
|
@ellahathaway - Nice discovery and analysis of what is happening.
|
We don't want to generate an AssemblyInfo.cs file as GenAPI already emits all the assembly metadata into the compiled source. I think a better solution would be to just generate that C# code ourselves (basically what the |
I didn't know if there would be enough knobs as to only generate the AssemblyMetadataAttribute. |
I think this is a good approach. I'll work on adding this. Edit: Implemented this change as part of 2347c49 |
I assume you verified that the assembly attribute is now present? Should we add a test for it (post-merge)? |
Testing of this attribute was already tracked in dotnet/source-build#2804 which will be one of the next items Ella will be working on. |
src/packageSourceGenerator/PackageSourceGeneratorTask/AddAttributes.cs
Outdated
Show resolved
Hide resolved
src/packageSourceGenerator/PackageSourceGeneratorTask/AddAttributes.cs
Outdated
Show resolved
Hide resolved
[assembly: AssemblyInformationalVersion("6.0.21.52210 built by: SOURCEBUILD")] | ||
[assembly: CLSCompliant(true)] | ||
[assembly: AssemblyMetadata("", "")] |
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.
How did these did here in the first place? Was it via automation or were they manually added?
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 were previously generating these attributes prior to the refactoring to use GenAPI. These are the few packages that have not been regenerated with the new tooling - tracked with dotnet/source-build#3459
I did check to verify that the assembly attribute is now present! |
/backport to release/8.0 |
Started backporting to release/8.0: https://github.com/dotnet/source-build-reference-packages/actions/runs/6536826626 |
Fixes dotnet/source-build#3639
This PR adds the following attribute to assemblies originating from SBRP:
[assembly: AssemblyInformationalVersion("<version> originated from source-build-reference-packages")]
. This PR also includes logic to add this attribute as part of packageSourceGenerator.