Visual Studio 自定义项模板依赖于

发布于 2024-10-01 13:58:25 字数 294 浏览 1 评论 0原文

我正在编写自己的自定义项目模板,以便在 Visual Studio 中使用。一切都很好,除了我需要找到一种方法使模板中的一个文件依赖于另一个文件。

在 csproj 文件中,它看起来像这样

<Compile Include="Class1.cs">
    <DependentUpon>Class1.xml</DependentUpon>
</Compile>

有人知道我如何在 vstemplate 文件中定义它吗?

谢谢

I'm writing my own custom item template for use within visual studio. All is well except I need to find a way to get one of the files in the template to be dependent upon another.

In a csproj file it would look like this

<Compile Include="Class1.cs">
    <DependentUpon>Class1.xml</DependentUpon>
</Compile>

Does anybody have any idea how I would define this in the vstemplate file?

Thanks

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

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

发布评论

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

评论(2

调妓 2024-10-08 13:58:25
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs" ReplaceParameters="true">Test.cs</ProjectItem>
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs\$fileinputname$Dependent.cs" ReplaceParameters="true">TestDependent.cs</ProjectItem>
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs" ReplaceParameters="true">Test.cs</ProjectItem>
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs\$fileinputname$Dependent.cs" ReplaceParameters="true">TestDependent.cs</ProjectItem>
岁月如刀 2024-10-08 13:58:25

不确定对于非托管文件类型(即 VS 不知道的文件类型,例如您的文件类型)是否会自动发生这种情况...

一个黑客方法是使用 WizardExtensions(google 提供有关编写基本向导的示例),如下所示:

  • 最初将文件添加为 .cs 和 .designer.cs。
  • 然后使用 WizardExtensions 重命名这些文件

,或者

  • 查看向导扩展是否可以直接修改 csproj(但这很困难,因为 VS 可能不允许您在不先卸载项目的情况下执行此操作)。

希望这有帮助...

Not sure if this can happen automatically for non-managed file types (i.e. file types that VS doesn't know about, like yours)...

A hack would be to use WizardExtensions (google for examples on writing a basic wizard) like this:

  • Add the files initially as .cs and .designer.cs.
  • Then use wizardExtensions to rename those files

or

  • see if wizard extensions can directly modify the csproj (but that be difficult as VS might not let you do that without unloading the project first).

hope this helps...

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