1

I have created a visual studio template which worked fine. But as soon I try to add a new project to my solution by using this new template I get the following error:

"The imported project "c:\users\xy\AppData\Local\Temp\Common\Shared\XY.projitems" was not found. Confirm 
that the expression in the import declaration "..\..\Common\Shared\XY.projitems" is correct and that the 
file exists on disk."c:\users\xy\AppData\Local\Temp\qfuczw4e.apk\Temp\MyTemplate1.csproj"

Background info:

My solution contains a shared project which is referenced in my project template

The import statement in *.csproj of my project template looks like this:

<Import Project="..\..\Common\Shared\XY.projitems" Label="Shared" />
  • The *.projitems file exists related to the above relative path.
  • The file does NOT exist in the above mentioned path "c:\users\xy\AppData\Local\Temp\qfuczw4e.apk\Temp\"

The error message is very confusing to me. Anybody have a hint for me?

UPDATE

The project structure in which a new project will be created with the template is as follows:

Solution_XY

   - SharedProject

   - PluginsFolder
     - Project_1
     - Project_2
     - Project_3

The projects created are located in a special project folder within the solution. So Project_1 to Project_3 need to have a reference to the SharedProject when created by the template.

  • 1
    I think it’s caused by the differences of reference. I test by using [multi-project templates](https://docs.microsoft.com/en-us/visualstudio/ide/how-to-create-multi-project-templates?view=vs-2019) and error persists, I notice that if I create template only for Shared Project or the other project, they will work without error. Since shared project is [unique](https://docs.microsoft.com/en-us/visualstudio/ide/managing-references-in-a-project?view=vs-2019#shared-project-references), I may consider VS doesn’t support to create a project template which contains a reference to Shared Project. – 大陸北方網友 May 05 '20 at 01:14
  • thank you for your reply on this. yes you're right, it must be related to this as you mentioned. probably then I can forget about creating such a template since even a multi-project-template will not fit, because I cannot have the shared project within the project itself. because the projects based on this template will be created in the solution containing the shared project...se my updated question. – Paul Richardson May 05 '20 at 04:57

1 Answers1

5

I was having this same problem, and there is no answer on here for it. It is caused because parameter replacement is being done in a temporary folder, as you can see. It's anyone's guess why they are checking path.

Either way, the fix is to have the CreateInPlace template data set to 'true'.

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
  <TemplateData>
    ...
    <CreateInPlace>true</CreateInPlace>
  </TemplateData>

This was a real pain to figure this out. Hopefully it will help somebody.

The problem isn't related to it being a multi project template. I solved this problem while making a multi project template.

Alex
  • 710
  • 6
  • 8