dotnet / dotnet/project-system
Invalid T4 output extension leads to a MessageBox instead of an Error List entry
- Dominant language
- C#
- Stars
- 1k
- Forks
- 415
- PR merge metrics
- No merged PRs in 30d
Description
Adding a T4 template to a .csproj file and setting its output extension to something invalid, e.g.
````
<#@ output extension="/" #>
````
results in a MessageBox that states
````
The filename, directory name, or volume label syntax is incorrect.
````

In the old project system this lead to a warning in Visual Studio's Error List:

There are at least two reasons why the MessageBox is a bad idea:
1. There are legitimate reasons for setting `output extension` to something invalid such as [generating multiple output files](https://tim-maes.com/2019/08/12/tutorial-generate-seperate-files-from-a-t4-template/) within the T4 template and hence not needing the file that gets generated by default. The workaround to suppress that default output file is to simply [specify an invalid file extension](https://stackoverflow.com/a/13878689).
2. Debugging what the actual issue is is hard. The MessageBox gives you no context what happened where. No callstack, no way of navigating to the source code, etc.
It would be good to turn this back into a warning that is listed in Visual Studio's Error List. Of course it would be even better if suppressing the default output of a T4 template would be supported by the project system itself.
Contributor guide
Assessment
This issue has not been assessed yet.