dotnet / dotnet/project-system

Invalid T4 output extension leads to a MessageBox instead of an Error List entry

Open
#7,775 0 comments 1 reaction 1 assignee Claimed by @tmeschter View on GitHub
Parity-Legacy-Feature Triage-Investigate
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.
````
![T4TemplateOutputNewProjectSystem](https://user-images.githubusercontent.com/25843943/142422256-e997e667-a950-490a-8bc3-565210d87e51.png)

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

![T4TemplateOutputProjectSystem](https://user-images.githubusercontent.com/25843943/142422812-8c5ba82c-efcf-40c0-b712-1531db1753f0.png)

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

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.