Visual Studio Project Template and Private Assembly Referencing

一世执手 提交于 2019-12-10 21:29:16

问题


I noticed someone else asked a similar, if not exactly the same, question before, but the answer to it didn't help (me, anyway).

I have a project that I'm building a template from. When I go to reference an assembly in the Program Files, the template project itself will build fine, but any projects built off of it cannot find the referenced assembly. I tried editing the csproj directly, but that didn't work either. How do I reference non-GACed DLLs like that? Am I forced to use an IWizard trick?


回答1:


Okay. You can do this by:

a) Reference your private assemblies in the appropriate folder on the hard-drive, e.g. where they're going to be installed b) Export the project as a template c) Extract the new zip file of the template d) Open the .vstemplate file e) At the bottom of the TemplateContent node, add a References node, and for each reference, add a Reference node as a child of References, then an Assembly node as a child of that, with the name of the assembly. If the assembly is in the GAC, I believe you need to put the fully-qualified assembly name, but otherwise, it seems to work with just the assembly name.

Originally, I'd set an environment path variable that should be searched; however, it ended up being unnecessary, as projects built on the template worked fine without it in the path.




回答2:


For Web Projects the best way I've found to handle this is to Include the Bin folder into the project with all the private assemblies in that folder. It's key that the Bin folder is included or else the folder won't copy.




回答3:


I finally found an easy way in VS 2010 so I am including this answer as it was so hard to find.

in vs2010

Go to Project, then Package/Publish Settings, then Resources tab, Click on Add Resource, locate the assembly file to include.

Done!



来源:https://stackoverflow.com/questions/1343857/visual-studio-project-template-and-private-assembly-referencing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!