<include> with relative file path does not work

A

Alex VanderWoude

I am trying to <include> some text into an XML documentation topic, but
that text is stored in a file that is in a different directory than the
"current" XML file. Using a relative path does not appear to work, because
the base being used is the Common7\IDE directory, not my original source
directory.

Here is the situation:

MyApp directory contains the file Form1.cs, Form1.xml, and Generic.xml.
There is also a subdirectory called SubDir, which contains Form2.cs and
Form2.xml. In Form2.xml I want to <include> a topic from Generic.xml, like
this:

<Form2 name="Foo">
<include file='Generic.xml' path='Generic[@name="Bar"]/*' />
</Form2>

The above doesn't work, because when the overall MyApp.xml file is produced
it cannot find Generic.xml. The complaint generated by the compiler is as
follows:

c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\Generic.xml
Badly formed XML in included comments file -- 'The system cannot locate the
object specified.'

So I tried the following:

<include file='..\Generic.xml' path='Generic[@name="Bar"]/*' />

But this doesn't work either, because as the above message implies, the
Common7\IDE directory is being used as the base from which to calculate the
relative path. Here's the error:

c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Generic.xml
Badly formed XML in included comments file -- 'The system cannot locate the
object specified.'

As can be seen, instead of failing to find the file in the IDE directory it
now fails to find the file in the Common7 directory. But why is it looking
there instead of where my source code is?

Finally I tried hard-coding the path:

<include file='C:\Dev\MyApp\Generic.xml' path='Generic[@name="Bar"]/*' />

This worked, but it is unsatisfying because the XML files are now tied to a
particular directory location on my hard drive. A different developer on
the team might have their development tree elsewhere, and these path
references would fail to compile.

What I can't figure out is why the Common7\IDE directory is being used as
the base from which to resolve the relative paths. Is there a setting
somewhere in Visual Studio that controls this?

Regards,
Alex VanderWoude
 
A

Alex VanderWoude

I am trying to <include> some text into an XML documentation topic, but
that text is stored in a file that is in a different directory than the
"current" XML file. Using a relative path does not appear to work,
because the base being used is the Common7\IDE directory, not my original
source directory.

Here is the situation:

MyApp directory contains the file Form1.cs, Form1.xml, and Generic.xml.
There is also a subdirectory called SubDir, which contains Form2.cs and
Form2.xml. In Form2.xml I want to <include> a topic from Generic.xml,
like this:

<Form2 name="Foo">
<include file='Generic.xml' path='Generic[@name="Bar"]/*' />
</Form2>

The above doesn't work, because when the overall MyApp.xml file is
produced it cannot find Generic.xml. The complaint generated by the
compiler is as follows:

c:\Program Files\Microsoft Visual Studio .NET
2003\Common7\IDE\Generic.xml Badly formed XML in included comments file --


'The system cannot locate the object specified.'

So I tried the following:

<include file='..\Generic.xml' path='Generic[@name="Bar"]/*' />

But this doesn't work either, because as the above message implies, the
Common7\IDE directory is being used as the base from which to calculate
the relative path. Here's the error:

c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Generic.xml
Badly formed XML in included comments file -- 'The system cannot locate
the object specified.'

As can be seen, instead of failing to find the file in the IDE directory
it now fails to find the file in the Common7 directory. But why is it
looking there instead of where my source code is?

Finally I tried hard-coding the path:

<include file='C:\Dev\MyApp\Generic.xml' path='Generic[@name="Bar"]/*' />

This worked, but it is unsatisfying because the XML files are now tied to
a particular directory location on my hard drive. A different developer
on the team might have their development tree elsewhere, and these path
references would fail to compile.

What I can't figure out is why the Common7\IDE directory is being used as
the base from which to resolve the relative paths. Is there a setting
somewhere in Visual Studio that controls this?


Well, I wasn't able to figure out how to make a reference work, so I solved
it by creating a Pre-Build action that copies the necessary files to the
same directory as the "calling" topic. Using the previous example, the
Pre-Build action copies the Generic.xml file to the SubDir subdirectory,
which allows the compiler to find the topic it's looking for while
compiling Form2 and include the relevant XML in the output file. Since the
file is copied every time a rebuild is issued, the copied file contains all
the latest text, and all is well.

Better than a poke in the eye, I suppose.

- Alex
 

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

Top