I exported a Project template from a working class library project, which has the following linked file element:
<Compile Include="..\DalBase.cs">
<Link>DalBase.cs</Link>
</Compile>
This works fine in the original project, but when I create a project from my template the include path ends up pointing to some temp folder, such as:
C:\Documents and Settings\bradk\Local Settings\Temp\5oohnkvn.04c\DalBase.cs
The linked file is obviously broken then, and the project won't compile. Is there any way around this I tried a custom parameter with the relative path in it, and the same problem persists.

c# Project template with linked file
Minho
Whitney
A custom wizard would be the only way to work around this unfortunately.
http://msdn2.microsoft.com/en-us/library/ms185301.aspx
/Ole
Nabz
Col38983
SMAlbright
That's what I ended up doing (adding the item through code), I haven't tried this with the recently released VS SP1, but that thing takes so long to install that I'm not sure if I will be recommending people to use it.
Gabo
jwise
Gabo/anyone,
Did you get anywhere with this As far as my own experiments are concerned this appears to be another bug in the extensibility model - if so, that sucks but is there a workaround in any way shape or form other than developers manually adding the links
Like you I have a scenario where the file to be linked already exists in a relative parent folder. If I just specify the relative path to it in the .csproj file in the template zip, then the Wizard screws up the path by prefix a bunch more "..\" characters so the link is broken.
So if I have this in my wizard template .csproj file (which is exactly what I want to end up with):
<ItemGroup>
<Compile Include="..\..\..\Configuration\AssemblyCommonInfo.cs">
<Link>Properties\AssemblyCommonInfo.cs</Link>
</Compile>
...
Then after the wizard runs, it adds "..\..\..\..\" to the path, such that the folder effectively becomes "C:\Configuration\AssemblyCommonInfo.cs" which is nonsense.
The directory created by the project wizard is in:
C:\folder1\folder2\folder3\folder4\folder5\folder6\MyNewProjectFolderByWizard
The linked file already exists at:
C:\folder1\folder2\folder3\folder4\Configuration\AssemblyCommonInfo.cs
Some form of resolution much appreciated - without it this is a major downgrade from the functionality in our VS.Net 2003 wizards.
Thanks,
Grant.
RolandKlein
Hmm, answering my own question - I did find a workaround which was mentioned earlier in the thread of doing it programmatically in the IWizard implementation class.
For anyone else wondering on the details reading this later - I stripped out the above <Compile Include=".... snippet from the csproj file.
Then in the IWizard.ProjectFinishedGenerating method, I added the following code (my linked file I want to be in the "Properties" subfolder of the project):
ProjectItem propertiesProjectItem = project.ProjectItems.Item(1);propertiesProjectItem.ProjectItems.AddFromFile(ABSOLUTE_PATH_TO_LINKED_FILE);
This correctly converts the absolute path to a relative one within the generated .csproj file - sorted.
Janikocjan
If the linked file already exists in the parent directory of the newly created project I don't see any reason to have your vstemplate file know about that linked file. Just add the link in project file located in the zip file and your project should end up fine after it has been created.
Ole
Arturo Moreno
That's not the case, if the file exists in the parent directory (i.e.: C:\Projects\MyFile.cs and the project is in C:\Projects\MyProject) then for some reason the csproj file ends up resolving this to some for of C:\Documents and Settings.
If the linked file exists in a folder that is not a parent folder of the project file (i.e: C:\Temp\MyFile.cs) then it works but I think the behavior is wrong.
Gabo