You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
XAML code always generates SHA1 checksums in binaries even when csproj file says SHA256 #7348
Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes/No
Unknown
Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? If yes, please file the issue via the instructions here.
No.
Problem description:
I'm compiling C# code with msbuild. The .csproj file has:
ChecksumAlgorithm SHA256 /ChecksumAlgorithm
Running ildasm on the binary, the manifest shows that the hash is still SHA1 via this line:
.hash algorithm 0x00008004
The csc.exe compiler team (Tomas Matousek) has also confirmed that SHA1 is being used for the XAML c# code.
This bug does not repro on projects without XAML.
I'm also a Microsoft FTE so you can contact me directly if you need anything MS-internal.
Actual behavior:
Binary checksum is SHA1.
Expected behavior:
Binary checksum should be SHA256 as requested by .csproj file.
Minimal repro:
The attached repro includes the entire project folder post-build. It thus includes the full -bl ".binlog" file, the source code including auto-generated XAML source, and the final DLL and symbols. The only thing it excludes are the dependency dlls that were not compiled by my project but were instead auto-added by the build, e.g. api-ms-win-core..., PresentationFramework..., etc. (Removing these was required to bring the zip file down to below 25 MB.)
changed the title [-]XAML code always generates SHA1 hashed binaries even when csproj file says SHA256[/-][+]XAML code always generates SHA1 checksums in binaries even when csproj file says SHA256[/+]on Dec 7, 2022
@singhashish-wpf - Is there a timeline on which someone will look at this? Our customers are demanding SHA256 checksums and we can't fulfill their request because of this bug.
@swenkeratmicrosoft Thanks for the issue. I did check the binlog you provided. The csc task is receiving the value for checksumalgorithm correctly as SHA256 and there also isn't any deviation to SHA1. @tmat Can you provide more details in here like do we need to modify at some place before calling the csc task with the proper parameter value for checksumalgorithm?
I have local changes to change the "#pragma checksum" in the generated code according to the current ChecksumAlgorithm of the project.
But I'm not able to reproduce how the manifest should look like (Line .hash algorithm 0x00008004 should change) in a non-WPF project. If I create a new C# Console project, add <ChecksumAlgorithm>SHA256</ChecksumAlgorithm> to the .csproj, build the project and ildasm the output assembly, the line .hash algorithm 0x00008004 never changes. @tmat Do you have some pointers on what I should do to be able to see the line .hash algorithm 0x00008004 change ?
You can ignore the value of .hash algorithm. It specifies a different hash, which is always SHA1. See ECMA-335 specification, paragraph II.6.2.1.1.
The source document hash algorithm that #pragma checksum specifies is written to the PDB. You can use a tool like pdb2xml to display the content of the PDB file.
Activity
[-]XAML code always generates SHA1 hashed binaries even when csproj file says SHA256[/-][+]XAML code always generates SHA1 checksums in binaries even when csproj file says SHA256[/+]swenkeratmicrosoft commentedon Feb 7, 2023
@singhashish-wpf - Is there a timeline on which someone will look at this? Our customers are demanding SHA256 checksums and we can't fulfill their request because of this bug.
singhashish-wpf commentedon Feb 15, 2023
@swenkeratmicrosoft Thanks for the issue. I did check the binlog you provided. The csc task is receiving the value for checksumalgorithm correctly as SHA256 and there also isn't any deviation to SHA1.
@tmat Can you provide more details in here like do we need to modify at some place before calling the csc task with the proper parameter value for checksumalgorithm?
tmat commentedon Feb 15, 2023
The SHA1 hash is written to the generated file
obj\Release\net6.0-windows\win-x64\MainWindow.g.csby XAML compiler:ThomasGoulet73 commentedon Feb 16, 2023
I have local changes to change the "#pragma checksum" in the generated code according to the current
ChecksumAlgorithmof the project.But I'm not able to reproduce how the manifest should look like (Line
.hash algorithm 0x00008004should change) in a non-WPF project. If I create a new C# Console project, add<ChecksumAlgorithm>SHA256</ChecksumAlgorithm>to the .csproj, build the project and ildasm the output assembly, the line.hash algorithm 0x00008004never changes.@tmat Do you have some pointers on what I should do to be able to see the line
.hash algorithm 0x00008004change ?swenkeratmicrosoft commentedon Feb 16, 2023
In case it helps, you should first confirm that the .csproj file is using the following XML. If it is, I defer to @tmat.
(Edited several times because I forgot how to insert a code block inn a github comment.)
<Project ...> ... <PropertyGroup Label="Configuration"> <ChecksumAlgorithm>SHA256</ChecksumAlgorithm> </PropertyGroup> ... </Project>tmat commentedon Feb 16, 2023
You can ignore the value of
.hash algorithm. It specifies a different hash, which is always SHA1. See ECMA-335 specification, paragraph II.6.2.1.1.The source document hash algorithm that
#pragma checksumspecifies is written to the PDB. You can use a tool likepdb2xmlto display the content of the PDB file.Use project ChecksumAlgorithm in code-behind.
Use project ChecksumAlgorithm in code-behind. (#7556)