How to create a template for visual studio 2008 for multiple projects - visual-studio

I want to create a template kind of thing where there will be more than one project in the solution. Like one test project + one normal project + some other project.
How to do that.
When I export a template it exports only one project.

We had to resort to a powershell script to do this, as we couldn't find a reliable way of doing this.

This is fully supported but you'll need to modify the .vstemplate file manually. Starting by running the Save as Template on each project is a good first step. Now you need to bind them together in another .vstemplate. More information can be found here:
http://msdn.microsoft.com/en-us/library/ms185308(v=vs.80).aspx

Have you tried this: http://visualstudiogallery.msdn.microsoft.com/57320b20-34a2-42e4-b97e-e615c71aca24

Related

Create solution programmatically

We are automatically creating solution files (sln) and solution filters (slnf) during our CI.
Since we are not working inside Visual Studio we cannot use the DTE to work with Therefore we are using the Microsoft.Build nuget packages.
Everathing works fine, except that there is not possibility to create a solution file programmatically. It seems that I have to create it fully manually by stiching blocks of text.
Is there a better way to do this?
Since my comment helped, posting it as answer
There's MvsSln which is very powerful in editing. Also there's mine little project that has very simple API - bunch of immutable types and saveToFile function

How do I modify the template that reference.cs is generated from?

I've been searching on the web for this, and maybe I'm just using the wrong keywords or something? I could use some help.
My problem is simple - we have a bunch of reference.cs files in our solution, which were auto-generated by VS2010 when adding services. These files don't add XML comments by default, so when we build the project, I get 800 or so messages in the build list. This doesn't break anything, but it does make the build take (significantly) longer, and mucks up the output screen.
I "fixed" this by adding the appropriate #pragma statments to the beginning and end of each reference.cs file, but if those ever get regenerated, they will have to be re-added by hand. I'd like to streamline that process and just add them to whatever T4 template VS2010 is using in the first place. The problem is, I don't know where that is, or if VS2010 is using something else to build these files?
Can this be done? Is there a better solution? I don't necessarily want to turn off XML comments for the entire project.
Visual Studio does not use T4 templates to generate the service reference proxy classes (Reference.cs). Instead Visual Studio is most likely using the WsdlImporter and ServiceContractGenerator classes to generate this code.
There is a stackoverflow post on using either a custom wsdl exporter or WCFExtras to add xml comments to the generated code. Both of these assume you have access to the code for the services you are referencing.

Is there a reason not to include Nant files in your solution?

The project I'm currently working on uses Nant build scripts for the continuous integration server builds. The build file is stored in a folder in the repository.
I find it annoying having to browse to it via windows explorer rather than it being available from the visual studio solution when I need to make changes.
I was wondering if there is any reason not to include it somewhere in the solution for ease of access? If this isn't daft where would you store it in the solution? Would you create a dummy non building project for holding these type of resources?
Thanks,
Neil
Go right ahead and add it to your solution file.
You will either get, or have to create manually, a folder for it, but I think that when you add it you will get a folder called Solution Items.
As far as I have seen, there is no real reason to not have them along with your project solution. In one project, since there were lots of build files, it made sense to create a separate solution for them.

In Visual Studio, how do I include a built file in another project?

How specifically should my command line be written as to copy the output from one project into the output of another project? The list of macros that are avaliable does not list anyway of accessing OTHER project directories under the same solution:
http://msdn.microsoft.com/en-us/library/42x5kfw4(v=vs.80).aspx
Here is what I currently have:
copy "$(TargetDir)FILE_TO_MOVE.EXE" ""
What should I put in the second quote to complete this command?
NOTE: A similar question does NOT actually show you HOW to do it, which is what I am asking: Visual Studio 2008: How do I include project output as an embedded resource in another project?
It is much easier to do it the other way around, have the project that has the dependency on the file also copy the file. Which you can do in the IDE without pre/post buid event or macro trickery.
Ensure the source project is built. Right click the target project, Add Existing Item and select the file. Click the added file in the Solution Explorer window and set the properties to Build Action = Content, Copy to Output Directory = Copy if newer. And right-click the target project, Project Dependencies, tick the source project to ensure that it always gets built first.
I am assuming that yout are copying the "FILE_TO_MOVE.EXE" in the post build events of your project.
The thing about the build events in Visual Studio is that they are run just like a batch file, therefore I beileve that the easiest way to solve your problem is to use a system environment variable in your project... This way your code would be similar to the one below.
copy "$(TargetDir)FILE_TO_MOVE.EXE" "$(MyVariable)"
Note: Visual Studio doesn't let you use your environment variable like this: %MyVariable%.
I think the correct way now would be to simply add your secondary project, i.e a Windows Service, to the References of the main project.
For example if you have a main GUI project (that the solution was created with), and a second Service project added to the solution, adding it to References of the GUI project will cause the EXE and the PDB of the service to be placed in the Debug/Release folder of you main project.
I am not sure if you still need to add the Project Dependancy as Hans suggested . This is probably automatic thanks to the reference.

Visual Studio Solution Template - Link Source Control Projects

My team is creating some standard VS solution templates. We have a well-defined project structure, resources, etc. that we need to use every time we start a new project and this is the perfect solution. The basics work nicely.
However, as well as defining folder structure (etc.) it would be nice to be able to import a number of projects from VSS/TFS. We have a number of shared assemblies that will be used by all projects and it would be awesome to add a reference to these projects when creating a new project via our template. Can anyone tell me if this is possible and, if so, how it can be achieved?
I think there are 3 types of items you might want to templatize (is that a word?).
New Solution
New Project added to a solution
New item added to a project
I'm not sure whether its possible to add existing projects to the solution that is created when a project template is run. http://msdn.microsoft.com/en-us/library/ms185308.aspx shows how to create multiple project templates. You may have to either manually add them to the solution or create a script that modifies the .sln file to do that part.
Adding an assembly reference to either a project or item template is easily doable. The project template is pretty simple since you just need to modify your .vstemplate file for the project template(s). See http://msdn.microsoft.com/en-us/library/ms171405.aspx for reference.
Adding a new assembly reference when you add a new item from a template is a bit harder but can also be done. See http://msdn.microsoft.com/en-us/library/ms185290.aspx for more.
Have fun!

Resources