dotnet / dotnet/wpf

When using full paths to source xaml files, the generated .g.cs files aren't placed in subfolders in the obj\target folder

Open
#6,290 8 comments 0 reactions 1 assignee Claimed by @chsienki View on GitHub
area-Compilers Untriaged
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

**Version Used**: Microsoft (R) Visual C# Compiler version 4.0.1-1.21568.1 (6ab66011)

**Steps to Reproduce**:

1. Create a .csproj. Using full pathnames, specify multiple xaml files with the same name, but a different subfolder.
```

Views\View1\GeneralView.xaml
Designer


Views\View2\GeneralView.xaml
Designer

```
2. Build
3. 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.