When using full paths to source xaml files, the generated .g.cs files aren't placed in subfolders in the obj\target folder
See original GitHub issueVersion Used: Microsoft ® Visual C# Compiler version 4.0.1-1.21568.1 (6ab66011)
Steps to Reproduce:
- Create a .csproj. Using full pathnames, specify multiple xaml files with the same name, but a different subfolder.
<Page Include="C:\Projects\MyProject\Views\View1\GeneralView.xaml">
<Link>Views\View1\GeneralView.xaml</Link>
<SubType>Designer</SubType>
</Page>
<Page Include="C:\Projects\MyProject\Views\View2\GeneralView.xaml">
<Link>Views\View2\GeneralView.xaml</Link>
<SubType>Designer</SubType>
</Page>
- Build
- Build Fails. Observe CS2002 warnings, combined with other errors because only the last
GeneralView.g.cs
file was written to/obj/x64/Debug
Expected Behavior:
Each GeneralView.g.cs
file should be in a subfolder in the object folder.
/obj/x64/Debug/Views/View1/GeneralView.g.cs
/obj/x64/Debug/Views/View2/GeneralView.g.cs
Actual Behavior:
Each GeneralView.g.cs
file overwrites the previous file in the root object folder, so you end up with only the last one in the root object folder: /obj/x64/Debug/GeneralView.g.cs
Notes:
The distinction is that the csproj file is using full paths to the source files, instead of relative paths. I’m using cmake
in my project, and it generated the csproj files like this. I would file a bug with cmake
, but there doesn’t seem to be anything in the specification for csproj files that would preclude using full paths to source files.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
@lindexi I agree that not many will use absolute paths, because they would have to be writing the csproj by hand. Or, in this case, using
cmake
to generate it. But anyone using cmake and also having duplicate file names with encounter this. Cmake is designed to always support out-of-source builds, so there is no way around the absolute paths.My workaround was to guarantee that each file has a unique name, so they don’t conflict when they all get written to the same output folder.
Perhaps an error message could at least be generated by the compiler when it encounters a duplicate file name during a single build run (as it tries to write the output)?
And I think few developers will write absolute paths in projects.