Reputation: 3154
I am attempting to create a Visual Studio Project template, and would like to set the name of a file to match that of the project. PerMSDN, this should be achievable using the TargetFileName parameter:
The TargetFileName attribute can also be used to rename files with parameters. The following procedure explains how to rename the file MyFile.vb, which exists in the root directory of the template .zip file, to a file name based on the project name.
I have modified the TargetFileName attribute of file Class1.cs to $safeprojectname$
:
<ProjectItem ReplaceParameters="true" TargetFileName="$safeprojectname$.cs">Class1.cs</ProjectItem>
When I try to use the template, I receive this error:
Unable to copy the file 'Class1.cs' from the project template to the project. Cannot find file "C:\Users\Dsolovay\AppData\Local\Temp\5vuyjuhv.y0c\Temp\Class1.cs".
Upvotes: 2
Views: 822
Reputation: 3154
The step I was missing was to update the csproj file to use the wildcard name. I had to change this:
<Compile Include="Class1.cs" />
to this:
<Compile Include="$safeprojectname$.cs" />
See https://msdn.microsoft.com/en-us/library/ys81cc94(v=vs.100).aspx.
Upvotes: 1