我正在尝试在Visual Studio中创建一个在解决方案中具有多个项目的项目模板。
大体上,它工作得很好,我面临的唯一问题是引用解决方案中的其他项目。

正如您在图像中看到的,一个项目被正确引用,因为此路径是设置的,并且不是动态的,其余的都是基于vstemplate文件中的项目名称。
<VSTemplate Version="2.0.0" Type="ProjectGroup"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name> Api Template</Name>
<Description>Base Template for Api Project</Description>
<Icon>Icon.ico</Icon>
<ProjectType>CSharp</ProjectType>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="$projectname$.Api" CopyParameters="true">
Template.Api\Api.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$projectname$.Application" CopyParameters="true">
Template.Application\Appilication.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$projectname$.Infrastructure" CopyParameters="true">
Template.Infrastructure\Infrastructure.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$projectname$.Shared" CopyParameters="true">
Template.Shared\Shared.vstemplate
</ProjectTemplateLink>
<SolutionFolder Name="Common">
<ProjectTemplateLink ProjectName="Mediator.Common" CopyParameters="true">
Mediatr.Common\MediatorCommon.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="Common.Types" CopyParameters="true">
Common.Types\CommonTypes.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="Common.Http" CopyParameters="true">
Common.Http\HttpCommon.vstemplate
</ProjectTemplateLink>
</SolutionFolder>
</ProjectCollection>
</TemplateContent>
</VSTemplate>接下来,在构建引用的.csproj文件中
<ItemGroup>
<ProjectReference Include="..\Mediator.Common\Mediator.Common.csproj" />
<ProjectReference Include="..\$projectname$.Application\$projectname$.Application.csproj" />
<ProjectReference Include="..\$projectname$.Infrastructure\$projectname$.Infrastructure.csproj" />
<ProjectReference Include="..\$projectname$.Shared\$projectname$.Shared.csproj" />
</ItemGroup>这是试图创建引用,但我需要它从中间删除'Api‘。
我已经走到这一步了,根本看不到这个问题
Adding references in Visual Studio project template?
Using CustomParameter with Visual Studio Multi-Project Template
然而,当我在这里查看https://docs.microsoft.com/en-us/visualstudio/ide/template-parameters?view=vs-2019时,当我尝试在引用中添加任何其他项时,都是错误的,只是显示为$value$,而不是项目或任何与它有关的内容。
我怎样才能正确地引用项目,以便我创建的模板不需要立即干预。
发布于 2020-11-17 16:27:57
经过多次搜索,尝试失败后,我终于偶然发现了这个页面
https://www.programmingwithwolfgang.com/create-a-net-core-visual-studio-template/
这让我找到了我想要的答案
<ItemGroup>
<ProjectReference Include="..\$ext_projectname$.Application\$ext_projectname$.Application.csproj" />
<ProjectReference Include="..\$ext_projectname$.Infrastructure\$ext_projectname$.Infrastructure.csproj" />
</ItemGroup>在开始的$之后我错过了ext_
https://stackoverflow.com/questions/64857940
复制相似问题