如何处理 SideWaffle 项目模板中的 VSTO 先决条件 [英] How to handle VSTO prerequisites in SideWaffle project template

查看:35
本文介绍了如何处理 SideWaffle 项目模板中的 VSTO 先决条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在根据以下视频使用 SideWaffle 构建 VSTO 项目模板:

I'm building a VSTO project template with SideWaffle following the video from:

如何使用 TemplateBuilder 和 SideWaffle 创建 Visual Studio 项目模板

我添加了一个现有的(新的)存根 VSTO 项目,将其设置为不在调试和发布中构建,但是当我按 Ctrl+F5 启动实验 VS 实例时,我收到以下三个构建错误:

I added an existing (new) stub VSTO project, set it not to build in both debug and release, but when I hit Ctrl+F5 to launch the Experimental VS instance I get the following three build errors:

Could not copy the file "c:\users\john\documents\visual studio 2013\Projects\VisioVstoTemplate\VisioVstoTemplate\.NETFramework,Version=v4.5" because it was not found.  VisioVstoVSIX
Could not copy the file "c:\users\john\documents\visual studio 2013\Projects\VisioVstoTemplate\VisioVstoTemplate\Microsoft.VSTORuntime.4.0" because it was not found.   VisioVstoVSIX
Could not copy the file "c:\users\john\documents\visual studio 2013\Projects\VisioVstoTemplate\VisioVstoTemplate\Microsoft.Windows.Installer.4.5" because it was not found. VisioVstoVSIX

所以问题是:

  1. 为什么首先要寻找这些先决条件
  2. 如何避免错误?

(使用 Visual Studio 2013 Ultimate(更新 4)、SideWaffle 1.15 和 TemplateBuilder 1.1.2-beta5)

推荐答案

我很确定我确切地知道这里发生了什么.我从未使用 VSTO 项目测试过 SideWaffle/TemplateBuilder.

I am pretty sure that I know exactly what is happening here. I've never tested SideWaffle/TemplateBuilder with a VSTO project.

在构建模板时,有一个步骤是使用项目文件中的文件填充 _project.vstemplate.xml 的内容.因此,如果项目中列出的所有文件尚未列出,它们将被添加到 xml 文件中.这是通过检查在 <ItemGroup></ItemGroup> 中作为元素列出的项目来实现的.例如

When templates are built there is a step where the contents of the _project.vstemplate.xml are populated using the files from the project file. So all files listed in the project will be added to the xml file if they were not already listed. This is implemented by examining the items listed as elements inside <ItemGroup></ItemGroup>. For example

<代码><项目组><编译 Include="App_Start\BundleConfig.cs"/><编译 Include="App_Start\FilterConfig.cs"/><编译 Include="App_Start\IdentityConfig.cs"/></项目组>

有时这些元素指向不是文件且不应复制的项目.例如.

Sometimes these elements point to items which are not files and should not be copied. For example.

<代码><项目组><Reference Include="Microsoft.CSharp"/><Reference Include="系统"/><Reference Include="System.Data"/></项目组>

TemplateBuilder 知道哪个是通过 MSBuild 项ls-NonFileTypes 的方式.默认值在 .targets 文件中定义,位于 https://github.com/ligershark/template-builder/blob/master/tools/ligershark.templates.targets#L75.

The way that TemplateBuilder knows which is by an MSBuild item ls-NonFileTypes. The default values for this are defined in the .targets file at https://github.com/ligershark/template-builder/blob/master/tools/ligershark.templates.targets#L75.

很可能 VSTO 项目使用了一些我还没有看到的其他元素名称,这些名称应该添加到默认列表中.

Odds are that VSTO projects use some other element name which I have not seen yet which should be added to the default list.

查看项目文件并检查 ItemGroup 下元素的名称,以及那些在 Include 属性中没有文件路径的元素(如果没有)已经在默认列表中列出了在默认列表中一个问题.

Take a look at the project file and examine the names of elements under ItemGroup and for those that do not have a file path in the Include attribute if they are not already listed in the default list that's a problem.

在安装了 TemplateBuilder 的项目中,在 Properties\template-builder.props 中有一个新的 props 文件.确定应在项目中过滤哪些项目类型后,您可以将其添加到该文件中.例如.

In a project which has TemplateBuilder installed there is a new props file at Properties\template-builder.props. Once you determine which item types should be filtered in your project you can add it in that file. For example.

<代码><项目组><ls-NonFileTypes Include="Service;BootstrapperPackage;"/></项目组>

或者你也可以将它声明为(它们是等价的)

or you could also have it declared as (they are equivalent)

<代码>xml<项目组><ls-NonFileTypes Include="Service"/><ls-NonFileTypes Include="BootstrapperPackage"/></项目组>

SideWaffle 也使用它https://github.com/ligershark/side-waffle/blob/master/TemplatePack/Properties/template-builder.props#L30.

SideWaffle uses this as well https://github.com/ligershark/side-waffle/blob/master/TemplatePack/Properties/template-builder.props#L30.

这篇关于如何处理 SideWaffle 项目模板中的 VSTO 先决条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆