【问题标题】:Visual Studio 2015 project template typeVisual Studio 2015 项目模板类型
【发布时间】:2017-07-05 15:29:26
【问题描述】:

我正在创建一个项目模板并将其放入“新建项目”窗口中的特定部分。我在模板文件夹中找到了一个 MyTemplate.vstemplate 类似 xml 的文件,并且有一个条目“ProjectType”。这似乎是解决问题的正确方法,只需在那里设置一个适当的值,但我找不到所有可用类型的列表。将模板放入“Visual C#”或“Visual Basic”部分没有问题,但我想放入“其他项目类型”或“Visual Studio 解决方案”下。

最大的成就是设置模板和扩展。

任何想法都会受到赞赏。谢谢

csproj 内容:

    <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{$guid1$}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>$safeprojectname$</RootNamespace>
    <AssemblyName>$safeprojectname$</AssemblyName>
    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup>
    <StartupObject />
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.ComponentModel.Composition" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="ModuleRegistry.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <ItemGroup />
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
  <Target Name="TemplateProjectOutputGroup">
  </Target>
</Project>

【问题讨论】:

    标签: visual-studio vs-extensibility project-template


    【解决方案1】:

    您应该使用的不是 ProjectType

    编辑包含 MyTemplate.vstemplate 文件的 csproj 并像这样设置 OutputSubPath 值:

    <VSTemplate Include="MyTemplate.vstemplate">
        <OutputSubPath>ELEVATION</OutputSubPath>
    </VSTemplate>
    

    【讨论】:

    • 但是没有VSTemplate这样的条目
    • 你需要添加它。
    • 那么,具体在哪里?在&lt;project&gt; 下或更深?我必须使用什么值才能进入“Visual Studio 解决方案”部分?
    • 对不起,我不明白。您的 csproj 文件中没有列出 MyTemplate.vstemplate?如果你做了它是如何列出的?
    • 很抱歉造成误会。但是vstemplate 没有在项目文件中的任何地方列出,您建议添加它。我在问应该在哪里添加它。
    猜你喜欢
    • 2016-02-26
    • 2017-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-18
    • 1970-01-01
    相关资源
    最近更新 更多