Visual Studio Project Template and Private Assembl

2019-07-04 16:55发布

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?

3条回答
beautiful°
2楼-- · 2019-07-04 16:56

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.

查看更多
Bombasti
3楼-- · 2019-07-04 17:12

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.

查看更多
beautiful°
4楼-- · 2019-07-04 17:19

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!

查看更多
登录 后发表回答