VS2017 新的 csproj 类型不从 VSTemplate 输出文件

VS2017 new csproj type not outputting files from VSTemplate

如果我在 VS2017 中基于新的 csproj 格式创建一个新库,例如

<Project Sdk="Microsoft.NET.Sdk">

当我创建 VSTemplate,然后使用模板时,它会创建项目,但是 none 的文件被复制,即使它们位于模板文件夹中。

我发现的一个例外是,如果任何文件是嵌入式资源并因此被标记为这样

<ItemGroup>
  <EmbeddedResource Include="App.xaml">       
     <Generator>MSBuild:UpdateDesignTimeXaml</Generator>     
  </EmbeddedResource>   
</ItemGroup>

该文件将输出到项目中。但即使 App.xaml.cs 也没有通过。

我使用旧 csproj 格式创建的任何 VSTemplate 都按预期工作。

我可以通过将 <CreateInPlace>true</CreateInPlace> 添加到 .vstemplate<TemplateData> 部分来解决这个问题。例如:

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
  <TemplateData>
    <Name>Service Template</Name>
    <Description></Description>
    <ProjectType>CSharp</ProjectType>
    <ProjectSubType>
    </ProjectSubType>
    <SortOrder>1000</SortOrder>
    <CreateNewFolder>false</CreateNewFolder>
    <DefaultName>NewService</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
    <LocationField>Enabled</LocationField>
    <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
    <CreateInPlace>true</CreateInPlace>
  </TemplateData>

从您在评论中发布的 first issue 中找到的解决方案。