I have a .cs file with a base class that I want to use from many projects. First I placed this cs file above the project folder (next to .sln). Then, as part of the project, I changed
<Compile Include="BaseClass.cs">
for image
<Compile Include="..\BaseClass.cs">
This works, and the file icon has a small arrow.
The problem occurs when I want to export a project as a project template. BaseClass is not included in the template because it is located outside the project folder. I tried adding BaseClass.cs to the zip template and adding
<ProjectItem ReplaceParameters="true" TargetFileName="..\BaseClass.cs">BaseClass.cs</ProjectItem>
to MyTemplate.vstemplate, but I get the error:
A target file name within the VSTemplate file is invalid, it contains a fully qualified path
If I delete ..\, it will contain the file directly. If I leave <ProjectItem>the .vstemplate file and just put it <Compile Include="..\BaseClass.cs">in the .csproj file in the template, it looks for the file in Users/me/AppData/Local....
How can I make a template link to a file outside the project directory?
source
share