Linking/Hiding files from a different project
Hi,
I have developed a custom project type using VSIP and using MSBuild to build the project. I want to link files from a different project into my project. How do I do it using <ItemGroup> <Content Include="TestFile.dat" /> </ItemGroup> tags. What does the <Link> element in MSBuild do and how do I use it.
Also, to hide some of the files from my project so that they don't show up in the solution explorer I tried using the Visible property however, did not have any luck.
-K
[517 byte] By [
Kal7379] at [2007-12-17]
Hi,
I'm not familar with the <Link> MSBuild element. Just checkted the XSD for the 2005 RC, didn't find it.
To include more files into your project for building you can use the <ItemGroup> element as follows:
<ItemGroup>
<Compile Include="externalDir\*.cs">
<InProject>false</InProject>
</Compile>
</ItemGroup> Since you are adding the sources files inside of the
externalDir directory to the
Compile Item collection, they will be compiled when your application is built. Since the
<InProject> element has a setting of false, those files will not be shown inside of the Visual Studios.
Hope this helps,
Sayed Ibrahim Hashimi
Kal,
You can experiment with a regular VB/C# project in VS to see how <Link> works. If you Add Existing File then by default if the file you choose is not in the project folder (or below) it will be copied there and be persisted in your project in the regular way.
However if instead of clicking "Add" in the dialog you click the little arrow next to the "Add" button, and choose "Add as Link" (or some similar wording) -- then Visual Studio will not make a copy of the file and instead will "link" to it. Open up the project (right click on the project, Unload, right click, Edit) and see how it was persisted. It's something like
<Compile Include="..\bar\foo.cs">
<Link>foo.cs</Link>
</Compile>
The itemspec is the actual path, the Link metadata has the name to be shown in the solution explorer. Experiment and you'll see how it works.
Dan
<Visible> and <InProject> are synonyms and have the exact same behavior.
We originally implemented it as InProject, but then late in the game, we decided that was a confusing name, so we changed it to Visible. But then it was so late that we didn't want to break existing projects that were already using InProject, so we decided to support both. But they mean the exact same thing. We'd prefer if people used "Visible" though, as its meaning is clearer.
--Rajeev