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

Editor config options not populated correctly when project build path includes a symlink? #72453

Open
nblumhardt opened this issue Mar 8, 2024 · 1 comment
Labels
untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@nblumhardt
Copy link

nblumhardt commented Mar 8, 2024

Version Used:

8.0.201 SDK on Ubuntu Linux 22.04

Steps to Reproduce:

(1) Create a folder a
(2) In a create an ASP.NET MVC project

dotnet new mvc

(3) Add a second Index.cshtml view in any location other than Home/
(4) Create a symlink directory b which points to a

ln -s ./a ./b

(5) Build the project via the symlinked path

dotnet build ./b/a.csproj

Diagnostic Id: CS8785

Expected Behavior:

Build succeeds cleanly.

Actual Behavior:

Build produces warning and will likely fail at runtime.

CSC : warning CS8785: Generator 'RazorSourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ArgumentException' with message 'The hintName 'Index_cshtml.g.cs' of the added source file must be unique within a generator. (Parameter 'hintName')'. [/home/nblumhardt/a/a.csproj]

In the generated editorconfig file, ProjectDir and MSBuildProjectDirectory use the symlink path, while the target paths generated for included files use the resolved path.

I hit this because my source code root is symlinked into a directory under my ~ home dir on another drive. In this repro.GeneratedMSBuildEditorConfig.editorconfig, the paths in question are ~/GitHub and /mnt/data/GitHub, and you can see that both Index.cshtml views end up with the same target path.

is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion = 
build_property.UsingMicrosoftNETSdkWeb = true
build_property.ProjectTypeGuids = 
build_property.InvariantGlobalization = 
build_property.PlatformNeutralAssembly = 
build_property.EnforceExtendedAnalyzerRules = 
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = repro
build_property.RootNamespace = repro
build_property.ProjectDir = /home/nblumhardt/GitHub/repro/
build_property.EnableComHosting = 
build_property.EnableGeneratedComInterfaceComImportInterop = 
build_property.RazorLangVersion = 8.0
build_property.SupportLocalizedComponentNames = 
build_property.GenerateRazorMetadataSourceChecksumAttributes = 
build_property.MSBuildProjectDirectory = /home/nblumhardt/GitHub/repro
build_property._RazorSourceGeneratorDebug = 

[/mnt/data/GitHub/repro/Views/Home/Index.cshtml]
build_metadata.AdditionalFiles.TargetPath = SW5kZXguY3NodG1s
build_metadata.AdditionalFiles.CssScope = 

[/mnt/data/GitHub/repro/Views/Home/Privacy.cshtml]
build_metadata.AdditionalFiles.TargetPath = UHJpdmFjeS5jc2h0bWw=
build_metadata.AdditionalFiles.CssScope = 

[/mnt/data/GitHub/repro/Views/Other/Index.cshtml]
build_metadata.AdditionalFiles.TargetPath = SW5kZXguY3NodG1s
build_metadata.AdditionalFiles.CssScope = 

[/mnt/data/GitHub/repro/Views/Shared/Error.cshtml]
build_metadata.AdditionalFiles.TargetPath = RXJyb3IuY3NodG1s
build_metadata.AdditionalFiles.CssScope = 

[/mnt/data/GitHub/repro/Views/Shared/_ValidationScriptsPartial.cshtml]
build_metadata.AdditionalFiles.TargetPath = X1ZhbGlkYXRpb25TY3JpcHRzUGFydGlhbC5jc2h0bWw=
build_metadata.AdditionalFiles.CssScope = 

[/mnt/data/GitHub/repro/Views/_ViewImports.cshtml]
build_metadata.AdditionalFiles.TargetPath = X1ZpZXdJbXBvcnRzLmNzaHRtbA==
build_metadata.AdditionalFiles.CssScope = 

[/mnt/data/GitHub/repro/Views/_ViewStart.cshtml]
build_metadata.AdditionalFiles.TargetPath = X1ZpZXdTdGFydC5jc2h0bWw=
build_metadata.AdditionalFiles.CssScope = 

[/mnt/data/GitHub/repro/Views/Shared/_Layout.cshtml]
build_metadata.AdditionalFiles.TargetPath = X0xheW91dC5jc2h0bWw=
build_metadata.AdditionalFiles.CssScope = b-ewte10s1rc

Building from the resolved path fixes this.

I know this is a fairly loose repro; if it's something that's likely to be fixed/fixable and you need more information from me please just let me know.

Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant