简体   繁体   中英

How can I add Solution Folder files to a VS Project Template?

I'm trying to create a Project Template in Visual Studio. My basic Solution contains two Projects and a 'Solution Items' Solution Folder that contains (among other things) libraries (.dlls) that the two projects need as References.

My Project Template creates the two Projects, the 'Solution Items' Folder, and another Folder within 'Solution Items' (as desired). It does not, however, add the .dlls and other files that are supposed to populate 'Solution Items'.

In the .vstemplate file, I add references to the .dlls as 'ProjectItem' items directly beneath the 'TemplateContent' node, and they are ignored.

If I try adding a 'Project' node (as if my Solution Items folder were a Project), I get all kinds of errors.

Must I actually create a dummy project to hold these files?

It seems that I do need to include the Miscellaneous Files (Microsoft's term) in a Project in order to have the project generator find them. I put them into a folder and included them in one of my project Templates.

I then implemented an IWizard which I also included in the Solution Template which, after that Project had been built, would move the files where I wanted them, and modify the .csproj file so that it wouldn't miss them.

It all works fine, but it feels like the grossest of hacks...! Is anybody from MS out there?

I've never created a template before, so I can only guess at what you're doing. In our .sln files, our solution items look like this:

Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Build", "_Build", "{45E29CA9-E213-4C73-AA54-AE9B87F79F2D}"
    ProjectSection(SolutionItems) = preProject
        _Build\Project.proj = _Build\Project.proj
    EndProjectSection
EndProject

Where _Build is the SolutionFolder, which we map to a physical folder also called "_ Build ". In this case, it contains one file, the Project.proj file, which is of course mapped to the physical folder version.

Hope that's even remotely helpful..?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM