How to pass files to generator?
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
I need to pass all XAML file paths to a generator in my project. Initially, I achieved this by adding the following line to my .csproj file:
`
`
However, after doing this, I noticed that all XAML files were incorrectly assigned the build action as C# analyzer additional files, which broke the normal XAML workflow.
When I tried to add a new XAML file afterward, Visual Studio started throwing the following error:
**“The given key was not present in the dictionary.”**
To work around this, I modified the entry to:
`
`
This fixed the build action issue, but the error still occurs when adding new XAML files.
Next, I changed the include scope to:
`Include="Views\**\*.xaml"
`
With this change, everything appears to work correctly: I can add new XAML files without errors. However, now I see additional linked shortcut versions of XAML files appearing in Solution Explorer, which is very confusing and cluttered.
At this point I’m not sure what the correct approach is. I need all XAML file paths available for a generator, but without:
- breaking Visual Studio project behavior
- causing “key not present in dictionary” errors
- or introducing unwanted linked file duplicates
i tried to use `Directory.EnumerateFiles` but file I/O banned in generator.
what should i do?
Contributor guide
Assessment
This issue has not been assessed yet.