1

I'm creating a template C++ project for Visual Studio that requires some .lib and .dll files. The files are linked to in the project properties linker settings and included in the dependencies and also included in the project via the Solution Explorer. Everything runs fine, but when I export the project to a template and use that template to create a new project the .lib files are the only ones missing.

I've tried extracting the .zip of the exported template, adding the .lib files manually and their paths to the .vstemplate, then re-zipping the project, but this hasn't worked either.

I'm using Visual Studio 2019 on Windows 10 if that's relevant.

drescherjm
  • 10,365
  • 5
  • 44
  • 64
molonepa
  • 53
  • 3
  • 1
    https://stackoverflow.com/questions/779505/include-custom-dlls-in-visual-studio-project-template – engf-010 Feb 19 '21 at 12:46
  • @engf-010 Thanks, I've had a look at this post, but some of the links are no longer available. Will have a look at nuget anyway. – molonepa Feb 22 '21 at 14:08

1 Answers1

1

In my opinion, as mentioned in the link, the best way is to create a nuget package which contains all your 'content' - such as DLLs.

Of course, there is another way:

  1. Create a Dependencies folder under the project directory, put the required dlls and libs.

  2. Set Proeperties->C/C++->General->Additional Include Directories->(SolutionDir)Dependencies\.. and Proeperties->Linker->General->Additional Library Directories->$(SolutionDir)Dependencies\.. in your project template.

For example: enter image description here

enter image description here

  1. When you use the project template, copy the Dependencies folder to your new project directory.
Barrnet Chou
  • 1,738
  • 1
  • 4
  • 7
  • Thanks for your answer. Up to now I have more or less been doing this, but copying the directory manually every time I start a new project is kind of annoying. I wonder if this could be done with a pre-build command alternatively? Either way I will probably have to look into nuget. – molonepa Feb 22 '21 at 14:12
  • Using [xcpoy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy) is similar to manual copying. So, I suggest that you could use nuget. – Barrnet Chou Feb 23 '21 at 06:54