Visual Studio中:如何覆盖默认的"生成动作"每项目或解决方案的某些扩展类型? [英] Visual Studio: How to override the default "Build Action" for certain extension types per project or solution?

查看:317
本文介绍了Visual Studio中:如何覆盖默认的"生成动作"每项目或解决方案的某些扩展类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是从很多组件服务我的asp.net mvc的观点和看法复制到生成后事件的主要应用。

I'm serving my asp.net mvc views from many assemblies and copying views to the main application on post-build event.

这个作品,但是,我意识到,当我改变鉴于东西,只是打F5,不包括的变化。我必须做的,看到的变化是:保存,建立和LT; - 明确单击,然后按F5。然而,这是pretty恼人的解决方案。

This works, however, I realized, that when I change something in view and just hit F5, changes are not included. What I have to do to see changes is to: save, build<- explicitly clicking, and then hit F5. However, it's pretty annoying solution.

我发现,设置生成操作在查看嵌入的资源解决问题为好,但其他开发者可能不记得他们有增加每个视图的解决方案后,要做到这一点。

I discovered that setting Build action to "Embedded Resource" on view solves the problem as well, however other devs may not remember that they have to do this after adding every view to the solution.

有没有办法来覆盖某些文件扩展名,如默认生成操作:在项目或溶液*的.aspx,*的.ascx(更好的)

Is there a way to override the default build action for certain file extensions, such as: *.aspx, *.ascx in project or (better) in solution ?

我发现的是在全球范围内添加此设置,每台机器的能力,但我并不想这样做(链接:<一个href=\"http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default-build-action-for-non-default-file-types.aspx\">http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default-build-action-for-non-default-file-types.aspx)

What I've found is an ability to add this setting globally, per machine, but I do not want to do that (link: http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default-build-action-for-non-default-file-types.aspx)

任何想法?

推荐答案

考虑以下项目文件概述:

Consider the following project file outline:

<Project ToolsVersion="3.5" DefaultTargets="EmbedViews;Build" ...>
...
  <Target Name="EmbedViews">
    <ItemGroup>
      <EmbeddedResource Include="Views\*\*.aspx" />
      <EmbeddedResource Include="Views\*\*.ascx" />
    </ItemGroup>
  </Target>
</Project>

这将增加所有 ASPX ASCX 文件浏览\\&LT;子&GT; 您库嵌入的资源。请注意, EmbedViews 添加到 DefaultTargets 构建 - 为了在这里很重要,我发现犯那个错误我: - )

This will add all aspx and ascx files in Views\<subfolder> to your library as Embedded Resource. Notice that EmbedViews is added to DefaultTargets before Build - order is important here, I found out making that mistake myself :-)

由于编辑的所有项目文件得到这个片段中很麻烦,你可以把包含在此你自己的项目模板。

Since editing all your project files to get this snippet in is cumbersome, you could make your own project template with this included.

请让我知道如果这有助于。

Please let me know if this helped.

这篇关于Visual Studio中:如何覆盖默认的&QUOT;生成动作&QUOT;每项目或解决方案的某些扩展类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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