Skip to content
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

Reproducible builds with Razor Class Library in .NET 6 RC1 #37182

Closed
meziantou opened this issue Oct 1, 2021 · 10 comments
Closed

Reproducible builds with Razor Class Library in .NET 6 RC1 #37182

meziantou opened this issue Oct 1, 2021 · 10 comments
Assignees
Labels
area-razor.compiler This issue is related to the Razor compiler (now external) Done This issue has been fixed
Milestone

Comments

@meziantou
Copy link
Contributor

Describe the bug

I try to update a project to .NET 6 RC1. The project is a Razor Class Library that contains Blazor components.
I use the [email protected] package to set the MSBuild properties for reproducible builds. It works great in .NET 5. However, in .NET 6 RC1, the path to the razor files in the pdb are local paths (C:\...) instead of a deterministic path (/_/...).

  • .NET 5:

    image

  • .NET 6:

    image

To Reproduce

Is there a new property to set in the csproj file to handle razor files in .NET 6?

@pranavkm pranavkm added the area-razor.compiler This issue is related to the Razor compiler (now external) label Oct 1, 2021
@pranavkm
Copy link
Contributor

pranavkm commented Oct 1, 2021

@meziantou I tried the repro app that you shared, and it looks like the net6.0 app works correctly. I have a rc2 SDK installed:

image

Are your results different when building locally?

@pranavkm pranavkm added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Oct 1, 2021
@meziantou
Copy link
Contributor Author

You can build the .NET 6 project (RazorClassLibrary1) locally using:

dotnet pack /p:GITHUB_ACTIONS=true /bl

/p:GITHUB_ACTIONS=true makes DotNet.ReproducibleBuilds think the project is built on GitHub, so it enables all useful properties (ContinuousIntegrationBuild, source link, etc.)

You can see using NuGet Package Explorer:

  • ✔️ Local .cs files are converted to a GitHub link (source link)
  • ❌ Razor files have local paths (c:\users\...)
  • ✔️Generated files have deterministic paths (/_/...)

image

Using the .NET SDK 5.0.401

To build the .NET 5 project (RazorClassLibrary2), you may need to use .NET 5 SDK (5.0.401) as the .NET 6 SDK RC1 produces an error because of #35568

You can see using NuGet Package Explorer:

  • ✔️ Local .cs files are converted to a GitHub link (source link)
  • ✔️ Local .razor files are converted to a GitHub link (source link)
  • ✔️Generated files have deterministic paths (/_/...)

image

dotnet --info

.NET SDK (reflecting any global.json):
 Version:   6.0.100-rc.1.21463.6
 Commit:    e627d556a1

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\

Host (useful for support):
  Version: 6.0.0-rc.1.21451.13
  Commit:  d7619cd4b1

.NET SDKs installed:
  5.0.401 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.1.21463.6 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.1.21452.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.1.21451.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-rc.1.21451.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Oct 2, 2021
@pranavkm
Copy link
Contributor

pranavkm commented Oct 5, 2021

@chsienki / @jaredpar do you know if there's anything we need to do in Razor to address this? Could be that sourcelinks are being correctly resolved for additional files?

@jaredpar
Copy link
Member

jaredpar commented Oct 5, 2021

@clairernovotny, @tmat

Unfortunately the screen shots don't line up with the binlog that are produced here. For example I can't see GeneratedForm.razor in the net6.0 binlog. Maybe I'm doing something subtly wrong here.

@meziantou
Copy link
Contributor Author

@jaredpar The screenshots from the first post was from another project (before I made the repro projects). The screenshots from the next messages should line up with the binlogs from the first post. Also, you can have a look at the GitHub project which contains the source code for all other screenshots and binlog.

@tmat
Copy link
Member

tmat commented Oct 5, 2021

I see the problem.

This is the PathMap that csc receives:

PathMap = 
  C:\Users\runneradmin\.nuget\packages\=/_1/,
  C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\=/_2/,
  C:\Program Files (x86)\Microsoft\Xamarin\NuGet\=/_3/,
  D:\a\repro-reproduciblebuilds\repro-reproduciblebuilds\=/_/,

This is the #line directive that Razor generator emits:

#line "d:\a\repro-reproduciblebuilds\repro-reproduciblebuilds\RazorClassLibrary1\_Imports.razor"

Notice the difference in casing of D drive. This causes mismatch in Source Link map.

The compiler is given the additional paths with lower-case drive, so the source generator is correctly emitting the paths with the given casing.
image

@pranavkm
Copy link
Contributor

pranavkm commented Oct 5, 2021

That's sounds like a Razor SDK issue. We were intentionally changing the path root to workaround an issue with O# which was recently resolved. I can take it from here and see if removing the workaround helps.

pranavkm added a commit to dotnet/sdk that referenced this issue Oct 6, 2021
As part of addressing dotnet/aspnetcore#30750, we had added
a workaround to the RazorSDK to ensure building inside O# worked. This issue is being
resolved as part of the upcoming O# v1.37.16. In the meanwhile, the workaround affects
sourcelink for razor files.

Fixes dotnet/aspnetcore#37182
@pranavkm pranavkm self-assigned this Oct 6, 2021
@pranavkm pranavkm added this to the 6.0.0 milestone Oct 6, 2021
@ghost ghost added the Working label Oct 6, 2021
pranavkm added a commit to dotnet/sdk that referenced this issue Oct 7, 2021
As part of addressing dotnet/aspnetcore#30750, we had added
a workaround to the RazorSDK to ensure building inside O# worked. This issue is being
resolved as part of the upcoming O# v1.37.16. In the meanwhile, the workaround affects
sourcelink for razor files.

Fixes dotnet/aspnetcore#37182
@pranavkm
Copy link
Contributor

pranavkm commented Oct 7, 2021

@meziantou this was resolved as part of dotnet/sdk#21806. A nightly build from the Release/6.0.1XX channel - https://github.com/dotnet/installer#installers-and-binaries - should have this fix if you'd like to give this a try.

@pranavkm pranavkm closed this as completed Oct 7, 2021
@ghost ghost added Done This issue has been fixed and removed Working labels Oct 7, 2021
@pranavkm pranavkm removed the Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. label Oct 7, 2021
@meziantou
Copy link
Contributor Author

Thanks @pranavkm! I gave it a try this morning and it's all green using 6.0.100-rtm.21508.2 😊
Do you know if the fix will be part of RC2 (it is not in the daily build), or do I have to wait for the RTM in November?

image

@pranavkm
Copy link
Contributor

pranavkm commented Oct 8, 2021

Do you know if the fix will be part of RC2

RC2 builds are mostly wrapped up now, the fix targets RTM.

@ghost ghost locked as resolved and limited conversation to collaborators Nov 7, 2021
chsienki pushed a commit to chsienki/razor-compiler that referenced this issue May 20, 2022
As part of addressing dotnet/aspnetcore#30750, we had added
a workaround to the RazorSDK to ensure building inside O# worked. This issue is being
resolved as part of the upcoming O# v1.37.16. In the meanwhile, the workaround affects
sourcelink for razor files.

Fixes dotnet/aspnetcore#37182
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-razor.compiler This issue is related to the Razor compiler (now external) Done This issue has been fixed
Projects
None yet
Development

No branches or pull requests

4 participants