在Visual Studio 2010中创建多项目(解决方案)模板【二】(VS2017)

    首先,这里要感谢dax.net的《在Visual Studio 2010中创建多项目(解决方案)模板【二】》一文。这里给出了一个解决对项目模板处理项目名称的思路。

    我使用的环境不是VS2010而是VS2017。可能是微软更新的原因,解决子项目引用项目名称的问题变得简单了。

    我们可以改造之前的子项目引用代码

<ProjectTemplateLink ProjectName="$safeprojectname$.Application" CopyParameters="true">
  CMSTemplate\Application\MyTemplate.vstemplate
</ProjectTemplateLink>

    这里我们加了一个参数CopyParameters,这个参数的说明是:

If this is set to 'true', all parameters/variables in the main template will be available in the nested vstemplates with an 'ext_' prefix. For example the main template parameter $safeprojectname$ will become $ext_safeprojectname$ in the nested template - the nested template will therefore have $safeprojectname$ and $ext_safeprojectname$.

    意思是:

    如果这个值设置为"true"那么主项目的所有参数会传递给子项目,使用的时候在原参数名称前加'ext_'前缀即可。例如:主项目参数$safeprojectname$在子项目中可以通过$ext_safeprojectname$参数获取,这样子项目中就可以同时使用$safeprojectname$和$ext_safeprojectname$两个参数。

    也就是说我只需要将项目中剩余的RainbowCMS替换成$ext_safeprojectname$即可。在创建项目时$ext_safeprojectname$就会替换成自己设置的【项目名称】了,而不会向前文那样背替换成【项目名称.Application】。从而达到我们预期的效果。这样也省去了GAC的设置了,比VS2010中的设置简单了许多。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值