如何在 VSTemplate 中创建评估的自定义参数

发布于 2024-12-14 11:14:19 字数 930 浏览 3 评论 0原文

所以我正在修改一个多项目VS模板(Visual Studio项目模板),并且我想在根模板中设置一个自定义参数以供子模板使用。但是,我想根据现有参数进行设置。

因此,例如,这可以正常工作:

变量 $FaultProject$ 被 MyProject.FaultContracts 替换,因为它应该是。

但是,这不起作用:

我希望 $safeprojectname$ 被正确的值替换,但事实并非如此。相反,变量 $FaultProject$ 被替换为 $safeprojectname$.FaultContracts。 $safeprojectname$ 被解释为文字而不是参数。

尽管在同一个文件中,这完全按照预期工作:

WCFFaultContract\FaultContract.vstemplate

Any想法会有帮助的。我相信我也许能够编写一个 IWizard 类来执行此操作,但如果可能的话,我宁愿避免使用这样一个简单的函数。

或者,如果我可以获得一个包含根模板的 $safeprojectname$ 值的参数,这也可以满足我的需求(在子模板中,$safeprojectname$ 更改为子项目的名称,而不是它的值)位于根模板中)。

So I'm modifying a multi-project VS Template (Visual Studio project template), and I want to set a Custom Parameter in the root template to be used by the sub templates. However, I want to set it based on an existing parameter.

So, for example, this works fine:

<CustomParameter Name="$FaultProject$" Value="MyProject.FaultContracts"/>

The variable $FaultProject$ is replaced by MyProject.FaultContracts, as it should be.

This, however, does not work:

<CustomParameter Name="$FaultProject$" Value="$safeprojectname$.FaultContracts"/>

I expect $safeprojectname$ to be replaced by the correct value, but it is not. Instead, the variable $FaultProject$ is replaced by $safeprojectname$.FaultContracts. The $safeprojectname$ is interpreted as a literal rather than the parameter that it is.

This is in spite of the fact that in the same file, this works exactly as expected:

<ProjectTemplateLink ProjectName="$safeprojectname$.FaultContracts">WCFFaultContract\FaultContract.vstemplate</ProjectTemplateLink>

Any ideas would be helpful. I believe I might be able to write an IWizard class that would do this, but I'd rather avoid that for such a simple function, if possible.

Alternatively, if I can get a parameter that contains the value of the root template's $safeprojectname$, that would address my need as well (in the sub-templates, $safeprojectname$ is changed to the sub-project's name, not the value it had in the root template).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

百善笑为先 2024-12-21 11:14:19

在多项目模板中,您基本上只能在项目级别具有替换参数。根模板位于解决方案级别,基本上不能在其中包含 $safeprojectname$。但是,您可以实现 IWizard 接口,并可以拥有自己的替换参数,并替换为您给出的值。

In a multi project template you can basically have replacement parameters only at the project level. The root template is at the solution level and you basically cannot have $safeprojectname$ in there. However you could implement IWizard interface and can have your own replacement parameters, substituted with the values you give.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文