在Visual Studio(2008)中,是否可以在另一个自定义文件上包含一个自定义依赖文件? [英] In Visual Studio (2008) is there a way to have a custom dependent file on another custom file?

查看:94
本文介绍了在Visual Studio(2008)中,是否可以在另一个自定义文件上包含一个自定义依赖文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个* .js文件,而不是后面的* .cs代码.我正在开发MVC应用程序,因为我有控制器,所以不需要任何代码,但是在某些情况下,最好在JavaScript代码旁边或以某种方式将文件与正在使用的页面关联起来.我想我可以用类似的方式命名它们,但是我想尽可能显示关联,所以对于文件的用途没有疑问.

Instead of a *.cs code behind or beside I'd like to have a *.js file. I'm developing a MVC application an have no need for a code beside because I have controllers, but in certain cases it'd be nice to have a JavaScript code beside or some way to associate the file to the page it's being used on. I suppose I could just name them similarly, but I'm wanting to show the association if possible so there's no question about what the file is for.

通常,我要说的是在Visual Studio中的Global.asax文件下,您会在左侧有一个加号:

Typically what I'm talking about is within Visual Studio now under your Global.asax file you will have a plus sign to the left:

+ Global.asax

展开后,您将得到

- Global.asax
    Global.asax.cs

我希望发生同样的事情:

I'd like the same thing to happen:

+ Home.spark

- Home.spark
    Home.spark.js

已更新:

我现有的csproj文件具有指向实际文件的路径,不确定是否将其弄乱了.我目前有:

My existing csproj file has a path to the actual file, not sure if that's screwing it up. I've currently got:

<ItemGroup>
    <Content Include="Views\User\Profile.spark.js">
      <DependentUpon>Views\User\Profile.spark</DependentUpon>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <Content Include="Views\User\Profile.spark" />
  </ItemGroup>

只是将文件显示在彼此之间.

and it's simply just showing the files besides each other.

推荐答案

当然-但是您必须手动编辑项目文件.找到您的子"文件的条目,并将其更改为非自关闭元素,然后添加一个子元素以说明其依赖的内容.这是一个正在编译.cs文件的示例:

Absolutely - but you'll have to edit the project file by hand. Find your "child" file's entry, and change it to be a non-self-closing element, and add a child element to say what it depends on. Here's an example for a .cs file being compiled:

<Compile Include="AssertCount.cs">
  <DependentUpon>MoreEnumerable.cs</DependentUpon>
</Compile>

这是我刚刚为您指定的文件模拟的版本-尽管我希望Home.spark将具有与其关联的操作,而不是无":

And here's a version I've just mocked up for the files you've specified - although I expect Home.spark will have an action associated with it rather than "None":

<ItemGroup>
  <Content Include="Home.spark.js">
    <DependentUpon>Home.spark</DependentUpon>
  </Content>
</ItemGroup>
<ItemGroup>
  <None Include="Home.spark" />
</ItemGroup>

Visual Studio会像您期望的那样显示它.

Visual Studio displays it just as you'd expect it to.

这篇关于在Visual Studio(2008)中,是否可以在另一个自定义文件上包含一个自定义依赖文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆