The ef6 build targeting net40 failed recently with the following error after updating the .NET SDK to 5.0.100-preview.6.20266.3.
##[error]artifacts\obj\ef6\Release\net40\ef6.AssemblyInfo.cs(21,30): error CS0234: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'AssemblyMetadataAttribute' does not exist in the namespace 'System.Reflection' (are you missing an assembly reference?)
https://github.com/dotnet/ef6/pull/1678
AssemblyMetadataAttribute doesn't exist in net40. ef6 has an AssemblyMetadataAttribute polyfill in some of its projects, but not the one that failed to build. Adding the polyfil works around the issue.
It looks like this is a regression introduced by https://github.com/dotnet/sdk/pull/11559 and could be fixed by not generating a reference to AssemblyMetadataAttribute when targeting net40.
/cc @sfoslund @dsplaisted @wli3
@wli3 @dsplaisted is not defining AssemblyMetadataAttribute a special case with net40 or is this a more common case?
Ping @wli3 @dsplaisted, is AssemblyMetadataAttribute only undefined with net40?
It was introduced in .NET 4.5. So if the TargetFrameworkIdentifier is .NETFramework and the version is less than 4.5, we should not emit this.
FYI @clairernovotny @tmat, looks like we won't get the RepositoryUrl in the assembly metadata for projects targeting .NET 4.0.x or earlier.
@clairernovotny Perhaps we should require packages to have implementation assemblies for netstandard, netcoreapp or net45+ and not validate libraries that target earlier frameworks.
@tmat Not really sure why this matters? What do we need this attribute in the assembly for other than informational use? The thing we actually check is in the PDB.
@clairernovotny We would use this URL to clone the sources when validating reproducibility. The info in the PDB does not include URL that can be cloned. It provides content URL pattern for each file. I guess another approach would be to fall back to downloading each file separately if the clone URL is not available. Less efficient, but perhaps ok as a fall back.
@tmat I guess I assumed that we'd just download each file. There's no guarantee the repo format is Git either, and no need for it to be long as we can download the files via the URL.
@clairernovotny I suspect that will be much slower than clone. But certainly something to try and measure.
Hi @sfoslund ,
We have a project referencing AssemblyMetadataAttribute in generated AssemblyInfo.cs when targeting net40. May I know if there is any workaround if using public preview5? Thanks!
@heng-liu sure, you can set the PublishRepositoryUrl property to false and not set the RepositoryUrl property for now. It should be fixed in the next preview.
Thanks! @sfoslund
@sfoslund What version was this fixed in?
@sharwell It should be in preview 7