Default Project References

  • Thread starter Thread starter Simon
  • Start date Start date
S

Simon

If there is a different newsgroup for specific Visual Studio questions then
please let me know - in the meantime perhaps I can post the question here:

It seems that whenever I create new projects, I repeatedly have to add the
same set of References in Solution Explorer. Is there a way of specifying a
default Reference list which will be picked up by all new Projects as a
starting point?

Cheers
Simon
 
Simon,

I don't believe that there is a way to do this. However, I do believe
that you can create your own project types, which you would then specify the
project references that you have to set.

Also, for specific projects, you can modify the references that are
added. I don't know how supported this is, but it should work.

If you look in the directory where VS.NET is installed, you should see
the following directory structure:

<Visual Studio .NET directory>
VC#
VC#Wizards
CSharpAddWinFormWiz
Scripts
1033

1033 I believe is the culture code, and it might be different if you
don't have the US english version installed. In that directory is a file
called "default.js". This is a bit of JavaScript that is run when the
project is created. If you open that up, you should notice a line:

AddReferencesForWinForm(selProj);

This is where the references are added. The code for this method is in
the following directory:

<Visual Studio .NET directory>\VC#\VC#Wizards\1033

Once again, 1033 might be different. Find the "common.js" file. In it,
you should be able to find the function AddReferencesForWinForm. That
function looks like this:

function AddReferencesForWinForm(oProj)
{
var refmanager = GetCSharpReferenceManager(oProj);
refmanager.Add("System");
refmanager.Add("System.Data");
refmanager.Add("System.Drawing");
refmanager.Add("System.Windows.Forms");
refmanager.Add("System.XML");
CollapseReferencesNode(oProj);
}

You should be able to add calls (or remove them if you wish) to the Add
method and add your own references.

Hope this helps.
 
Nicholas

The "back-door" approach worked well. I wouldn't have worked that one out
though! Shame that there wasn't a more straight-forward approach. I guess
that while I would consider the ability to do this a "must-have", the
requirement is actually more niche in the real world. Oh well, my mind must
work differently to others!

Do you have any more information on creating custom project types?

Many thanks for your help.
Cheers
Simon

Nicholas Paldino said:
Simon,

I don't believe that there is a way to do this. However, I do believe
that you can create your own project types, which you would then specify the
project references that you have to set.

Also, for specific projects, you can modify the references that are
added. I don't know how supported this is, but it should work.

If you look in the directory where VS.NET is installed, you should see
the following directory structure:

<Visual Studio .NET directory>
VC#
VC#Wizards
CSharpAddWinFormWiz
Scripts
1033

1033 I believe is the culture code, and it might be different if you
don't have the US english version installed. In that directory is a file
called "default.js". This is a bit of JavaScript that is run when the
project is created. If you open that up, you should notice a line:

AddReferencesForWinForm(selProj);

This is where the references are added. The code for this method is in
the following directory:

<Visual Studio .NET directory>\VC#\VC#Wizards\1033

Once again, 1033 might be different. Find the "common.js" file. In it,
you should be able to find the function AddReferencesForWinForm. That
function looks like this:

function AddReferencesForWinForm(oProj)
{
var refmanager = GetCSharpReferenceManager(oProj);
refmanager.Add("System");
refmanager.Add("System.Data");
refmanager.Add("System.Drawing");
refmanager.Add("System.Windows.Forms");
refmanager.Add("System.XML");
CollapseReferencesNode(oProj);
}

You should be able to add calls (or remove them if you wish) to the Add
method and add your own references.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)



Simon said:
If there is a different newsgroup for specific Visual Studio questions then
please let me know - in the meantime perhaps I can post the question here:

It seems that whenever I create new projects, I repeatedly have to add the
same set of References in Solution Explorer. Is there a way of
specifying
a
default Reference list which will be picked up by all new Projects as a
starting point?

Cheers
Simon
 
Back
Top