gpt4 book ai didi

asp.net - 多项目模板引用损坏

转载 作者:行者123 更新时间:2023-12-02 01:32:56 25 4
gpt4 key购买 nike

我正在构建多项目模板。子项目之一是 ASP.NET Web 应用程序。当我将它导出为单个项目模板时,一切都很好,但是当包含在多项目模板中时,几乎一半的引用都被破坏了(Antlr3.Runtime、EntitiFramework、Microsoft.Owin 和许多其他)

多项目模板如下所示:

<VSTemplate Version="3.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Web Api Solution Template</Name>
<Description>Template commonly used in projects</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>
</ProjectSubType>
<SortOrder>1000</SortOrder>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>Web_API</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<LocationField>Enabled</LocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<Icon>IconSolution.png</Icon>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="Api">
Api\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="BLL">
BLL\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="DBModel">
DBModel\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink CopyParameters="true" ProjectName="Web">
Web\MyTemplate.vstemplate
</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
</VSTemplate>

为什么会这样?

最佳答案

使用模板向导扩展解决了这个问题。基本上我所做的是从子项目中删除所有预安装的 nuget 包,并使用向导扩展添加它们,以便 project.vstemplate 的末尾看起来像这样:(在本例中为 api)

    <WizardExtension>
<Assembly>NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>NuGet.VisualStudio.TemplateWizard</FullClassName>
</WizardExtension>
<WizardData>
<packages>
<package id="EntityFramework" version="6.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Core" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Owin" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Cors" version="5.2.3" />
<package id="Microsoft.AspNet.Mvc" version="5.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="5.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.HelpPage" version="5.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.0" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Cors" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Cookies" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Facebook" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Google" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.MicrosoftAccount" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.OAuth" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Twitter" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
</packages>
</WizardData>
</VSTemplate>

据我所知,您可以复制粘贴 Assembly 部分,因为它以后不会更改。

关于asp.net - 多项目模板引用损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33037587/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com