views:

453

answers:

3

I'm working on an automated process to build a base application to include common libraries and projects, check everything into source control and setup the base build for the solution. Most of the issues I've solved except one. Is it possible to intercept the user given path for the solution and projects and alter that path?

In other words.

the user gives C:/Projects/App1 on the create new project screen. the solution and projects actually get stored at C:/Projects/App1/trunk/source/App1

I want to change the path to facilitate how our TFS is setup for continuous builds. I've solved most other problems except this one and it seems like this should be the simplest. I tried to see if I could change it within my IWizard class but so far, no luck. Any suggestions would be greatly appreciated.

I should add that this process is being triggered by the user selecting a custom template. If there is no answer using a custom template, I will switch to a VS add-in.

-Scott

A: 

I'm not sure what you are doing, but something like that is possible with project templates. Not sure if this applies in your case though.

Added: Something like this:

<TemplateContent>
    <Project>
        <Folder>
            <Folder>
                <ProjectItem></ProjectItem
            </Folder>
        </Folder>
    </Project>
</TemplateContent>
Vilx-
I modified my post to have a bit more detail. I am using a custom template which uses a custom class that implements IWizard. I can do some other stuff with IWizard, just not sure I can change the save directory.
Bomlin
The template descriptor XML specifies all the folders into which the template files should be copied. Why not just add it there?
Vilx-
Because that controls the folder structure within the project. I need to change the folder structure at the solution level. This is a multi-project template.
Bomlin
Perhaps you can somehow make Studio NOT to create the default .SLN file, but instead make one yourself, like a project item?
Vilx-
A: 

You shold look into the Guidance Automation Toolkit. Among other things, it allows you to create solution templates that will allow you to do all you've mentioned, and more. You could even present a wizard UI to the user asking for options with which you can then customize the solution, in terms of what project and file references to include. You can set up project settings of all kinds; enforce standards, etc.

You can see a sophisticated example of GAT in the Service Factory. There is also a GAT forum at http://social.msdn.microsoft.com/forums/en-US/vsgatk/threads/.

GAT is a great way to use Visual Studio Extensibility to really get things done.

John Saunders
A: 

After looking into it some more, I discovered that the IWizard interface is not even called until after the folder structure for the solution (not the projects) has already been created. Since I need to make progress, I've decided to go ahead and switch it to an Add-In to Visual Studio instead of a purely templated process.

I've already had much more luck creating the solution programmatically then adding in the templated projects to my solution. I was able to get around the problem. I've snipped some code but this gives the basic idea.

System.Type vsType = System.Type.GetTypeFromProgID("VisualStudio.DTE.9.0"); DTE2 vs = (DTE2)System.Activator.CreateInstance(vsType, true);

soln = (Solution2)vs.Solution;

soln.Create(PathProjectRoot, SolutionName);

soln.SaveAs(SolutionName);

Thanks everyone for the suggestions.

Bomlin
FYI, this is exactly the sort of thing that can be done with the GAT, but it can do even more. A user could run a "recipe" that prompts for solution name, project, team or whatever, and solution could be built at right place in source tree, with right references, etc.
John Saunders