0

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

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

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

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)

4

1 回答 1

1

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

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

<ItemGroup> <Compile Include="App_Start\BundleConfig.cs" /> <Compile Include="App_Start\FilterConfig.cs" /> <Compile Include="App_Start\IdentityConfig.cs" /> </ItemGroup>

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

<ItemGroup> <Reference Include="Microsoft.CSharp" /> <Reference Include="System" /> <Reference Include="System.Data" /> </ItemGroup>

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

奇怪的是 VSTO 项目使用了一些我还没有看到的其他元素名称,应该将其添加到默认列表中。

如何解决它

查看项目文件并检查ItemGroup那些在属性中没有文件路径的元素的名称,Include如果它们尚未列在有问题的默认列表中。

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

<ItemGroup> <ls-NonFileTypes Include="Service;BootstrapperPackage;"/> </ItemGroup>

或者您也可以将其声明为(它们是等效的)

xml <ItemGroup> <ls-NonFileTypes Include="Service"/> <ls-NonFileTypes Include="BootstrapperPackage"/> </ItemGroup>

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

于 2015-01-14T04:03:30.303 回答