Excluding a file from VS.Net Project

J

Jon Maz

Hi,

Curiosity - when you right-click on a file in the VS.Net Solution Explorer
and select "Exclude from Project", it continues to be shown in the Solution
Explorer as a sort of ghostly outline (as long as you have selected "Show
All Files"). Yet if you open up the project file (which is just XML) in a
text editor, the reference to the now-excluded file has gone.

Question: how is VS.Net still able to show the file in Solution Explorer
when all references to it have been deleted from the project file?

TIA,

JON
 
S

Scott Mitchell [MVP]

Jon said:
Curiosity - when you right-click on a file in the VS.Net Solution Explorer
and select "Exclude from Project", it continues to be shown in the Solution
Explorer as a sort of ghostly outline (as long as you have selected "Show
All Files"). Yet if you open up the project file (which is just XML) in a
text editor, the reference to the now-excluded file has gone.

Question: how is VS.Net still able to show the file in Solution Explorer
when all references to it have been deleted from the project file?

Jon, I don't know for certain, but I imagine it just shows *all* files
in the appropriate directory when you select to "Show All Files," giving
the ghostly outline to those that are not included in the project.
That's how it still knows it's there - it's a file in the directory.

That is, excluding a file from a project doesn't delete it from the file
system, it just unassociates it with the project.

hth

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
J

Jon Maz

Hi Scott,

Plausible, but I think the mystery continues...

Try this:

1 Create a project
2 Show All Files
3 Add a new file "temp.txt" via Solution Explorer in the project root folder
4 Exclude "temp.txt" from the project
5 Close the project down, saving everything
6 Navigate to the root folder and delete "temp.txt" via windows explorer
7 Open the project again
8 The file "temp.txt" is *still* there in Solution Explorer, all ghostly and
malevolent.

!!!!!!!???????????!!!!!!!!!!!!

JON
 
S

Scott Mitchell [MVP]

I am not able to repro. I tried what you said, but in Step 7, when I
reopen the Solution and click "Show ALl Files," test.txt is not there.
I am using VS.NET 2003.

Jon said:
Hi Scott,

Plausible, but I think the mystery continues...

Try this:

1 Create a project
2 Show All Files
3 Add a new file "temp.txt" via Solution Explorer in the project root folder
4 Exclude "temp.txt" from the project
5 Close the project down, saving everything
6 Navigate to the root folder and delete "temp.txt" via windows explorer
7 Open the project again
8 The file "temp.txt" is *still* there in Solution Explorer, all ghostly and
malevolent.

!!!!!!!???????????!!!!!!!!!!!!

JON


--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
K

Kevin Spencer

Jon, you have too much time on your hands...

--
:),
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 
F

Flip

8 The file "temp.txt" is *still* there in Solution Explorer, all ghostly
and
malevolent.
I've done this with my messing around with adding files to the project. I
had several nested directories I wanted to make part of the project. So I
added them like I would do in JBuilder and then refreshed the proj but there
weren't added. :< I could drag'n'drop them into VS, but it would only
recreate the folders, not add the underneath files. :< Kind of makes me
wonder the value of the refresh button?
 
J

Jon Maz

Hi All,

SCOTT
1 Am using VS2002
2 Genius! When I reach the puzzling Step 8, if I click "Show All Files"
*twice*, the offending file has disappeared as it should! All is now right
in the world, and we are at the cusp of a new dawn of peace and happiness.

KEVIN
1 Why do people keep saying that to me?
2 Amazingly, there is a bit more to all this than idle hands... I'm
following up on a suggestion made to me in another thread "Auto-add files &
folders to VS.Net project?"
http://groups.google.com/groups?hl=...write+a+little+routine+to+do+this&btnG=Search

FLIP
1 Yup, that's exactly the issue I'm working on (see other thread)

Thanks for all the interest!

JON
 
K

Kevin Spencer

Hi Jon,
1 Why do people keep saying that to me?

I hope you realize my remark was in jest. I try to inject a bit of humor
here and there to keep things from getting too dry.
2 Amazingly, there is a bit more to all this than idle hands... I'm
following up on a suggestion made to me in another thread "Auto-add files &
folders to VS.Net project?"

After reading your other question, and the answers you got, I understand
your predicament, and I can tell you that there is a good reason that VS.Net
doesn't automatically add files and folders to an given project. That is,
you may not want them added. For example, if you use Visual SourceSafe to
protect your projects, it adds files to your folders that you definitely do
NOT want in your project. Also, at times I have found it convenient to
temporarily exclude a file from a project when compiling, for one reason or
another. If VS.Net automatically added files and folders to projects, you
would soon see a spate of messages coming from people like myself, who would
complain about it not working the way it does now. It's a no-win situation.
Your best bet is to learn to work with the app as it is. And it looks like
you have a solution that works for you now. So, bask away!

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 
J

Jon Maz

Hi Kevin,

1 Quite right too - there's nothing like a bit of jocularity when you're
getting down and dirty with XML, which can indeed be as dry as a ...*
2 Good point, hadn't thought of it that way. And anyway I'm learning quite a
lot making this mini-app.

Cheers,

JON

PS Am quite amused that a relatively frivolous question got an immediate
response from several dotnet heavyweights. In future I will avoid all
serious topics, safe in the knowledge that the gurus are on their way.

*see http://www.jamesnaylor.com/extras/slang.html for ways to finish that
sentence
 
K

Klaus H. Probst

Jon,

As another step in the experiment, open the .csproj (or .vbproj) file in
your solution with a text editor.
 
J

Jon Maz

Hi Klaus,

Yup, playing with the xml in those files is exactly what I'm doing.

Cheers,

JON
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top