Visual Studio: how to override the standard "build action" for certain types of extensions for each project or solution?

I serve my asp.net mvc views from many assemblies and copy the views to the main application on an event after the build.

This works, however, I realized that when I change something and just press F5, the changes are not included. What I need to do to see the changes is: save, build <- click explicitly, and then press F5. However, this is a rather annoying decision.

I found that setting the Build action to "Embedded Resource" in the view also solves the problem, but other developers may not remember that they should do this after adding each view to the solution.

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

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

Any ideas?

+7
-studio of visual the build an asp.net-mvc the action
July 23. '10 at 16:20
source share
2 answers

Consider the following project:

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

This will add all aspx and ascx files in Views\<subfolder> to your library as Embedded Resource . Please note that EmbedViews added to DefaultTargets before Build - the order is important here, I myself found this error DefaultTargets

Since editing all your project files to get this snippet is cumbersome, you can create your own project template with it turned on.

Please let me know if this helps.

+6
02 Feb 2018-11-18T00:
source share

If someone asks a question here, there is still no way to do it if you want it to work with current and future members.

In VS 2017 when you add a new file in the presence of rules catch-all (for example, Content Include = "**.*ts" ), if you add a new file, it will add its own line in the <ItemGroup> with its own BuildAction , ignoring your predefined catch-all.

0
Dec 15 '17 10:45
source share



All Articles