dotnet / maintenance-packages

Repository that hosts packages from the .NET platform whose original home/branch is not building any longer.
MIT License
16 stars 10 forks source link

Migrate Microsoft.IO.Redist #110

Closed carlossanlop closed 1 month ago

carlossanlop commented 2 months ago

Migrated from 6.0.

The Microsoft.IO.Redist nuget package has the following information:

When consuming this nuget package in a console app, then printing typeof( Microsoft.IO.Directory).Assembly.CodeBase I confirmed that:

However, the csproj in the release/6.0 branch only targets net472, and also the nuget package only contains a net472/ folder: https://github.com/dotnet/runtime/blob/6bc4d4a68b944fa6643203efb5a6c5e8eccc8522/src/libraries/Microsoft.IO.Redist/src/Microsoft.IO.Redist.csproj#L12

Question: Are these differences in the ILSpy information expected?:

BeforeAfter
```cs // C:\Before\Microsoft.IO.Redist.dll // Microsoft.IO.Redist, Version=6.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 // Global type: // Architecture: AnyCPU (64-bit preferred) // Runtime: v4.0.30319 // This assembly is signed with a strong name key. // This assembly was compiled using the /deterministic option. // Hash algorithm: SHA1 // Public key: using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: DefaultDllImportSearchPaths(/*Could not decode attribute arguments.*/)] [assembly: AssemblyDefaultAlias("Microsoft.IO.Redist")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyMetadata("PreferInbox", "True")] [assembly: AssemblyMetadata("IsTrimmable", "True")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyDescription("Downlevel support package for System.IO classes.")] [assembly: AssemblyFileVersion("6.0.3224.31407")] [assembly: AssemblyInformationalVersion("6.0.32+e77011b31a3e5c47d931248a64b47f9b2d47853d")] [assembly: AssemblyProduct("Microsoft® .NET")] [assembly: AssemblyTitle("Microsoft.IO.Redist")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/dotnet/runtime")] [assembly: SecurityPermission(8, SkipVerification = true)] [assembly: AssemblyVersion("6.0.0.1")] [module: UnverifiableCode] [module: NullablePublicOnly(false)] ``` ```cs // C:\After\Microsoft.IO.Redist.dll // Microsoft.IO.Redist, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 // Global type: // Architecture: AnyCPU (64-bit preferred) // Runtime: v4.0.30319 // This assembly is signed with a strong name key. // This assembly was compiled using the /deterministic option. // Hash algorithm: SHA1 // Public key: using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyFileVersion("6.100.24.42801")] [assembly: AssemblyInformationalVersion("6.1.0-ci.24428.1+b6d717d6e9ffd2beb0345fd3a0227be370a5e698")] [assembly: AssemblyProduct("Microsoft® .NET")] [assembly: AssemblyTitle("Microsoft.IO.Redist")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/carlossanlop/maintenance-packages")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(8, SkipVerification = true)] [assembly: AssemblyVersion("6.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] ```
ericstj commented 1 month ago

When consuming this nuget package in a console app, then printing typeof( Microsoft.IO.Directory).Assembly.CodeBase I confirmed that: ... When targeting .NET 6.0, this assembly is used: bin/Debug/net6.0/Microsoft.IO.Redist.dll ... However, the csproj in the release/6.0 branch only targets net472, and also the nuget package only contains a net472/ folder

Correct, you'll likely notice a warning in that net6.0 project like:

warning NU1701: Package 'Microsoft.IO.Redist 6.0.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project.

Are these differences in the ILSpy information expected?:

It looks to me like some common attribute settings might be missing from maintenance-packages. The ones here that look worth following up on are AssemblyDefaultAlias, AssemblyMetadata, and DefaultDllImportSearchPathsAttribute. Looks like a lot of those come from https://github.com/dotnet/runtime/blob/release/8.0/eng/versioning.targets. You might want to handle that as a separate PR.

carlossanlop commented 1 month ago

It looks to me like some common attribute settings might be missing from maintenance-packages. The ones here that look worth following up on are AssemblyDefaultAlias, AssemblyMetadata, and DefaultDllImportSearchPathsAttribute. Looks like a lot of those come from https://github.com/dotnet/runtime/blob/release/8.0/eng/versioning.targets. You might want to handle that as a separate PR.

Got it! Will take care of that separately. Thanks.

carlossanlop commented 1 month ago

Need to fix the following api compat error now:

C:\.tools\.nuget\packages\microsoft.dotnet.apicompat.task\9.0.100-preview.2.24102.10\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): 

error : API compatibility errors between 'lib/net472/Microsoft.IO.Redist.dll' (C:\.tools\.nuget\packages\microsoft.io.redist\6.0.1\microsoft.io.redist.6.0.1.nupkg) and 'lib/net472/Microsoft.IO.Redist.dll' 
error CP0003: [Baseline] lib/net472/Microsoft.IO.Redist.dll assembly public key token 'cc7b13ffcd2ddd51' does not match with lib/net472/Microsoft.IO.Redist.dll '31bf3856ad364e35'.
error : API breaking changes found. If those are intentional, the APICompat suppression file can be updated by rebuilding with '/p:ApiCompatGenerateSuppressionFile=true'

We fixed this in Microsoft.Bcl.HashCode by adding <StrongNameKeyId>Open</StrongNameKeyId>.