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.
我正在尝试在Visual Studio中创建项目模板。我的基本解决方案包含两个项目和一个“解决方案项目”解决方案文件夹,其中包含两个项目需要作为参考的库(.dll)。
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'.
我的项目模板创建了两个项目,“解决方案项目”文件夹和“解决方案项目”中的另一个文件夹(根据需要)。但是,它不会添加.dll和其他应该填充“解决方案项”的文件。
In the .vstemplate file, I add references to the .dlls as 'ProjectItem' items directly beneath the 'TemplateContent' node, and they are ignored.
在.vstemplate文件中,我将.dll的引用添加为“ProjectContem”节点正下方的“ProjectItem”项,并忽略它们。
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?
我真的必须创建一个虚拟项目来保存这些文件吗?
2 个解决方案
#1
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.
我似乎需要在项目中包含杂项文件(Microsoft的术语),以便让项目生成器找到它们。我把它们放在一个文件夹中,并将它们包含在我的一个项目模板中。
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.
然后我实现了一个IWizard,我也包含在解决方案模板中,在构建项目之后,将文件移动到我想要的位置,并修改.csproj文件以便它不会错过它们。
It all works fine, but it feels like the grossest of hacks...! Is anybody from MS out there?
一切正常,但感觉就像最粗糙的黑客......!有人来自MS吗?
#2
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:
我以前从未创建过模板,所以我只能猜测你在做什么。在我们的.sln文件中,我们的解决方案项目如下所示:
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.
_Build是SolutionFolder,我们将其映射到一个名为“_Build”的物理文件夹。在这种情况下,它包含一个文件Project.proj文件,该文件当然映射到物理文件夹版本。
Hope that's even remotely helpful..?
希望这甚至远程帮助..?
#1
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.
我似乎需要在项目中包含杂项文件(Microsoft的术语),以便让项目生成器找到它们。我把它们放在一个文件夹中,并将它们包含在我的一个项目模板中。
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.
然后我实现了一个IWizard,我也包含在解决方案模板中,在构建项目之后,将文件移动到我想要的位置,并修改.csproj文件以便它不会错过它们。
It all works fine, but it feels like the grossest of hacks...! Is anybody from MS out there?
一切正常,但感觉就像最粗糙的黑客......!有人来自MS吗?
#2
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:
我以前从未创建过模板,所以我只能猜测你在做什么。在我们的.sln文件中,我们的解决方案项目如下所示:
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.
_Build是SolutionFolder,我们将其映射到一个名为“_Build”的物理文件夹。在这种情况下,它包含一个文件Project.proj文件,该文件当然映射到物理文件夹版本。
Hope that's even remotely helpful..?
希望这甚至远程帮助..?