Wednesday, July 2, 2014

Visual Studio templates vstemplates part 2

Yesterdays lesson was a catchup to today's lesson learned. Actually there were several which will end up in separate posts since the topic vary. This lesson is regarding creating new solutions from template collections. After a custom template is made available and you create a new solution from that template, all of the projects are created in their respective folders under a folder the same name as the solution.

The good: the solution is well organized.

The bad: if you have NuGet packages installed as part of the template, the references will be mangled since they want to point to ../packages but you need them to point to ../packages.

The ugly: there are several ways to resolve this issue until the NuGet gets rid of this ref issue for good (another lesson learned today).

Option 1: close the solution, move the project folders up one folder, open the sln file in Notpad++ or some other text editor, change the project refs to reflect the new location.


Option 2: edit the proj files in the template collection folders to ref nuget package one level up.

Option 3: edit the proj files in your new solution to point to the correct place.

Option 4: uninstall and reinstall all the nugets in the solution. Better take notes of versions and use the nuget commands because the manager won't give you the same version.

Option 5: edit the proj templates to reflect the fix in my next post.

there may be other options, so far I went with the first one. Found that you have to close the solution before you edit or it will resave from the cache.

Another thing I learned about vstemplates is that they get cached by VS after you create a couple. If you edit the templates, you would need to clear them from the template cache. Once you do that, you also need to restart VS. The template cache is located in appdata/roaming/microsoft/visual studio/{{version}}/project templates or something like that.

No comments:

Post a Comment