Domanda

In a Visual Studio web application project the custom tool information set via the file properties window is being stored in the CSPROJ project file on per file basis.

In a Visual Studio web site project there is no project file, only the SLN file with some global configuration. No file specific information are being stored here as far as I see and know, this should be the whole point of the web site project type.

I can still add both the normal and the preprocessed (runtime) T4 text template to the web site project, but there is no custom tool configuration possible via the file properties window. Nonetheless the Visual Studio knows and remembers which template is of which type, i.e. uses either 'TextTemplatingFileGenerator' for the normal template or 'TextTemplatingFilePreprocessor' for the preprocessed template and the generated output is alright.

This works for me for new web site projects in Visual Studio 2010 and 2012, but it does not work with a web site project I have at hand, which is manually converted from a web application to a web site. All the preprocessed T4 text templates in this project are automatically being processed with the 'TextTemplatingFileGenerator' and there seems to be no way to change this. Of course the templates crash and the project is not buildable afterwards because of the missing classes.

So how does the Visual Studio manage the custom tool information for the T4 templates in a web site project?

If there would be no precompiled text template option in the Add New Item dialog I would say that custom tools are not supported by the web site project at all. But the text templates are there and work fine under some circumstances.

È stato utile?

Soluzione

It seems it needed some time to occur to me that nothing stops me from moving the templates out of the web project and put them into a library project, where there is always a project file and it will be working well regardless of the type of web project, which solves my problem.

I still don't know how the precompiled T4 text templates are supposed be working with a web page type of project though. Feel free to expand on this if you know more.

Altri suggerimenti

The custom wizard DLL in the item template sets the preprocessed item when you do an Add New Item. As a fallback, the project just uses the following registry key to set up the regular templating.

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0_Config\Projects\{E24C65DC-7377-472b-9ABA-BC803B73C61A}\FileExtensions\.tt\CustomTool

If you only have preprocessed templates, you could change this to say TextTemplatingFilePreprocessor instead of TextTemplatingFileGenerator

Otherwise re-adding a set of files from the add new item dialog and copying the content across should work.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top