找不到 Visual Studio 项目模板 *.projitems

Pau*_*son 1 c# project-template visual-studio

我创建了一个视觉工作室模板,效果很好。但是当我尝试使用这个新模板将新项目添加到我的解决方案中时,我收到以下错误:

"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"
Run Code Online (Sandbox Code Playgroud)

背景资料:

我的解决方案包含一个在我的项目模板中引用的共享项目

我的项目模板 *.csproj 中的导入语句如下所示:

<Import Project="..\..\Common\Shared\XY.projitems" Label="Shared" />
Run Code Online (Sandbox Code Playgroud)
  • *.projitems 文件存在与上述相对路径相关。
  • 该文件不存在于上述路径“c:\users\xy\AppData\Local\Temp\qfuczw4e.apk\Temp\”中

该错误消息让我非常困惑。有人给我提示吗?

更新

使用模板创建新项目的项目结构如下:

Solution_XY

   - SharedProject

   - PluginsFolder
     - Project_1
     - Project_2
     - Project_3
Run Code Online (Sandbox Code Playgroud)

创建的项目位于解决方案中的特殊项目文件夹中。所以Project_1到Project_3在模板创建时需要有对SharedProject的引用。

小智 5

我也遇到了同样的问题,这里没有答案。这是因为参数替换是在临时文件夹中完成的,如您所见。任何人都可以猜测他们为什么要检查路径。

无论哪种方式,修复方法都是将CreateInPlace模板数据设置为“true”。

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
  <TemplateData>
    ...
    <CreateInPlace>true</CreateInPlace>
  </TemplateData>
Run Code Online (Sandbox Code Playgroud)

弄清楚这一点真的很痛苦。希望它能帮助某人。

该问题与它是多项目模板无关。我在制作多项目模板时解决了这个问题。