我正在为我的公司创建一个用于MVC 4应用程序的自定义VSTemplate,它使用的向导与创建新MVC4应用程序时出现的向导相当.当开发人员创建此类型的新应用程序时,我想要应用两个模板中的一个:

这两个条目都对应于我的VSIX项目中名为ProjectTemplates的文件夹中定义的模板:

我的问题是,如何在向导运行时应用正确的模板?我知道如何使用多个项目创建一个vstemplate(使用vstemplate中的ProjectCollection节点),但这不是我想要做的,因为它们永远不会一起部署.我看到我可以将vstemplates作为Assets添加到我的vsixmanifest文件中,但我不确定如何有条件地仅应用一个模板.
谢谢!
我有一个VS 2013项目模板,其中包含如下项目
<ProjectItem ReplaceParameters="true" TargetFileName="Target.xml">Target.xml</ProjectItem>
Run Code Online (Sandbox Code Playgroud)
我想要的是"Target.xml"是MyProjectName.xml.
我知道我可以在文件中使用变量但不能在名称中使用变量.
谢谢
G
我使用 Visual Studio 2015 更新 2 社区版。
使用 Visual Studio DotNetCore RC1 工具,我在 DNX 部分下有我的自定义项目模板。我无法提供证明截图,因为我已经转移到 DotNetCore RC2 工具预览版 1。使用最后一组工具,我丢失了我的项目模板。
我尝试将 ProjectType 和 ProjectSubType 从 DNX 更改为 CSharp/Web,尝试将组件放在不同的地方,但没有成功。
最后一个 .vstemplate 文件有以下内容
<?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>ReactComponent</DefaultName>
<Name>ReactComponent</Name>
<Description>ReactComponent</Description>
<TemplateID>Chandrush.ReactComponent</TemplateID>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>Web</ProjectSubType>
<Icon>__TemplateIcon.ico</Icon>
</TemplateData>
<TemplateContent>
<References />
<ProjectItem TargetFileName="$fileinputname$\$fileinputname$.tsx" ReplaceParameters="true">ReactComponent.tsx</ProjectItem>
<ProjectItem TargetFileName="$fileinputname$\package.json" ReplaceParameters="true">package.json</ProjectItem>
<ProjectItem TargetFileName="$fileinputname$\$fileinputname$.scss" ReplaceParameters="true">ComponentStyle.scss</ProjectItem>
</TemplateContent>
</VSTemplate>
Run Code Online (Sandbox Code Playgroud)
有人知道使用 .NetCore RC2 preview1 工具将自定义项目模板恢复到 VS2015u2 的解决方案吗?
我想更改 Resources.resx 模板。
每当我添加一个新的资源文件时,它应该以以下形式显示自动生成的代码:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.296
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectName.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建类似于MVC的Area的ItemTemplate。无论如何,我无法在TemplateContent中创建一个包含TargetFolderName和参数的文件夹。这是我的TemplateContent部分的简化示例:
<TemplateContent>
<Folder Name="Area" TargetFolderName="$AreaName$">
<ProjectItem ReplaceParameters="true" TargetFileName="$AreaName$Controller.cs">Controller.cs</ProjectItem>
</Folder>
</TemplateContent>
Run Code Online (Sandbox Code Playgroud)
即使MSDN指出TargetFolderName为
对于使用参数替换来创建文件夹名称或使用无法在.zip文件中直接使用的国际字符串命名文件夹很有用。
尽管如此,我还是无法完成这项工作。
输入“ TestArea ”的预期结果:
TestArea
|__ TestAreaController.cs
Run Code Online (Sandbox Code Playgroud)
实际结果:
$AreaName$
|__ TestAreaController.cs
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
提前致谢。
我正在 Visual Studio 中整理一个模板项目供我的部门使用。项目需要引用一些存储在TFS其他地方的常用库。问题是模板可能会在各种位置使用,而我在尝试可靠地设置 HintPath 以处理所有位置时遇到了麻烦。
模板化项目需要能够在本地和 TFS 中找到公共库,以便在构建中使用。目前,在我们现有的应用程序中,引用如下所示:
<Reference Include="Company.Common">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Core Components\Libraries\Company.Common\Latest\Company.Common.dll</HintPath>
</Reference>
Run Code Online (Sandbox Code Playgroud)
但是到达根节点需要遍历的父节点数量可能会有所不同。
与其为 ../、../../、../../../ 等设置 50 个条件路径,我的第一个想法是设置一个绝对引用。工作文件夹在我们的组织中是标准化的,因此在本地,始终可以在 C:\Projects\Core Components\...
但这不适用于服务器构建。所以我想我需要某种环境变量来解决 $/. 我正在想象这样的事情:
<Choose>
<When Condition="Exists('C:\Projects')">
<ItemGroup>
<Reference Include="Company.Common">
<HintPath>C:\Projects\Core Components\Libraries\Company.Common\Latest\Company.Common.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Company.Common">
<HintPath>$(TFSRoot)\Core Components\Libraries\Company.Common\Latest\Company.Common.dll</HintPath>
</Reference>
</ItemGroup>
</Otherwise>
</Choose>
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚如何实现这一点。
更新:
最终,我们确实建立了一个内部 Nuget 服务器。我建议任何有同样困境的人解决任何阻碍您设置 Nuget 的繁文缛节。我们用这种老套的做事方式生活了 3 年,总有一些新的问题需要人工干预。
tfs environment-variables csproj tfsbuild visual-studio-templates