(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.
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.
Version Used:
8.0.201 SDK on Ubuntu Linux 22.04
Steps to Reproduce:
(1) Create a folder
a
(2) Ina
create an ASP.NET MVC project(3) Add a second
Index.cshtml
view in any location other thanHome/
(4) Create a symlink directoryb
which points toa
(5) Build the project via the symlinked path
Diagnostic Id: CS8785
Expected Behavior:
Build succeeds cleanly.
Actual Behavior:
Build produces warning and will likely fail at runtime.
In the generated editorconfig file,
ProjectDir
andMSBuildProjectDirectory
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 thisrepro.GeneratedMSBuildEditorConfig.editorconfig
, the paths in question are~/GitHub
and/mnt/data/GitHub
, and you can see that bothIndex.cshtml
views end up with the same target path.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.